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