]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: ublk: add _ublk_sleep helper for parallel execution
authorMing Lei <ming.lei@redhat.com>
Sat, 31 Jan 2026 16:23:37 +0000 (00:23 +0800)
committerJens Axboe <axboe@kernel.dk>
Sat, 31 Jan 2026 21:56:28 +0000 (14:56 -0700)
Add _ublk_sleep() helper function that uses different sleep times
depending on whether tests run in parallel or sequential mode.

Usage: _ublk_sleep <normal_secs> <parallel_secs>

Export JOBS variable from Makefile so test scripts can detect parallel
execution, and use _ublk_sleep in test_part_02.sh to handle the
partition scan delay (1s normal, 5s parallel).

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
tools/testing/selftests/ublk/Makefile
tools/testing/selftests/ublk/test_common.sh
tools/testing/selftests/ublk/test_part_02.sh

index 37e012d3a8a78cea75b11c5a8163d81f24196b34..1ceae611acb721b40b0c8eb067b471559ccf6742 100644 (file)
@@ -78,6 +78,7 @@ check:
 # JOBS>1: parallel execution with xargs -P
 # Usage: make run_null JOBS=4
 JOBS ?= 1
+export JOBS
 
 # Auto-detect test groups from TEST_PROGS (test_<group>_<num>.sh -> group)
 TEST_GROUPS := $(shell echo "$(TEST_PROGS)" | tr ' ' '\n' | \
index 422882c324901b6338e5fb6dd499fd43016d0c7d..bd27a6875c1aeadfbd54ef3cb26d7b0f7dacdc78 100755 (executable)
@@ -15,6 +15,16 @@ _have_program() {
        return 1
 }
 
+# Sleep with awareness of parallel execution.
+# Usage: _ublk_sleep <normal_secs> <parallel_secs>
+_ublk_sleep() {
+       if [ "${JOBS:-1}" -gt 1 ]; then
+               sleep "$2"
+       else
+               sleep "$1"
+       fi
+}
+
 _get_disk_dev_t() {
        local dev_id=$1
        local dev
index acd098deda3a9d6ff77ecb684b00ed9e60652d39..7d42ab4d6e838393e4e190f887e78499bc83accb 100755 (executable)
@@ -33,7 +33,7 @@ _test_partition_scan_no_hang()
        # The add command should return quickly because partition scan is async.
        # Now sleep briefly to let the async partition scan work start and hit
        # the delay in the fault_inject handler.
-       sleep 1
+       _ublk_sleep 1 5
 
        # Kill the ublk daemon while partition scan is potentially blocked
        # And check state transitions properly