PLUGINS=$(filter-out $(DISABLE_PLUGINS), \
$(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c))))
+strip-plugin = $(wordlist 1, 1, $(subst -with-, ,$1))
+extract-plugin = $(wordlist 2, 2, $(subst -with-, ,$1))
+extract-test = $(subst run-plugin-,,$(wordlist 1, 1, $(subst -with-, ,$1)))
+
# We need to ensure expand the run-plugin-TEST-with-PLUGIN
# pre-requistes manually here as we can't use stems to handle it. We
# only expand MULTIARCH_TESTS which are common on most of our targets
ifneq ($(MULTIARCH_TESTS),)
+# Extract extra tests from the extra test+plugin combination.
+EXTRA_TESTS_WITH_PLUGIN=$(foreach test, \
+ $(EXTRA_RUNS_WITH_PLUGIN),$(call extract-test,$(test)))
+# Exclude tests that were specified to run with specific plugins from the tests
+# which can run with any plugin combination, so we don't run it twice.
+MULTIARCH_TESTS:=$(filter-out $(EXTRA_TESTS_WITH_PLUGIN), $(MULTIARCH_TESTS))
+
NUM_PLUGINS := $(words $(PLUGINS))
NUM_TESTS := $(words $(MULTIARCH_TESTS))
$(shell $(PYTHON) -c "print( ($(1) % $(2)) + 1 )")
endef
+# Rules for running tests with any plugin combination, i.e., no specific plugin.
$(foreach _idx, $(shell seq 1 $(NUM_TESTS)), \
$(eval _test := $(word $(_idx), $(MULTIARCH_TESTS))) \
$(eval _plugin := $(word $(call mod_plus_one, $(_idx), $(NUM_PLUGINS)), $(PLUGINS))) \
$(eval run-plugin-$(_test)-with-$(_plugin): $(_test) $(_plugin)) \
$(eval RUN_TESTS+=run-plugin-$(_test)-with-$(_plugin)))
+# Rules for running extra tests with specific plugins.
+$(foreach f,$(EXTRA_RUNS_WITH_PLUGIN), \
+ $(eval $(f): $(call extract-test,$(f)) $(call extract-plugin,$(f))))
+
endif # MULTIARCH_TESTS
endif # CONFIG_PLUGIN
-strip-plugin = $(wordlist 1, 1, $(subst -with-, ,$1))
-extract-plugin = $(wordlist 2, 2, $(subst -with-, ,$1))
-
RUN_TESTS+=$(EXTRA_RUNS)
+RUN_TESTS+=$(EXTRA_RUNS_WITH_PLUGIN)
# Some plugins need additional arguments above the default to fully
# exercise things. We can define them on a per-test basis here.