]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/shell: print number of completed tests to show progress
authorThomas Haller <thaller@redhat.com>
Fri, 8 Sep 2023 14:26:02 +0000 (16:26 +0200)
committerFlorian Westphal <fw@strlen.de>
Sat, 9 Sep 2023 14:35:12 +0000 (16:35 +0200)
Especially with VALGRIND=y, a full test run can take a long time. When
looking at the output, it's interesting to get a feel how far along we
are.

Print the number of completed jobs vs. the number of total jobs, in the
line showing the test result. It gives a nice progress status.

Example:

    I: [OK]           1/373 ./tests/shell/testcases/bitwise/0040mark_binop_1
    I: [OK]           2/373 ./tests/shell/testcases/bitwise/0040mark_binop_0
    ...

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
tests/shell/run-tests.sh

index 5931b20e164500638da6a145fdc3e4d61415506f..d57108c054d1249a2298e1af42f8d3d7fcfb9ac3 100755 (executable)
@@ -511,19 +511,24 @@ fi
 print_test_header() {
        local msglevel="$1"
        local testfile="$2"
-       local status="$3"
-       local suffix="$4"
+       local testidx_completed="$3"
+       local status="$4"
+       local suffix="$5"
        local text
+       local s_idx
+
+       s_idx="${#TESTS[@]}"
+       align_text text right "${#s_idx}" "$testidx_completed"
+       s_idx="$text/${#TESTS[@]}"
 
        align_text text left 12 "[$status]"
-       _msg "$msglevel" "$text $testfile${suffix:+: $suffix}"
+       _msg "$msglevel" "$text $s_idx $testfile${suffix:+: $suffix}"
 }
 
 print_test_result() {
        local NFT_TEST_TESTTMPDIR="$1"
        local testfile="$2"
        local rc_got="$3"
-       shift 3
 
        local result_msg_level="I"
        local result_msg_suffix=""
@@ -553,7 +558,7 @@ print_test_result() {
                result_msg_files=( "$NFT_TEST_TESTTMPDIR/testout.log" )
        fi
 
-       print_test_header "$result_msg_level" "$testfile" "$result_msg_status" "$result_msg_suffix"
+       print_test_header "$result_msg_level" "$testfile" "$((ok + skipped + failed))" "$result_msg_status" "$result_msg_suffix"
 
        if [ "$VERBOSE" = "y" ] ; then
                local f
@@ -575,9 +580,10 @@ declare -A JOBS_PIDLIST
 
 job_start() {
        local testfile="$1"
+       local testidx="$2"
 
        if [ "$NFT_TEST_JOBS" -le 1 ] ; then
-               print_test_header I "$testfile" "EXECUTING" ""
+               print_test_header I "$testfile" "$testidx" "EXECUTING" ""
        fi
 
        NFT_TEST_TESTTMPDIR="${JOBS_TEMPDIR["$testfile"]}" \
@@ -619,7 +625,7 @@ for testfile in "${TESTS[@]}" ; do
        chmod 755 "$NFT_TEST_TESTTMPDIR"
        JOBS_TEMPDIR["$testfile"]="$NFT_TEST_TESTTMPDIR"
 
-       job_start "$testfile" &
+       job_start "$testfile" "$TESTIDX" &
        JOBS_PIDLIST[$!]="$testfile"
        ((JOBS_N_RUNNING++))
 done