Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: ublk: improve test usability

Add UBLK_TEST_QUIET, so we can print test result(PASS/SKIP/FAIL) only.

Also always run from test script's current directory, then the same test
script can be started from other work directory.

This way helps a lot to reuse this test source code and scripts for
other projects(liburing, blktests, ...)

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250303124324.3563605-12-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Ming Lei and committed by
Jens Axboe
390174c9 af83ccc7

+17 -11
+8 -2
tools/testing/selftests/ublk/test_common.sh
··· 80 80 local type=$1 81 81 shift 1 82 82 modprobe ublk_drv 83 - echo "ublk $type: $*" 83 + [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "ublk $type: $*" 84 84 } 85 85 86 86 _remove_test_files() ··· 209 209 wait 210 210 } 211 211 212 + _ublk_test_top_dir() 213 + { 214 + cd "$(dirname "$0")" && pwd 215 + } 212 216 213 - UBLK_PROG=$(pwd)/kublk 217 + UBLK_PROG=$(_ublk_test_top_dir)/kublk 218 + UBLK_TEST_QUIET=1 214 219 export UBLK_PROG 220 + export UBLK_TEST_QUIET
+1 -1
tools/testing/selftests/ublk/test_loop_01.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - . test_common.sh 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 5 6 6 TID="loop_01" 7 7 ERR_CODE=0
+1 -1
tools/testing/selftests/ublk/test_loop_02.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - . test_common.sh 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 5 6 6 TID="loop_02" 7 7 ERR_CODE=0
+1 -1
tools/testing/selftests/ublk/test_loop_03.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - . test_common.sh 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 5 6 6 TID="loop_03" 7 7 ERR_CODE=0
+1 -1
tools/testing/selftests/ublk/test_loop_04.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - . test_common.sh 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 5 6 6 TID="loop_04" 7 7 ERR_CODE=0
+1 -1
tools/testing/selftests/ublk/test_null_01.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - . test_common.sh 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 5 6 6 TID="null_01" 7 7 ERR_CODE=0
+2 -2
tools/testing/selftests/ublk/test_stress_01.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - . test_common.sh 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 5 TID="stress_01" 6 6 ERR_CODE=0 7 7 DEV_ID=-1 ··· 17 17 DEV_ID=$(_add_ublk_dev "$@") 18 18 _check_add_dev $TID $? "${backfile}" 19 19 20 - echo "run ublk IO vs. remove device(ublk add $*)" 20 + [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs. remove device(ublk add $*)" 21 21 if ! __run_io_and_remove "${DEV_ID}" "${size}" "no"; then 22 22 echo "/dev/ublkc${DEV_ID} isn't removed" 23 23 _remove_backfile "${backfile}"
+2 -2
tools/testing/selftests/ublk/test_stress_02.sh
··· 1 1 #!/bin/bash 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 - . test_common.sh 4 + . "$(cd "$(dirname "$0")" && pwd)"/test_common.sh 5 5 TID="stress_02" 6 6 ERR_CODE=0 7 7 DEV_ID=-1 ··· 17 17 DEV_ID=$(_add_ublk_dev "$@") 18 18 _check_add_dev $TID $? "${backfile}" 19 19 20 - echo "run ublk IO vs kill ublk server(ublk add $*)" 20 + [ "$UBLK_TEST_QUIET" -eq 0 ] && echo "run ublk IO vs kill ublk server(ublk add $*)" 21 21 if ! __run_io_and_remove "${DEV_ID}" "${size}" "yes"; then 22 22 echo "/dev/ublkc${DEV_ID} isn't removed res ${res}" 23 23 _remove_backfile "${backfile}"