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 105314d25aSMing 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 21320f9b1cSUday ShankarTEST_PROGS += test_generic_17.sh 228ccebc19SMing Lei 2320aeab0bSMing LeiTEST_PROGS += test_batch_01.sh 24e8cd481cSMing LeiTEST_PROGS += test_batch_02.sh 25e8cd481cSMing LeiTEST_PROGS += test_batch_03.sh 2620aeab0bSMing Lei 27723977caSMing LeiTEST_PROGS += test_null_01.sh 288cb9b971SMing LeiTEST_PROGS += test_null_02.sh 2963276182SCaleb Sander MateosTEST_PROGS += test_null_03.sh 305d95bfb5SMing LeiTEST_PROGS += test_loop_01.sh 315d95bfb5SMing LeiTEST_PROGS += test_loop_02.sh 32bedc9cbcSMing LeiTEST_PROGS += test_loop_03.sh 33bedc9cbcSMing LeiTEST_PROGS += test_loop_04.sh 348c778614SMing LeiTEST_PROGS += test_loop_05.sh 3563276182SCaleb Sander MateosTEST_PROGS += test_loop_06.sh 3663276182SCaleb Sander MateosTEST_PROGS += test_loop_07.sh 37d9a36ab3SMing Lei 38d9a36ab3SMing LeiTEST_PROGS += test_integrity_01.sh 39d9a36ab3SMing LeiTEST_PROGS += test_integrity_02.sh 40*1cdf3b28SCaleb Sander MateosTEST_PROGS += test_integrity_03.sh 41d9a36ab3SMing Lei 42d9a36ab3SMing LeiTEST_PROGS += test_recover_01.sh 43d9a36ab3SMing LeiTEST_PROGS += test_recover_02.sh 44d9a36ab3SMing LeiTEST_PROGS += test_recover_03.sh 45d9a36ab3SMing LeiTEST_PROGS += test_recover_04.sh 460f3ebf2dSMing LeiTEST_PROGS += test_stripe_01.sh 470f3ebf2dSMing LeiTEST_PROGS += test_stripe_02.sh 488c778614SMing LeiTEST_PROGS += test_stripe_03.sh 4957ed58c1SMing LeiTEST_PROGS += test_stripe_04.sh 5063276182SCaleb Sander MateosTEST_PROGS += test_stripe_05.sh 5163276182SCaleb Sander MateosTEST_PROGS += test_stripe_06.sh 526aecda00SMing Lei 53e07a2039SMing LeiTEST_PROGS += test_part_01.sh 547a30d3dfSMing LeiTEST_PROGS += test_part_02.sh 55e07a2039SMing Lei 562f1e9468SMing LeiTEST_PROGS += test_shmemzc_01.sh 57d4866503SMing LeiTEST_PROGS += test_shmemzc_02.sh 5812075992SMing LeiTEST_PROGS += test_shmemzc_03.sh 59affb5f67SMing LeiTEST_PROGS += test_shmemzc_04.sh 602f1e9468SMing Lei 61c60ac48eSMing LeiTEST_PROGS += test_stress_01.sh 62af83ccc7SMing LeiTEST_PROGS += test_stress_02.sh 63d836590dSMing LeiTEST_PROGS += test_stress_03.sh 64d836590dSMing LeiTEST_PROGS += test_stress_04.sh 652f9a30bdSMing LeiTEST_PROGS += test_stress_05.sh 6663276182SCaleb Sander MateosTEST_PROGS += test_stress_06.sh 6763276182SCaleb Sander MateosTEST_PROGS += test_stress_07.sh 6820aeab0bSMing LeiTEST_PROGS += test_stress_08.sh 6920aeab0bSMing LeiTEST_PROGS += test_stress_09.sh 70c60ac48eSMing Lei 714968fb7cSMing LeiTEST_FILES := settings 724968fb7cSMing Lei 73261b67f4SCaleb Sander MateosTEST_GEN_PROGS_EXTENDED = kublk metadata_size 74261b67f4SCaleb Sander MateosSTANDALONE_UTILS := metadata_size.c 756aecda00SMing Lei 76a2ce1339SMing LeiLOCAL_HDRS += $(wildcard *.h) 776aecda00SMing Leiinclude ../lib.mk 786aecda00SMing Lei 79261b67f4SCaleb Sander Mateos$(OUTPUT)/kublk: $(filter-out $(STANDALONE_UTILS),$(wildcard *.c)) 80632051ffSMing Lei 81632051ffSMing Leicheck: 82632051ffSMing Lei shellcheck -x -f gcc *.sh 83b6bbc3beSMing Lei 84b6bbc3beSMing Lei# Test groups for running subsets of tests 85b6bbc3beSMing Lei# JOBS=1 (default): sequential with kselftest TAP output 86b6bbc3beSMing Lei# JOBS>1: parallel execution with xargs -P 87b6bbc3beSMing Lei# Usage: make run_null JOBS=4 88b6bbc3beSMing LeiJOBS ?= 1 8964406dd2SMing Leiexport JOBS 90b6bbc3beSMing Lei 91b6bbc3beSMing Lei# Auto-detect test groups from TEST_PROGS (test_<group>_<num>.sh -> group) 92b6bbc3beSMing LeiTEST_GROUPS := $(shell echo "$(TEST_PROGS)" | tr ' ' '\n' | \ 93b6bbc3beSMing Lei sed 's/test_\([^_]*\)_.*/\1/' | sort -u) 94b6bbc3beSMing Lei 95b6bbc3beSMing Lei# Template for group test targets 96b6bbc3beSMing Lei# $(1) = group name (e.g., null, generic, stress) 97b6bbc3beSMing Leidefine RUN_GROUP 98b6bbc3beSMing Leirun_$(1): all 99b6bbc3beSMing Lei @if [ $$(JOBS) -gt 1 ]; then \ 100b6bbc3beSMing Lei echo $$(filter test_$(1)_%.sh,$$(TEST_PROGS)) | tr ' ' '\n' | \ 101b6bbc3beSMing Lei xargs -P $$(JOBS) -n1 sh -c './"$$$$0"' || true; \ 102b6bbc3beSMing Lei else \ 103b6bbc3beSMing Lei $$(call RUN_TESTS, $$(filter test_$(1)_%.sh,$$(TEST_PROGS))); \ 104b6bbc3beSMing Lei fi 105b6bbc3beSMing Lei.PHONY: run_$(1) 106b6bbc3beSMing Leiendef 107b6bbc3beSMing Lei 108b6bbc3beSMing Lei# Generate targets for each discovered test group 109b6bbc3beSMing Lei$(foreach group,$(TEST_GROUPS),$(eval $(call RUN_GROUP,$(group)))) 110b6bbc3beSMing Lei 111b6bbc3beSMing Lei# Run all tests (parallel when JOBS>1) 112b6bbc3beSMing Leirun_all: all 113b6bbc3beSMing Lei @if [ $(JOBS) -gt 1 ]; then \ 114b6bbc3beSMing Lei echo $(TEST_PROGS) | tr ' ' '\n' | \ 115b6bbc3beSMing Lei xargs -P $(JOBS) -n1 sh -c './"$$0"' || true; \ 116b6bbc3beSMing Lei else \ 117b6bbc3beSMing Lei $(call RUN_TESTS, $(TEST_PROGS)); \ 118b6bbc3beSMing Lei fi 119b6bbc3beSMing Lei.PHONY: run_all 120