From ee5e07bf494cbc26072c5aa21926b8cb4797728a Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Tue, 19 May 2020 14:55:56 -0400 Subject: [PATCH] t/zbd: improve error handling for test scripts 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 Signed-off-by: Vincent Fu --- t/zbd/run-tests-against-regular-nullb | 4 ++-- t/zbd/run-tests-against-zoned-nullb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/t/zbd/run-tests-against-regular-nullb b/t/zbd/run-tests-against-regular-nullb index 0f6e4b66..5b7b4009 100755 --- a/t/zbd/run-tests-against-regular-nullb +++ b/t/zbd/run-tests-against-regular-nullb @@ -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 diff --git a/t/zbd/run-tests-against-zoned-nullb b/t/zbd/run-tests-against-zoned-nullb index 0952011c..53aee3e8 100755 --- a/t/zbd/run-tests-against-zoned-nullb +++ b/t/zbd/run-tests-against-zoned-nullb @@ -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 -- 2.25.1