Message ID | 20240422133453.1793988-1-mpe@ellerman.id.au |
---|---|
State | Accepted |
Commit | 822a04957cc5e675570645f506270797a1cf2865 |
Headers | show |
Series | [v2,1/2] selftests/powerpc: Convert pmu Makefile to for loop style | expand |
On 4/22/24 7:04 PM, Michael Ellerman wrote: > The pmu Makefile has grown more sub directories over the years. Rather > than open coding the rules for each subdir, use for loops. Nice cleanup. Thanks. Tested-by: Madhavan Srinivasan <maddy@linux.ibm.com> > Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> > --- > tools/testing/selftests/powerpc/pmu/Makefile | 43 ++++++++++---------- > 1 file changed, 22 insertions(+), 21 deletions(-) > > v2: Actually send both patches. > > diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile > index 1fcacae1b188..773933e5180e 100644 > --- a/tools/testing/selftests/powerpc/pmu/Makefile > +++ b/tools/testing/selftests/powerpc/pmu/Makefile > @@ -9,7 +9,9 @@ top_srcdir = ../../../../.. > include ../../lib.mk > include ../flags.mk > > -all: $(TEST_GEN_PROGS) ebb sampling_tests event_code_tests > +SUB_DIRS := ebb sampling_tests event_code_tests > + > +all: $(TEST_GEN_PROGS) $(SUB_DIRS) > > $(TEST_GEN_PROGS): $(EXTRA_SOURCES) > > @@ -23,12 +25,16 @@ $(OUTPUT)/count_stcx_fail: loop.S $(EXTRA_SOURCES) > > $(OUTPUT)/per_event_excludes: ../utils.c > > +$(SUB_DIRS): > + BUILD_TARGET=$(OUTPUT)/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $@ all > + > DEFAULT_RUN_TESTS := $(RUN_TESTS) > override define RUN_TESTS > $(DEFAULT_RUN_TESTS) > - +TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests > - +TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests > - +TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests > + +@for TARGET in $(SUB_DIRS); do \ > + BUILD_TARGET=$(OUTPUT)/$$TARGET; \ > + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests; \ > + done; > endef > > emit_tests: > @@ -36,34 +42,29 @@ emit_tests: > BASENAME_TEST=`basename $$TEST`; \ > echo "$(COLLECTION):$$BASENAME_TEST"; \ > done > - +TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests > - +TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests > - +TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests > + +@for TARGET in $(SUB_DIRS); do \ > + BUILD_TARGET=$(OUTPUT)/$$TARGET; \ > + $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests; \ > + done; > > DEFAULT_INSTALL_RULE := $(INSTALL_RULE) > override define INSTALL_RULE > $(DEFAULT_INSTALL_RULE) > - +TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install > - +TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install > - +TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install > + +@for TARGET in $(SUB_DIRS); do \ > + BUILD_TARGET=$(OUTPUT)/$$TARGET; \ > + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install; \ > + done; > endef > > DEFAULT_CLEAN := $(CLEAN) > override define CLEAN > $(DEFAULT_CLEAN) > $(RM) $(TEST_GEN_PROGS) $(OUTPUT)/loop.o > - +TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean > - +TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean > - +TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean > + +@for TARGET in $(SUB_DIRS); do \ > + BUILD_TARGET=$(OUTPUT)/$$TARGET; \ > + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \ > + done; > endef > > -ebb: > - TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all > - > -sampling_tests: > - TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all > - > -event_code_tests: > - TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all > > .PHONY: all run_tests ebb sampling_tests event_code_tests emit_tests
On Mon, 22 Apr 2024 23:34:52 +1000, Michael Ellerman wrote: > The pmu Makefile has grown more sub directories over the years. Rather > than open coding the rules for each subdir, use for loops. > > Applied to powerpc/next. [1/2] selftests/powerpc: Convert pmu Makefile to for loop style https://git.kernel.org/powerpc/c/822a04957cc5e675570645f506270797a1cf2865 [2/2] selftests/powerpc: Install tests in sub-directories https://git.kernel.org/powerpc/c/dda32e37d397f5937cc24a6e98b71d3645f51afa cheers
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile index 1fcacae1b188..773933e5180e 100644 --- a/tools/testing/selftests/powerpc/pmu/Makefile +++ b/tools/testing/selftests/powerpc/pmu/Makefile @@ -9,7 +9,9 @@ top_srcdir = ../../../../.. include ../../lib.mk include ../flags.mk -all: $(TEST_GEN_PROGS) ebb sampling_tests event_code_tests +SUB_DIRS := ebb sampling_tests event_code_tests + +all: $(TEST_GEN_PROGS) $(SUB_DIRS) $(TEST_GEN_PROGS): $(EXTRA_SOURCES) @@ -23,12 +25,16 @@ $(OUTPUT)/count_stcx_fail: loop.S $(EXTRA_SOURCES) $(OUTPUT)/per_event_excludes: ../utils.c +$(SUB_DIRS): + BUILD_TARGET=$(OUTPUT)/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $@ all + DEFAULT_RUN_TESTS := $(RUN_TESTS) override define RUN_TESTS $(DEFAULT_RUN_TESTS) - +TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests - +TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests - +TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests + +@for TARGET in $(SUB_DIRS); do \ + BUILD_TARGET=$(OUTPUT)/$$TARGET; \ + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests; \ + done; endef emit_tests: @@ -36,34 +42,29 @@ emit_tests: BASENAME_TEST=`basename $$TEST`; \ echo "$(COLLECTION):$$BASENAME_TEST"; \ done - +TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests - +TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests - +TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests + +@for TARGET in $(SUB_DIRS); do \ + BUILD_TARGET=$(OUTPUT)/$$TARGET; \ + $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests; \ + done; DEFAULT_INSTALL_RULE := $(INSTALL_RULE) override define INSTALL_RULE $(DEFAULT_INSTALL_RULE) - +TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install - +TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install - +TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install + +@for TARGET in $(SUB_DIRS); do \ + BUILD_TARGET=$(OUTPUT)/$$TARGET; \ + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install; \ + done; endef DEFAULT_CLEAN := $(CLEAN) override define CLEAN $(DEFAULT_CLEAN) $(RM) $(TEST_GEN_PROGS) $(OUTPUT)/loop.o - +TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean - +TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean - +TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean + +@for TARGET in $(SUB_DIRS); do \ + BUILD_TARGET=$(OUTPUT)/$$TARGET; \ + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \ + done; endef -ebb: - TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all - -sampling_tests: - TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all - -event_code_tests: - TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all .PHONY: all run_tests ebb sampling_tests event_code_tests emit_tests
The pmu Makefile has grown more sub directories over the years. Rather than open coding the rules for each subdir, use for loops. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> --- tools/testing/selftests/powerpc/pmu/Makefile | 43 ++++++++++---------- 1 file changed, 22 insertions(+), 21 deletions(-) v2: Actually send both patches.