t/zbd: make the test script easier to terminate master
authorDmitry Fomichev <dmitry.fomichev@wdc.com>
Mon, 25 May 2020 21:32:56 +0000 (06:32 +0900)
committerJens Axboe <axboe@kernel.dk>
Tue, 26 May 2020 00:21:45 +0000 (18:21 -0600)
Very often, it takes more than one ^C to terminate test-zbd-support
script. Just a single ^C does end the test that is currently being
executed, but then the script proceeds to the next test. This commit
adds a simple signal handler to exit the test loop after receiving
a Ctrl-C.

Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/zbd/test-zbd-support

index 51b05df..4001be3 100755 (executable)
@@ -940,6 +940,9 @@ else
 fi
 rc=0
 
+intr=0
+trap 'intr=1' SIGINT
+
 for test_number in "${tests[@]}"; do
     rm -f "${logfile}.${test_number}"
     echo -n "Running test $(printf "%02d" $test_number) ... "
@@ -955,6 +958,7 @@ for test_number in "${tests[@]}"; do
     fi
     echo -e "$cc_status"
     echo "$status" >> "${logfile}.${test_number}"
+    [ $intr -ne 0 ] && exit 1
 done
 
 echo "$passed tests passed"