summaryrefslogtreecommitdiff
path: root/tools/testing
diff options
context:
space:
mode:
authorMing Lei <ming.lei@redhat.com>2026-02-01 00:23:35 +0800
committerJens Axboe <axboe@kernel.dk>2026-01-31 14:56:28 -0700
commit2021e6109de3e97adfce262c40a657ff206ef495 (patch)
tree060fe97932f7f3bb851a8de7027f717b9d442758 /tools/testing
parent92734a4f3a7a5449b0c7d0160ba658a2b665c31b (diff)
selftests: ublk: track created devices for per-test cleanup
Track device IDs in UBLK_DEVS array when created. Update _cleanup_test() to only delete devices created by this test instead of using 'del -a' which removes all devices. This prepares for running tests concurrently where each test should only clean up its own devices. Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'tools/testing')
-rwxr-xr-xtools/testing/selftests/ublk/test_common.sh13
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/testing/selftests/ublk/test_common.sh b/tools/testing/selftests/ublk/test_common.sh
index 0f1fdb0892b4..422882c32490 100755
--- a/tools/testing/selftests/ublk/test_common.sh
+++ b/tools/testing/selftests/ublk/test_common.sh
@@ -164,7 +164,12 @@ _check_add_dev()
}
_cleanup_test() {
- "${UBLK_PROG}" del -a
+ if [ -f "${UBLK_TEST_DIR}/.ublk_devs" ]; then
+ while read -r dev_id; do
+ ${UBLK_PROG} del -n "${dev_id}"
+ done < "${UBLK_TEST_DIR}/.ublk_devs"
+ rm -f "${UBLK_TEST_DIR}/.ublk_devs"
+ fi
_remove_files
rmdir ${UBLK_TEST_DIR}
@@ -205,6 +210,7 @@ _create_ublk_dev() {
fi
if [[ "$dev_id" =~ ^[0-9]+$ ]]; then
+ echo "$dev_id" >> "${UBLK_TEST_DIR}/.ublk_devs"
echo "${dev_id}"
else
return 255
@@ -276,6 +282,11 @@ _ublk_del_dev() {
local dev_id=$1
${UBLK_PROG} del -n "${dev_id}"
+
+ # Remove from tracking file
+ if [ -f "${UBLK_TEST_DIR}/.ublk_devs" ]; then
+ sed -i "/^${dev_id}$/d" "${UBLK_TEST_DIR}/.ublk_devs"
+ fi
}
__remove_ublk_dev_return() {