diff --git a/makefiles/tests/tests.inc.mk b/makefiles/tests/tests.inc.mk index c2152ccb21..7ceded0bcc 100644 --- a/makefiles/tests/tests.inc.mk +++ b/makefiles/tests/tests.inc.mk @@ -40,17 +40,36 @@ test-as-root/available: $(Q)test -n "$(strip $(TESTS_AS_ROOT))" # Tests that require specific configuration -.PHONY: test-with-config test-with-config/available -TESTS_WITH_CONFIG ?= $(foreach file,$(wildcard $(APPDIR)/tests-with-config/*[^~]),\ - $(shell test -f $(file) -a -x $(file) && echo $(file))) +.PHONY: test-with-config test-with-config/available test-with-config/check-config +# Scripts for tests that require specific configuration (with automatic +# configuration checks filtered out) +TESTS_WITH_CONFIG ?= $(filter-out $(APPDIR)/tests-with-config/check-config%,\ + $(foreach file,$(wildcard $(APPDIR)/tests-with-config/*[^~]),\ + $(shell test -f $(file) -a -x $(file) && echo $(file)))\ +) +# Scripts that provide an automatic configuration check +# for tests with specific configuration +CHECK_CONFIG ?= $(foreach file,$(wildcard $(APPDIR)/tests-with-config/check-config*[^~]),\ + $(shell test -f $(file) -a -x $(file) && echo $(file))) -test-with-config: $(TEST_DEPS) +test-with-config: test-with-config/check-config $(TEST_DEPS) $(Q) for t in $(TESTS_WITH_CONFIG); do \ $$t || exit 1; \ done -test-with-config/available: - $(Q)test -n "$(strip $(TESTS_WITH_CONFIG))" +# run the automatic configuration check +test-with-config/check-config: + $(Q)test -z "$(strip $(CHECK_CONFIG))" || \ + ${COLOR_ECHO} -n "${COLOR_RED}"; \ + for t in $(CHECK_CONFIG) empty; do \ + test $$t = "empty" && break; \ + $$t || \ + (echo "System configuration for" \ + "tests is not available, check $${t#$${RIOTBASE}/} failed." \ + "${COLOR_RESET}"; \ + exit 1) || exit 1; \ + done; \ + ${COLOR_ECHO} -n "${COLOR_RESET}" # this target only makes sense if an ELFFILE is actually created, thus guard by # RIOTNOLINK="".