]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/shell: preserve result directory with NFT_TEST_FAIL_ON_SKIP
authorThomas Haller <thaller@redhat.com>
Fri, 6 Oct 2023 09:42:19 +0000 (11:42 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 10 Oct 2023 18:18:41 +0000 (20:18 +0200)
On a successful run, the result directory will be deleted (unless run
with "-k|--keep-logs" option or NFT_TEST_KEEP_LOGS=y).

With NFT_TEST_FAIL_ON_SKIP=y, when there are no failures but skipped
tests, also preserve the result.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/run-tests.sh

index 4ff0b55ad7b1663b0bb1692bfcc34b316f7052ab..7672b2fe5074fa94957f823660db9b346dd928e1 100755 (executable)
@@ -850,7 +850,12 @@ echo ""
 kmemleak_found=0
 check_kmemleak_force
 
-if [ "$failed" -gt 0 ] || [ "$NFT_TEST_FAIL_ON_SKIP" = y -a "$skipped" -gt 0 ] ; then
+failed_total="$failed"
+if [ "$NFT_TEST_FAIL_ON_SKIP" = y ] ; then
+       failed_total="$((failed_total + skipped))"
+fi
+
+if [ "$failed_total" -gt 0 ] ; then
        RR="$RED"
 elif [ "$skipped" -gt 0 ] ; then
        RR="$YELLOW"
@@ -875,7 +880,7 @@ END_TIME="$(cut -d ' ' -f1 /proc/uptime)"
 WALL_TIME="$(awk -v start="$START_TIME" -v end="$END_TIME" "BEGIN { print(end - start) }")"
 printf "%s\n" "$WALL_TIME" "$START_TIME" "$END_TIME" > "$NFT_TEST_TMPDIR/times"
 
-if [ "$failed" -gt 0 -o "$NFT_TEST_KEEP_LOGS" = y ] ; then
+if [ "$failed_total" -gt 0 -o "$NFT_TEST_KEEP_LOGS" = y ] ; then
        msg_info "check the temp directory \"$NFT_TEST_TMPDIR\" (\"$NFT_TEST_LATEST\")"
        msg_info "   ls -lad \"$NFT_TEST_LATEST\"/*/*"
        msg_info "   grep -R ^ \"$NFT_TEST_LATEST\"/"