From 3618665d1ffd7ec57074f244d27309da9d6dc2cc Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Tue, 16 Apr 2024 16:22:12 +0800 Subject: [PATCH] block/033: fix the output when ublk prog not avaiable UBLK_PROG was not defined when calling _have_ublk, move the defination to common/ublk. Replace ublk_prog with UBLK_PROG in block/033. common/fio already included in common/rc, so remove the dup inclusion. $ ./check block/033 block/033 (add & delete ublk device and test if gendisk is leaked) [not run] driver ublk_drv is not available is not available Signed-off-by: Yi Zhang --- common/ublk | 6 ++++++ tests/block/033 | 8 ++++---- tests/ublk/rc | 7 ------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/common/ublk b/common/ublk index c4d1e340..c065db21 100644 --- a/common/ublk +++ b/common/ublk @@ -40,3 +40,9 @@ _exit_ublk() { udevadm settle modprobe -r -q ublk_drv } + +if which rublk > /dev/null 2>&1; then + export UBLK_PROG="src/rublk_wrapper.sh" +else + export UBLK_PROG="src/miniublk" +fi diff --git a/tests/block/033 b/tests/block/033 index 762f606b..510e1c56 100755 --- a/tests/block/033 +++ b/tests/block/033 @@ -17,7 +17,7 @@ requires() { } test() { - local ublk_prog="src/miniublk" + local UBLK_PROG="src/miniublk" echo "Running ${TEST_NAME}" @@ -25,15 +25,15 @@ test() { return 1 fi - ${ublk_prog} add -t null -n 0 > "$FULL" + ${UBLK_PROG} add -t null -n 0 > "$FULL" udevadm settle - if ! ${ublk_prog} list -n 0 >> "$FULL"; then + if ! ${UBLK_PROG} list -n 0 >> "$FULL"; then echo "fail to list dev" fi if ! dd if=/dev/ublkb0 iflag=direct of=/dev/null bs=1M count=512 >> "$FULL" 2>&1; then echo "fail io" fi - ${ublk_prog} del -n 0 >> "$FULL" + ${UBLK_PROG} del -n 0 >> "$FULL" _exit_ublk diff --git a/tests/ublk/rc b/tests/ublk/rc index 5fbf8613..530b0977 100644 --- a/tests/ublk/rc +++ b/tests/ublk/rc @@ -6,16 +6,9 @@ . common/rc . common/ublk -. common/fio group_requires() { _have_root _have_ublk _have_fio } - -if which rublk > /dev/null 2>&1; then - export UBLK_PROG="src/rublk_wrapper.sh" -else - export UBLK_PROG="src/miniublk" -fi