From: Toke Høiland-Jørgensen Date: Thu, 18 Sep 2025 13:38:38 +0000 (+0200) Subject: test_runner: Support retrying tests X-Git-Url: https://git.feebdaed.xyz/?a=commitdiff_plain;h=8fc4edb5ad0fd68fbee2d79118e1d2343791858c;p=0xmirror%2Fxdp-tools.git test_runner: Support retrying tests Some of the xdpdump tests can be a bit flaky, so support automatically retrying failed tests to avoid CI failures every time they fail. Signed-off-by: Toke Høiland-Jørgensen --- diff --git a/lib/testing/test_runner.sh b/lib/testing/test_runner.sh index 18de45a..d866af9 100755 --- a/lib/testing/test_runner.sh +++ b/lib/testing/test_runner.sh @@ -460,6 +460,7 @@ exec_test() local output local ret local prefix + local retries=${TEST_RETRIES:-1} prefix=$(printf " %-30s" "[$testn]") if ! is_func "$testn"; then @@ -467,17 +468,28 @@ exec_test() return 1 fi - if [ "$VERBOSE_TESTS" -eq "1" ]; then - echo "${prefix}START:" - ($testn 2>&1) | sed 's/^/ /' - ret=${PIPESTATUS[0]} - echo " Test $testn exited with return code: $ret" - else - echo -n "$prefix" - output=$($testn 2>&1) - ret=$? - prefix= - fi + while [[ "$retries" -gt 0 ]]; do + if [ "$VERBOSE_TESTS" -eq "1" ]; then + echo "${prefix}START:" + ($testn 2>&1) | sed 's/^/ /' + ret=${PIPESTATUS[0]} + echo " Test $testn exited with return code: $ret" + else + echo -n "$prefix" + output=$($testn 2>&1) + ret=$? + prefix= + fi + if [ "$ret" -eq "0" ]; then + break + else + retries=$[$retries - 1] + [ "$VERBOSE_TESTS" -eq "1" ] && echo " Test failed - retrying $retries more times" + if is_func cleanup_tests; then + cleanup_tests || true + fi + fi + done if [ "$ret" -eq "0" ]; then echo "${prefix}PASS" diff --git a/xdp-dump/tests/test-xdpdump.sh b/xdp-dump/tests/test-xdpdump.sh index 01d1fc0..53f61e5 100644 --- a/xdp-dump/tests/test-xdpdump.sh +++ b/xdp-dump/tests/test-xdpdump.sh @@ -7,6 +7,7 @@ ALL_TESTS="test_help test_interfaces test_capt_pcap test_capt_pcapng test_capt_t XDPDUMP=${XDPDUMP:-./xdpdump} XDP_LOADER=${XDP_LOADER:-../xdp-loader/xdp-loader} +TEST_RETRIES=3 RESULT=""