From a2925a079fa04ff4c891016a0eea1818bdb2cf4b Mon Sep 17 00:00:00 2001 From: Eyal Soha Date: Thu, 23 Apr 2020 08:34:42 -0700 Subject: Run failing packetimpact test and expect failure. This will make it easier to notice if a code change causes an existing test to pass. PiperOrigin-RevId: 308057978 --- test/packetimpact/tests/test_runner.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'test/packetimpact/tests/test_runner.sh') diff --git a/test/packetimpact/tests/test_runner.sh b/test/packetimpact/tests/test_runner.sh index e99fc7d09..2be3c17c3 100755 --- a/test/packetimpact/tests/test_runner.sh +++ b/test/packetimpact/tests/test_runner.sh @@ -29,7 +29,7 @@ function failure() { } trap 'failure ${LINENO} "$BASH_COMMAND"' ERR -declare -r LONGOPTS="dut_platform:,posix_server_binary:,testbench_binary:,runtime:,tshark,extra_test_arg:" +declare -r LONGOPTS="dut_platform:,posix_server_binary:,testbench_binary:,runtime:,tshark,extra_test_arg:,expect_failure" # Don't use declare below so that the error from getopt will end the script. PARSED=$(getopt --options "" --longoptions=$LONGOPTS --name "$0" -- "$@") @@ -68,6 +68,10 @@ while true; do EXTRA_TEST_ARGS+="$2" shift 2 ;; + --expect_failure) + declare -r EXPECT_FAILURE="1" + shift 1 + ;; --) shift break @@ -263,6 +267,15 @@ docker exec -t "${TESTBENCH}" \ --local_ipv4=${TEST_NET_PREFIX}${TESTBENCH_NET_SUFFIX} \ --remote_mac=${REMOTE_MAC} \ --local_mac=${LOCAL_MAC} \ - --device=${TEST_DEVICE}" - + --device=${TEST_DEVICE}" && true +declare -r TEST_RESULT="${?}" +if [[ -z "${EXPECT_FAILURE-}" && "${TEST_RESULT}" != 0 ]]; then + echo 'FAIL: This test was expected to pass.' + exit ${TEST_RESULT} +fi +if [[ ! -z "${EXPECT_FAILURE-}" && "${TEST_RESULT}" == 0 ]]; then + echo 'FAIL: This test was expected to fail but passed. Enable the test and' \ + 'mark the corresponding bug as fixed.' + exit 1 +fi echo PASS: No errors. -- cgit v1.2.3