summaryrefslogtreecommitdiffstats
path: root/src/tests/xlat/all.mk
blob: 190a1eddcd65e443eca49da36a354ab7a359e4dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
#  Unit tests for dynamic xlat expansions
#

#
#  The test files are files without extensions.
#  The list is unordered.  The order is added in the next step by looking
#  at precursors.
#
XLAT_FILES := $(subst $(DIR)/,,$(wildcard $(DIR)/*.txt))

#
#  Create the output directory
#
.PHONY: $(BUILD_DIR)/tests/xlat
$(BUILD_DIR)/tests/xlat:
	@mkdir -p $@

#
#  Files in the output dir depend on the unit tests
#
#	src/tests/xlat/FOO		input file
#	build/tests/xlat/FOO		updated if the test succeeds
#	build/tests/xlat/FOO.log	debug output for the test
#
#  Auto-depend on modules via $(shell grep INCLUDE $(DIR)/radiusd.conf | grep mods-enabled | sed 's/.*}/raddb/'))
#
#  If the test fails, then look for ERROR in the input.  No error
#  means it's unexpected, so we die.
#
#  Otherwise, check the log file for a parse error which matches the
#  ERROR line in the input.
#
$(BUILD_DIR)/tests/xlat/%: $(DIR)/% $(TESTBINDIR)/unittest | $(BUILD_DIR)/tests/xlat build.raddb
	@echo XLAT-TEST $(notdir $@)
	@if ! $(TESTBIN)/unittest -D share -d src/tests/xlat/ -i $< -xx -O xlat_only > $@.log 2>&1; then \
		cat $@.log; \
		echo "./$(TESTBIN)/unittest -D share -d src/tests/xlat/ -i $< -xx -O xlat_only"; \
		exit 1; \
	fi
	@touch $@

#
#  Get all of the unit test output files
#
TESTS.XLAT_FILES := $(addprefix $(BUILD_DIR)/tests/xlat/,$(XLAT_FILES))

#
#  Depend on the output files, and create the directory first.
#
tests.xlat: $(TESTS.XLAT_FILES)

$(TESTS.XLAT_FILES): $(TESTS.UNIT_FILES)

.PHONY: clean.tests.xlat
clean.tests.xlat:
	@rm -rf $(BUILD_DIR)/tests/xlat/