]> git.feebdaed.xyz Git - 0xmirror/xdp-tools.git/commitdiff
test_runner: Support retrying tests
authorToke Høiland-Jørgensen <toke@redhat.com>
Thu, 18 Sep 2025 13:38:38 +0000 (15:38 +0200)
committerToke Høiland-Jørgensen <toke@toke.dk>
Fri, 19 Sep 2025 14:06:08 +0000 (16:06 +0200)
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 <toke@redhat.com>
lib/testing/test_runner.sh
xdp-dump/tests/test-xdpdump.sh

index 18de45affb1f2fe66965608ee76924e804fd63e6..d866af98143ea910fe54cacdf5eb035729ad10cc 100755 (executable)
@@ -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"
index 01d1fc0358687864f461082a569652ea1ed0cbf0..53f61e5d243b3c966cc89906a024283b871b8d43 100644 (file)
@@ -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=""