From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Cc: Caleb Sander Mateos <csander@purestorage.com>,
Uday Shankar <ushankar@purestorage.com>,
Alexander Atanasov <alex@zazolabs.com>,
linux-kselftest@vger.kernel.org, Shuah Khan <shuah@kernel.org>,
Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 5/9] selftests: ublk: add group-based test targets
Date: Sun, 1 Feb 2026 00:23:36 +0800 [thread overview]
Message-ID: <20260131162342.13872-6-ming.lei@redhat.com> (raw)
In-Reply-To: <20260131162342.13872-1-ming.lei@redhat.com>
Add convenient Makefile targets for running specific test groups:
- run_generic, run_batch, run_null, run_loop, run_stripe, run_stress, etc.
- run_all for running all tests
Test groups are auto-detected from TEST_PROGS using pattern matching
(test_<group>_<num>.sh -> group), and targets are generated dynamically
using define/eval templates.
Supports parallel execution via JOBS variable:
- JOBS=1 (default): sequential with kselftest TAP output
- JOBS>1: parallel execution with xargs -P
Usage examples:
make run_null # Sequential execution
make run_stress JOBS=4 # Parallel with 4 jobs
make run_all JOBS=8 # Run all tests with 8 parallel jobs
With JOBS=8, running time of `make run_all` is reduced to 2m2s from 6m5s
in my test VM.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
tools/testing/selftests/ublk/Makefile | 36 +++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile
index ca8588ed962c..37e012d3a8a7 100644
--- a/tools/testing/selftests/ublk/Makefile
+++ b/tools/testing/selftests/ublk/Makefile
@@ -72,3 +72,39 @@ $(OUTPUT)/kublk: $(filter-out $(STANDALONE_UTILS),$(wildcard *.c))
check:
shellcheck -x -f gcc *.sh
+
+# Test groups for running subsets of tests
+# JOBS=1 (default): sequential with kselftest TAP output
+# JOBS>1: parallel execution with xargs -P
+# Usage: make run_null JOBS=4
+JOBS ?= 1
+
+# Auto-detect test groups from TEST_PROGS (test_<group>_<num>.sh -> group)
+TEST_GROUPS := $(shell echo "$(TEST_PROGS)" | tr ' ' '\n' | \
+ sed 's/test_\([^_]*\)_.*/\1/' | sort -u)
+
+# Template for group test targets
+# $(1) = group name (e.g., null, generic, stress)
+define RUN_GROUP
+run_$(1): all
+ @if [ $$(JOBS) -gt 1 ]; then \
+ echo $$(filter test_$(1)_%.sh,$$(TEST_PROGS)) | tr ' ' '\n' | \
+ xargs -P $$(JOBS) -n1 sh -c './"$$$$0"' || true; \
+ else \
+ $$(call RUN_TESTS, $$(filter test_$(1)_%.sh,$$(TEST_PROGS))); \
+ fi
+.PHONY: run_$(1)
+endef
+
+# Generate targets for each discovered test group
+$(foreach group,$(TEST_GROUPS),$(eval $(call RUN_GROUP,$(group))))
+
+# Run all tests (parallel when JOBS>1)
+run_all: all
+ @if [ $(JOBS) -gt 1 ]; then \
+ echo $(TEST_PROGS) | tr ' ' '\n' | \
+ xargs -P $(JOBS) -n1 sh -c './"$$0"' || true; \
+ else \
+ $(call RUN_TESTS, $(TEST_PROGS)); \
+ fi
+.PHONY: run_all
--
2.47.0
next prev parent reply other threads:[~2026-01-31 16:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-31 16:23 [PATCH 0/9] selftests: ublk: test infrastructure improvements Ming Lei
2026-01-31 16:23 ` [PATCH 1/9] selftests: ublk: simplify UBLK_TEST_DIR handling Ming Lei
2026-01-31 16:23 ` [PATCH 2/9] selftests: ublk: refactor test_loop_08 into separate functions Ming Lei
2026-01-31 16:23 ` [PATCH 3/9] selftests: ublk: add _ublk_del_dev helper function Ming Lei
2026-01-31 16:23 ` [PATCH 4/9] selftests: ublk: track created devices for per-test cleanup Ming Lei
2026-01-31 16:23 ` Ming Lei [this message]
2026-01-31 16:23 ` [PATCH 6/9] selftests: ublk: add _ublk_sleep helper for parallel execution Ming Lei
2026-01-31 16:23 ` [PATCH 7/9] selftests: ublk: increase timeouts for parallel test execution Ming Lei
2026-01-31 16:23 ` [PATCH 8/9] selftests: ublk: reorganize tests into integrity and recover groups Ming Lei
2026-01-31 16:23 ` [PATCH 9/9] selftests: ublk: improve I/O ordering test with bpftrace Ming Lei
2026-01-31 21:56 ` [PATCH 0/9] selftests: ublk: test infrastructure improvements Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260131162342.13872-6-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=alex@zazolabs.com \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=ushankar@purestorage.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox