Debian Codegraph @

tools/testing/selftests/ublk/Makefile

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