t/zbd: improve error handling for test scripts
authorVincent Fu <vincent.fu@wdc.com>
Tue, 19 May 2020 18:55:56 +0000 (14:55 -0400)
committerVincent Fu <vincent.fu@wdc.com>
Wed, 20 May 2020 17:47:56 +0000 (13:47 -0400)
Use exit instead of return to abort the scripts if modprobe null_blk
fails. With return, the script continues to run after printing an error
message. Also abort if the null block device setup fails for the regular
null block device test script.

Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Vincent Fu <vincent.fu@wdc.com>
t/zbd/run-tests-against-regular-nullb
t/zbd/run-tests-against-zoned-nullb

index 0f6e4b662964ed41183dd2ab9c7ba36809f9cafc..5b7b4009bb2582b707cda3d877cb4833be8f8d2d 100755 (executable)
@@ -8,7 +8,7 @@ scriptdir="$(cd "$(dirname "$0")" && pwd)"
 
 for d in /sys/kernel/config/nullb/*; do [ -d "$d" ] && rmdir "$d"; done
 modprobe -r null_blk
-modprobe null_blk nr_devices=0 || return $?
+modprobe null_blk nr_devices=0 || exit $?
 for d in /sys/kernel/config/nullb/*; do
     [ -d "$d" ] && rmdir "$d"
 done
@@ -22,6 +22,6 @@ modprobe null_blk nr_devices=0 &&
     echo 4096 > blocksize &&
     echo 1024 > size &&
     echo 1 > memory_backed &&
-    echo 1 > power
+    echo 1 > power || exit $?
 
 "${scriptdir}"/test-zbd-support "$@" /dev/nullb0
index 0952011c576e04af1d5ffedaf4db5a58b40b36f7..53aee3e84caf9fa6c67a3a5817b18690c336d729 100755 (executable)
@@ -8,7 +8,7 @@ scriptdir="$(cd "$(dirname "$0")" && pwd)"
 
 for d in /sys/kernel/config/nullb/*; do [ -d "$d" ] && rmdir "$d"; done
 modprobe -r null_blk
-modprobe null_blk nr_devices=0 || return $?
+modprobe null_blk nr_devices=0 || exit $?
 for d in /sys/kernel/config/nullb/*; do
     [ -d "$d" ] && rmdir "$d"
 done