Makefile 2.9 KB

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