t/zbd: add an option to bail on a failed test
authorDmitry Fomichev <dmitry.fomichev@wdc.com>
Wed, 27 Jan 2021 04:19:39 +0000 (13:19 +0900)
committerJens Axboe <axboe@kernel.dk>
Fri, 29 Jan 2021 15:14:01 +0000 (08:14 -0700)
Sometimes, it can be useful to inspect the state of the zones of the
test device, usually right after a test failure. Currently,
test-zbd-support script just keeps running and proper examination of
device zones can be difficult.

Add the -q option to test/zbd/support to quit immediately upon
encountering any test failure. Additionally, define the same option
in run-tests-against-nullb to propagate it to test/zbd/support.

Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Reviewed-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/zbd/run-tests-against-nullb
t/zbd/test-zbd-support

index 8771e92eeb0f471bed15136452441b62ee526f22..db901179493d242a9478e6a6af6a1a7a92b78bf5 100755 (executable)
@@ -24,6 +24,7 @@ usage()
        echo -e "\t-o <max_open_zones> Specify MaxOpen value, (${set_max_open} by default)."
        echo -e "\t-n <#number of runs> Set the number of times to run the entire suite "
        echo -e "\t   or an individual section/test."
+       echo -e "\t-q Quit t/zbd/test-zbd-support run after any failed test."
        echo -e "\t-r Remove the /dev/nullb0 device that may still exist after"
        echo -e "\t   running this script."
        exit 1
@@ -241,6 +242,7 @@ zbd_test_opts=()
 libzbc=0
 num_of_runs=1
 test_case=0
+quit_on_err=0
 
 while (($#)); do
        case "$1" in
@@ -251,6 +253,7 @@ while (($#)); do
                -l) libzbc=1; shift;;
                -n) num_of_runs="${2}"; shift; shift;;
                -t) test_case="${2}"; shift; shift;;
+               -q) quit_on_err=1; shift;;
                -h) usage; break;;
                --) shift; break;;
                 *) usage; exit 1;;
@@ -296,6 +299,9 @@ while ((run_nr <= $num_of_runs)); do
                if ((test_case)); then
                        zbd_test_opts+=("-t" "${test_case}")
                fi
+               if ((quit_on_err)); then
+                       zbd_test_opts+=("-q")
+               fi
                section$section_number
                configure_nullb
                rc=$?
@@ -330,9 +336,13 @@ while ((run_nr <= $num_of_runs)); do
                        exit 1
                fi
                ((intr)) && exit 1
-               (($test_rc)) && rc=1
+               if (($test_rc)); then
+                       rc=1
+                       ((quit_on_err)) && break
+               fi
        done
 
+       ((rc && quit_on_err)) && break
        run_nr=$((run_nr + 1))
 done
 
index 4d8e905d069faaef4096bd1a4f3966eaba19997f..93456ec63e1b59bce6c2a0d613ab43910da0897a 100755 (executable)
@@ -14,6 +14,7 @@ usage() {
        echo -e "\t-r Reset all zones before test start"
        echo -e "\t-o <max_open_zones> Run fio with max_open_zones limit"
        echo -e "\t-t <test #> Run only a single test case with specified number"
+       echo -e "\t-q Quit the test run after any failed test"
        echo -e "\t-z Run fio with debug=zbd option"
 }
 
@@ -1113,6 +1114,7 @@ reset_all_zones=
 use_libzbc=
 zbd_debug=
 max_open_zones_opt=
+quit_on_err=
 
 while [ "${1#-}" != "$1" ]; do
   case "$1" in
@@ -1127,6 +1129,7 @@ while [ "${1#-}" != "$1" ]; do
     -o) max_open_zones_opt="${2}"; shift; shift;;
     -v) dynamic_analyzer=(valgrind "--read-var-info=yes");
        shift;;
+    -q) quit_on_err=1; shift;;
     -z) zbd_debug=1; shift;;
     --) shift; break;;
   esac
@@ -1288,6 +1291,7 @@ for test_number in "${tests[@]}"; do
     echo -e "$cc_status"
     echo "$status" >> "${logfile}.${test_number}"
     [ $intr -ne 0 ] && exit 1
+    [ -n "$quit_on_err" -a "$rc" -ne 0 ] && exit 1
 done
 
 echo "$passed tests passed"