xref: /linux/tools/testing/selftests/ublk/Makefile (revision 5314d25afbc44d0449fa2519d2c9d7f3c319f74c)
16aecda00SMing Lei# SPDX-License-Identifier: GPL-2.0
26aecda00SMing Lei
3e371b9d3SUday ShankarCFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir)/usr/include
43d6ee575SUday Shankarifneq ($(WERROR),0)
53d6ee575SUday Shankar	CFLAGS += -Werror
63d6ee575SUday Shankarendif
73d6ee575SUday Shankar
86aecda00SMing LeiLDLIBS += -lpthread -lm -luring
96aecda00SMing Lei
10*5314d25aSMing LeiTEST_PROGS := test_generic_02.sh
11c78ae7b7SMing LeiTEST_PROGS += test_generic_03.sh
1281586652SUday ShankarTEST_PROGS += test_generic_06.sh
13730d8379SMing LeiTEST_PROGS += test_generic_07.sh
14723977caSMing Lei
158ccebc19SMing LeiTEST_PROGS += test_generic_08.sh
166f1a182aSMing LeiTEST_PROGS += test_generic_09.sh
17f40b1f26SMing LeiTEST_PROGS += test_generic_10.sh
18236918d3SUday ShankarTEST_PROGS += test_generic_12.sh
19a755da0dSUday ShankarTEST_PROGS += test_generic_13.sh
2065955a09SMing LeiTEST_PROGS += test_generic_16.sh
218ccebc19SMing Lei
2220aeab0bSMing LeiTEST_PROGS += test_batch_01.sh
23e8cd481cSMing LeiTEST_PROGS += test_batch_02.sh
24e8cd481cSMing LeiTEST_PROGS += test_batch_03.sh
2520aeab0bSMing Lei
26723977caSMing LeiTEST_PROGS += test_null_01.sh
278cb9b971SMing LeiTEST_PROGS += test_null_02.sh
2863276182SCaleb Sander MateosTEST_PROGS += test_null_03.sh
295d95bfb5SMing LeiTEST_PROGS += test_loop_01.sh
305d95bfb5SMing LeiTEST_PROGS += test_loop_02.sh
31bedc9cbcSMing LeiTEST_PROGS += test_loop_03.sh
32bedc9cbcSMing LeiTEST_PROGS += test_loop_04.sh
338c778614SMing LeiTEST_PROGS += test_loop_05.sh
3463276182SCaleb Sander MateosTEST_PROGS += test_loop_06.sh
3563276182SCaleb Sander MateosTEST_PROGS += test_loop_07.sh
36d9a36ab3SMing Lei
37d9a36ab3SMing LeiTEST_PROGS += test_integrity_01.sh
38d9a36ab3SMing LeiTEST_PROGS += test_integrity_02.sh
39d9a36ab3SMing Lei
40d9a36ab3SMing LeiTEST_PROGS += test_recover_01.sh
41d9a36ab3SMing LeiTEST_PROGS += test_recover_02.sh
42d9a36ab3SMing LeiTEST_PROGS += test_recover_03.sh
43d9a36ab3SMing LeiTEST_PROGS += test_recover_04.sh
440f3ebf2dSMing LeiTEST_PROGS += test_stripe_01.sh
450f3ebf2dSMing LeiTEST_PROGS += test_stripe_02.sh
468c778614SMing LeiTEST_PROGS += test_stripe_03.sh
4757ed58c1SMing LeiTEST_PROGS += test_stripe_04.sh
4863276182SCaleb Sander MateosTEST_PROGS += test_stripe_05.sh
4963276182SCaleb Sander MateosTEST_PROGS += test_stripe_06.sh
506aecda00SMing Lei
51e07a2039SMing LeiTEST_PROGS += test_part_01.sh
527a30d3dfSMing LeiTEST_PROGS += test_part_02.sh
53e07a2039SMing Lei
54c60ac48eSMing LeiTEST_PROGS += test_stress_01.sh
55af83ccc7SMing LeiTEST_PROGS += test_stress_02.sh
56d836590dSMing LeiTEST_PROGS += test_stress_03.sh
57d836590dSMing LeiTEST_PROGS += test_stress_04.sh
582f9a30bdSMing LeiTEST_PROGS += test_stress_05.sh
5963276182SCaleb Sander MateosTEST_PROGS += test_stress_06.sh
6063276182SCaleb Sander MateosTEST_PROGS += test_stress_07.sh
6120aeab0bSMing LeiTEST_PROGS += test_stress_08.sh
6220aeab0bSMing LeiTEST_PROGS += test_stress_09.sh
63c60ac48eSMing Lei
644968fb7cSMing LeiTEST_FILES := settings
654968fb7cSMing Lei
66261b67f4SCaleb Sander MateosTEST_GEN_PROGS_EXTENDED = kublk metadata_size
67261b67f4SCaleb Sander MateosSTANDALONE_UTILS := metadata_size.c
686aecda00SMing Lei
69a2ce1339SMing LeiLOCAL_HDRS += $(wildcard *.h)
706aecda00SMing Leiinclude ../lib.mk
716aecda00SMing Lei
72261b67f4SCaleb Sander Mateos$(OUTPUT)/kublk: $(filter-out $(STANDALONE_UTILS),$(wildcard *.c))
73632051ffSMing Lei
74632051ffSMing Leicheck:
75632051ffSMing Lei	shellcheck -x -f gcc *.sh
76b6bbc3beSMing Lei
77b6bbc3beSMing Lei# Test groups for running subsets of tests
78b6bbc3beSMing Lei# JOBS=1 (default): sequential with kselftest TAP output
79b6bbc3beSMing Lei# JOBS>1: parallel execution with xargs -P
80b6bbc3beSMing Lei# Usage: make run_null JOBS=4
81b6bbc3beSMing LeiJOBS ?= 1
8264406dd2SMing Leiexport JOBS
83b6bbc3beSMing Lei
84b6bbc3beSMing Lei# Auto-detect test groups from TEST_PROGS (test_<group>_<num>.sh -> group)
85b6bbc3beSMing LeiTEST_GROUPS := $(shell echo "$(TEST_PROGS)" | tr ' ' '\n' | \
86b6bbc3beSMing Lei	sed 's/test_\([^_]*\)_.*/\1/' | sort -u)
87b6bbc3beSMing Lei
88b6bbc3beSMing Lei# Template for group test targets
89b6bbc3beSMing Lei# $(1) = group name (e.g., null, generic, stress)
90b6bbc3beSMing Leidefine RUN_GROUP
91b6bbc3beSMing Leirun_$(1): all
92b6bbc3beSMing Lei	@if [ $$(JOBS) -gt 1 ]; then \
93b6bbc3beSMing Lei		echo $$(filter test_$(1)_%.sh,$$(TEST_PROGS)) | tr ' ' '\n' | \
94b6bbc3beSMing Lei			xargs -P $$(JOBS) -n1 sh -c './"$$$$0"' || true; \
95b6bbc3beSMing Lei	else \
96b6bbc3beSMing Lei		$$(call RUN_TESTS, $$(filter test_$(1)_%.sh,$$(TEST_PROGS))); \
97b6bbc3beSMing Lei	fi
98b6bbc3beSMing Lei.PHONY: run_$(1)
99b6bbc3beSMing Leiendef
100b6bbc3beSMing Lei
101b6bbc3beSMing Lei# Generate targets for each discovered test group
102b6bbc3beSMing Lei$(foreach group,$(TEST_GROUPS),$(eval $(call RUN_GROUP,$(group))))
103b6bbc3beSMing Lei
104b6bbc3beSMing Lei# Run all tests (parallel when JOBS>1)
105b6bbc3beSMing Leirun_all: all
106b6bbc3beSMing Lei	@if [ $(JOBS) -gt 1 ]; then \
107b6bbc3beSMing Lei		echo $(TEST_PROGS) | tr ' ' '\n' | \
108b6bbc3beSMing Lei			xargs -P $(JOBS) -n1 sh -c './"$$0"' || true; \
109b6bbc3beSMing Lei	else \
110b6bbc3beSMing Lei		$(call RUN_TESTS, $(TEST_PROGS)); \
111b6bbc3beSMing Lei	fi
112b6bbc3beSMing Lei.PHONY: run_all
113