selftests: ublk: derive TID automatically from script name

Add automatic TID derivation in test_common.sh based on the script
filename. The TID is extracted by stripping the "test_" prefix and
".sh" suffix from the script name (e.g., test_loop_01.sh -> loop_01).

This removes the need for each test script to manually define TID,
reducing boilerplate and preventing potential mismatches between
the script name and TID. Scripts can still override TID after
sourcing test_common.sh if needed.

Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Ming Lei 2026-01-30 00:19:52 +08:00 committed by Jens Axboe
parent 8443e2087e
commit 3a4d8bed0b
47 changed files with 5 additions and 46 deletions

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="batch_01"
ERR_CODE=0
if ! _have_feature "BATCH_IO"; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="batch_02"
ERR_CODE=0
if ! _have_feature "BATCH_IO"; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="batch_03"
ERR_CODE=0
if ! _have_feature "BATCH_IO"; then

View File

@ -1,6 +1,11 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Derive TID from script name: test_<type>_<num>.sh -> <type>_<num>
# Can be overridden in test script after sourcing this file
TID=$(basename "$0" .sh)
TID=${TID#test_}
UBLK_SKIP_CODE=4
_have_program() {

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_01"
ERR_CODE=0
if ! _have_program bpftrace; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_02"
ERR_CODE=0
if ! _have_program bpftrace; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_03"
ERR_CODE=0
_prep_test "null" "check dma & segment limits for zero copy"

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_04"
ERR_CODE=0
ublk_run_recover_test()

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_05"
ERR_CODE=0
ublk_run_recover_test()

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_06"
ERR_CODE=0
_prep_test "fault_inject" "fast cleanup when all I/Os of one hctx are in server"

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_07"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_08"
ERR_CODE=0
if ! _have_feature "AUTO_BUF_REG"; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_09"
ERR_CODE=0
if ! _have_feature "AUTO_BUF_REG"; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_10"
ERR_CODE=0
if ! _have_feature "UPDATE_SIZE"; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_11"
ERR_CODE=0
ublk_run_quiesce_recover()

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_12"
ERR_CODE=0
if ! _have_program bpftrace; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_13"
ERR_CODE=0
_prep_test "null" "check that feature list is complete"

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_14"
ERR_CODE=0
ublk_run_recover_test()

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_15"
ERR_CODE=0
_test_partition_scan_no_hang()

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="generic_16"
ERR_CODE=0
_prep_test "null" "stop --safe command"

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="loop_01"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="loop_02"
ERR_CODE=0
_prep_test "loop" "mkfs & mount & umount"

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="loop_03"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="loop_04"
ERR_CODE=0
_prep_test "loop" "mkfs & mount & umount with zero copy"

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="loop_05"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="loop_06"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="loop_07"
ERR_CODE=0
_prep_test "loop" "mkfs & mount & umount with user copy"

View File

@ -13,7 +13,6 @@ if [[ "$fio_version" =~ fio-[0-9]+\.[0-9]+$ ]]; then
exit $UBLK_SKIP_CODE
fi
TID=loop_08
_prep_test "loop" "end-to-end integrity"

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="null_01"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="null_02"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="null_03"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID=null_04
_prep_test "null" "integrity params"

View File

@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stress_01"
ERR_CODE=0
ublk_io_and_remove()

View File

@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stress_02"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stress_03"
ERR_CODE=0
ublk_io_and_remove()

View File

@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stress_04"
ERR_CODE=0
ublk_io_and_kill_daemon()

View File

@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stress_05"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stress_06"
ERR_CODE=0
ublk_io_and_remove()

View File

@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stress_07"
ERR_CODE=0
ublk_io_and_kill_daemon()

View File

@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stress_08"
ERR_CODE=0
ublk_io_and_remove()

View File

@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-2.0
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stress_09"
ERR_CODE=0
ublk_io_and_kill_daemon()

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stripe_01"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stripe_02"
ERR_CODE=0
_prep_test "stripe" "mkfs & mount & umount"

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stripe_03"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stripe_04"
ERR_CODE=0
_prep_test "stripe" "mkfs & mount & umount on zero copy"

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stripe_05"
ERR_CODE=0
if ! _have_program fio; then

View File

@ -3,7 +3,6 @@
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
TID="stripe_06"
ERR_CODE=0
_prep_test "stripe" "mkfs & mount & umount on user copy"