@echo "ok"
@touch $@
-test: ${BUILD_DIR}/bin/radiusd ${BUILD_DIR}/bin/radclient tests.unit tests.keywords tests.auth $(BUILD_DIR)/tests/radiusd-c | build.raddb
+test: ${BUILD_DIR}/bin/radiusd ${BUILD_DIR}/bin/radclient tests.unit tests.keywords tests.auth tests.modules $(BUILD_DIR)/tests/radiusd-c | build.raddb
@$(MAKE) -C src/tests tests
# Tests specifically for Travis. We do a LOT more than just
# do nothing
endif
-SUBMAKEFILES := include/all.mk lib/all.mk tests/all.mk modules/all.mk main/all.mk
+SUBMAKEFILES := include/all.mk lib/all.mk modules/all.mk main/all.mk tests/all.mk
-SUBMAKEFILES := rbmonkey.mk unit/all.mk keywords/all.mk auth/all.mk
+SUBMAKEFILES := rbmonkey.mk unit/all.mk keywords/all.mk auth/all.mk modules/all.mk
#
# Include all of the autoconf definitions into the Make variable space
--- /dev/null
+Module Tests
+------------
+
+To test module `foo`, create a directory `foo`, and put a file `all.mk` into it, e.g.
+
+ foo/all.mk
+
+All of the tests for the module should go here. The tests will be run
+*only* if the module is available, and has been built correctly on the system.
+
+The file should contain a target "MODULE.test". This is the main
+target used to test the module. The framework automatically makes the
+tests depend on the module (i.e. library). So if the module source
+changes, you can just do `make MODULE.test`. The module will be
+re-built, and the tests will be run.
--- /dev/null
+#
+# Find the subdirs which have "all.mk"
+#
+TEST_SUBDIRS := $(patsubst src/tests/modules/%/all.mk,%,$(wildcard src/tests/modules/*/all.mk))
+
+#
+# Find out which of those have a similar target. i.e. modules/foo -> rlm_foo.la
+#
+TEST_TARGETS := $(foreach x,$(TEST_SUBDIRS),$(findstring rlm_$x.la,$(ALL_TGTS)))
+
+TEST_BUILT := $(patsubst rlm_%.la,%,$(TEST_TARGETS))
+
+#
+# For the remaining ones, add on the directory to include.
+#
+SUBMAKEFILES := $(addsuffix /all.mk,$(TEST_BUILT))
+
+#
+# Ensure that the tests depend on the module, so that changes to the
+# module will re-run the test
+#
+$(foreach x,$(TEST_BUILT),$(eval $x.test: rlm_$x.la))
+
+#
+# Add the module tests to the overall dependencies
+#
+tests.modules: tests.unit tests.keywords tests.auth $(patsubst %,%.test,$(TEST_BUILT))
--- /dev/null
+#
+# Test the "files" module
+#
+
+# MODULE.test is the main target for this module.
+files.test:
+ @echo OK: files.test