xref: /linux/tools/testing/selftests/ublk/Makefile (revision 55ab7e14222e5f0b0fd9f7711ca391d2924b35e3)
1# SPDX-License-Identifier: GPL-2.0
2
3CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir)/usr/include
4ifneq ($(WERROR),0)
5	CFLAGS += -Werror
6endif
7
8LDLIBS += -lpthread -lm -luring
9
10TEST_PROGS := test_generic_02.sh
11TEST_PROGS += test_generic_03.sh
12TEST_PROGS += test_generic_06.sh
13TEST_PROGS += test_generic_07.sh
14
15TEST_PROGS += test_generic_08.sh
16TEST_PROGS += test_generic_09.sh
17TEST_PROGS += test_generic_10.sh
18TEST_PROGS += test_generic_12.sh
19TEST_PROGS += test_generic_13.sh
20TEST_PROGS += test_generic_16.sh
21TEST_PROGS += test_generic_17.sh
22
23TEST_PROGS += test_batch_01.sh
24TEST_PROGS += test_batch_02.sh
25TEST_PROGS += test_batch_03.sh
26TEST_PROGS += test_batch_04.sh
27
28TEST_PROGS += test_null_01.sh
29TEST_PROGS += test_null_02.sh
30TEST_PROGS += test_null_03.sh
31TEST_PROGS += test_loop_01.sh
32TEST_PROGS += test_loop_02.sh
33TEST_PROGS += test_loop_03.sh
34TEST_PROGS += test_loop_04.sh
35TEST_PROGS += test_loop_05.sh
36TEST_PROGS += test_loop_06.sh
37TEST_PROGS += test_loop_07.sh
38TEST_PROGS += test_loop_08.sh
39
40TEST_PROGS += test_integrity_01.sh
41TEST_PROGS += test_integrity_02.sh
42TEST_PROGS += test_integrity_03.sh
43
44TEST_PROGS += test_recover_01.sh
45TEST_PROGS += test_recover_02.sh
46TEST_PROGS += test_recover_03.sh
47TEST_PROGS += test_recover_04.sh
48TEST_PROGS += test_stripe_01.sh
49TEST_PROGS += test_stripe_02.sh
50TEST_PROGS += test_stripe_03.sh
51TEST_PROGS += test_stripe_04.sh
52TEST_PROGS += test_stripe_05.sh
53TEST_PROGS += test_stripe_06.sh
54
55TEST_PROGS += test_part_01.sh
56TEST_PROGS += test_part_02.sh
57
58TEST_PROGS += test_params_01.sh
59
60TEST_PROGS += test_shmemzc_01.sh
61TEST_PROGS += test_shmemzc_02.sh
62TEST_PROGS += test_shmemzc_03.sh
63TEST_PROGS += test_shmemzc_04.sh
64
65TEST_PROGS += test_stress_01.sh
66TEST_PROGS += test_stress_02.sh
67TEST_PROGS += test_stress_03.sh
68TEST_PROGS += test_stress_04.sh
69TEST_PROGS += test_stress_05.sh
70TEST_PROGS += test_stress_06.sh
71TEST_PROGS += test_stress_07.sh
72TEST_PROGS += test_stress_08.sh
73TEST_PROGS += test_stress_09.sh
74
75TEST_FILES := settings
76
77TEST_GEN_PROGS_EXTENDED = kublk metadata_size
78STANDALONE_UTILS := metadata_size.c
79
80LOCAL_HDRS += $(wildcard *.h)
81include ../lib.mk
82
83$(OUTPUT)/kublk: $(filter-out $(STANDALONE_UTILS),$(wildcard *.c))
84
85check:
86	shellcheck -x -f gcc *.sh
87
88# Test groups for running subsets of tests
89# JOBS=1 (default): sequential with kselftest TAP output
90# JOBS>1: parallel execution with xargs -P
91# Usage: make run_null JOBS=4
92JOBS ?= 1
93export JOBS
94
95# Auto-detect test groups from TEST_PROGS (test_<group>_<num>.sh -> group)
96TEST_GROUPS := $(shell echo "$(TEST_PROGS)" | tr ' ' '\n' | \
97	sed 's/test_\([^_]*\)_.*/\1/' | sort -u)
98
99# Template for group test targets
100# $(1) = group name (e.g., null, generic, stress)
101define RUN_GROUP
102run_$(1): all
103	@if [ $$(JOBS) -gt 1 ]; then \
104		echo $$(filter test_$(1)_%.sh,$$(TEST_PROGS)) | tr ' ' '\n' | \
105			xargs -P $$(JOBS) -n1 sh -c './"$$$$0"' || true; \
106	else \
107		$$(call RUN_TESTS, $$(filter test_$(1)_%.sh,$$(TEST_PROGS))); \
108	fi
109.PHONY: run_$(1)
110endef
111
112# Generate targets for each discovered test group
113$(foreach group,$(TEST_GROUPS),$(eval $(call RUN_GROUP,$(group))))
114
115# Run all tests (parallel when JOBS>1)
116run_all: all
117	@if [ $(JOBS) -gt 1 ]; then \
118		echo $(TEST_PROGS) | tr ' ' '\n' | \
119			xargs -P $(JOBS) -n1 sh -c './"$$0"' || true; \
120	else \
121		$(call RUN_TESTS, $(TEST_PROGS)); \
122	fi
123.PHONY: run_all
124