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 26d507d3cbSYang XiuweiTEST_PROGS += test_batch_04.sh 2720aeab0bSMing Lei 28723977caSMing LeiTEST_PROGS += test_null_01.sh 298cb9b971SMing LeiTEST_PROGS += test_null_02.sh 3063276182SCaleb Sander MateosTEST_PROGS += test_null_03.sh 315d95bfb5SMing LeiTEST_PROGS += test_loop_01.sh 325d95bfb5SMing LeiTEST_PROGS += test_loop_02.sh 33bedc9cbcSMing LeiTEST_PROGS += test_loop_03.sh 34bedc9cbcSMing LeiTEST_PROGS += test_loop_04.sh 358c778614SMing LeiTEST_PROGS += test_loop_05.sh 3663276182SCaleb Sander MateosTEST_PROGS += test_loop_06.sh 3763276182SCaleb Sander MateosTEST_PROGS += test_loop_07.sh 38d61d0f95SCaleb Sander MateosTEST_PROGS += test_loop_08.sh 39d9a36ab3SMing Lei 40d9a36ab3SMing LeiTEST_PROGS += test_integrity_01.sh 41d9a36ab3SMing LeiTEST_PROGS += test_integrity_02.sh 421cdf3b28SCaleb Sander MateosTEST_PROGS += test_integrity_03.sh 43d9a36ab3SMing Lei 44d9a36ab3SMing LeiTEST_PROGS += test_recover_01.sh 45d9a36ab3SMing LeiTEST_PROGS += test_recover_02.sh 46d9a36ab3SMing LeiTEST_PROGS += test_recover_03.sh 47d9a36ab3SMing LeiTEST_PROGS += test_recover_04.sh 480f3ebf2dSMing LeiTEST_PROGS += test_stripe_01.sh 490f3ebf2dSMing LeiTEST_PROGS += test_stripe_02.sh 508c778614SMing LeiTEST_PROGS += test_stripe_03.sh 5157ed58c1SMing LeiTEST_PROGS += test_stripe_04.sh 5263276182SCaleb Sander MateosTEST_PROGS += test_stripe_05.sh 5363276182SCaleb Sander MateosTEST_PROGS += test_stripe_06.sh 546aecda00SMing Lei 55e07a2039SMing LeiTEST_PROGS += test_part_01.sh 567a30d3dfSMing LeiTEST_PROGS += test_part_02.sh 57e07a2039SMing Lei 58007af5e5SYao SangTEST_PROGS += test_params_01.sh 59007af5e5SYao Sang 602f1e9468SMing LeiTEST_PROGS += test_shmemzc_01.sh 61d4866503SMing LeiTEST_PROGS += test_shmemzc_02.sh 6212075992SMing LeiTEST_PROGS += test_shmemzc_03.sh 63affb5f67SMing LeiTEST_PROGS += test_shmemzc_04.sh 642f1e9468SMing Lei 65c60ac48eSMing LeiTEST_PROGS += test_stress_01.sh 66af83ccc7SMing LeiTEST_PROGS += test_stress_02.sh 67d836590dSMing LeiTEST_PROGS += test_stress_03.sh 68d836590dSMing LeiTEST_PROGS += test_stress_04.sh 692f9a30bdSMing LeiTEST_PROGS += test_stress_05.sh 7063276182SCaleb Sander MateosTEST_PROGS += test_stress_06.sh 7163276182SCaleb Sander MateosTEST_PROGS += test_stress_07.sh 7220aeab0bSMing LeiTEST_PROGS += test_stress_08.sh 7320aeab0bSMing LeiTEST_PROGS += test_stress_09.sh 74c60ac48eSMing Lei 754968fb7cSMing LeiTEST_FILES := settings 76*c4fa55f8SMahmoud Nagy AdamTEST_FILES += test_common.sh 77*c4fa55f8SMahmoud Nagy AdamTEST_FILES += trace 784968fb7cSMing Lei 79261b67f4SCaleb Sander MateosTEST_GEN_PROGS_EXTENDED = kublk metadata_size 80261b67f4SCaleb Sander MateosSTANDALONE_UTILS := metadata_size.c 816aecda00SMing Lei 82a2ce1339SMing LeiLOCAL_HDRS += $(wildcard *.h) 836aecda00SMing Leiinclude ../lib.mk 846aecda00SMing Lei 85261b67f4SCaleb Sander Mateos$(OUTPUT)/kublk: $(filter-out $(STANDALONE_UTILS),$(wildcard *.c)) 86632051ffSMing Lei 87632051ffSMing Leicheck: 88632051ffSMing Lei shellcheck -x -f gcc *.sh 89b6bbc3beSMing Lei 90b6bbc3beSMing Lei# Test groups for running subsets of tests 91b6bbc3beSMing Lei# JOBS=1 (default): sequential with kselftest TAP output 92b6bbc3beSMing Lei# JOBS>1: parallel execution with xargs -P 93b6bbc3beSMing Lei# Usage: make run_null JOBS=4 94b6bbc3beSMing LeiJOBS ?= 1 9564406dd2SMing Leiexport JOBS 96b6bbc3beSMing Lei 97b6bbc3beSMing Lei# Auto-detect test groups from TEST_PROGS (test_<group>_<num>.sh -> group) 98b6bbc3beSMing LeiTEST_GROUPS := $(shell echo "$(TEST_PROGS)" | tr ' ' '\n' | \ 99b6bbc3beSMing Lei sed 's/test_\([^_]*\)_.*/\1/' | sort -u) 100b6bbc3beSMing Lei 101b6bbc3beSMing Lei# Template for group test targets 102b6bbc3beSMing Lei# $(1) = group name (e.g., null, generic, stress) 103b6bbc3beSMing Leidefine RUN_GROUP 104b6bbc3beSMing Leirun_$(1): all 105b6bbc3beSMing Lei @if [ $$(JOBS) -gt 1 ]; then \ 106b6bbc3beSMing Lei echo $$(filter test_$(1)_%.sh,$$(TEST_PROGS)) | tr ' ' '\n' | \ 107b6bbc3beSMing Lei xargs -P $$(JOBS) -n1 sh -c './"$$$$0"' || true; \ 108b6bbc3beSMing Lei else \ 109b6bbc3beSMing Lei $$(call RUN_TESTS, $$(filter test_$(1)_%.sh,$$(TEST_PROGS))); \ 110b6bbc3beSMing Lei fi 111b6bbc3beSMing Lei.PHONY: run_$(1) 112b6bbc3beSMing Leiendef 113b6bbc3beSMing Lei 114b6bbc3beSMing Lei# Generate targets for each discovered test group 115b6bbc3beSMing Lei$(foreach group,$(TEST_GROUPS),$(eval $(call RUN_GROUP,$(group)))) 116b6bbc3beSMing Lei 117b6bbc3beSMing Lei# Run all tests (parallel when JOBS>1) 118b6bbc3beSMing Leirun_all: all 119b6bbc3beSMing Lei @if [ $(JOBS) -gt 1 ]; then \ 120b6bbc3beSMing Lei echo $(TEST_PROGS) | tr ' ' '\n' | \ 121b6bbc3beSMing Lei xargs -P $(JOBS) -n1 sh -c './"$$0"' || true; \ 122b6bbc3beSMing Lei else \ 123b6bbc3beSMing Lei $(call RUN_TESTS, $(TEST_PROGS)); \ 124b6bbc3beSMing Lei fi 125b6bbc3beSMing Lei.PHONY: run_all 126