Remove redundant file from freeradius-abfab list.
[freeradius.git] / src / tests / map / map_tests.mk
1 MAP_TESTS       := $(patsubst $(top_srcdir)/src/tests/map/%,%,$(filter-out %.conf %.md %.attrs %.c %.mk %~ %.rej %.out,$(wildcard $(top_srcdir)/src/tests/map/*)))
2 MAP_OUTPUT      := $(addsuffix .out,$(addprefix $(BUILD_DIR)/tests/map/,$(MAP_TESTS)))
3 MAP_UNIT        := $(BUILD_DIR)/bin/local/map_unit
4
5 .PHONY: $(BUILD_DIR)/tests/map/
6 $(BUILD_DIR)/tests/map/:
7         @mkdir -p $@
8
9 #
10 #       Re-run the tests if the test program changes
11 #
12 #       Create the output directory before the files
13 #
14 $(MAP_OUTPUT): $(MAP_UNIT) | $(BUILD_DIR)/tests/map/
15
16 #
17 #       Re-run the tests if the input file changes
18 #
19 $(BUILD_DIR)/tests/map/%.out: $(top_srcdir)/src/tests/map/%
20         @echo MAP_TEST $(notdir $<)
21         @if ! $(MAP_UNIT) -d $(top_srcdir)/raddb -D $(top_srcdir)/share $< > $@ 2>&1; then \
22                 if ! grep ERROR $< 2>&1 > /dev/null; then \
23                         cat $@; \
24                         echo "# $@"; \
25                         echo FAILED: "$(MAP_UNIT) -d $(top_srcdir)/raddb -D $(top_srcdir)/share $<"; \
26                         exit 1; \
27                 fi; \
28                 FOUND=$$(grep $< $@ | head -1 | sed 's,^.*$(top_srcdir),,;s/:.*//;s/.*\[//;s/\].*//'); \
29                 EXPECTED=$$(grep -n ERROR $< | sed 's/:.*//'); \
30                 if [ "$$EXPECTED" != "$$FOUND" ]; then \
31                         cat $@; \
32                         echo "# $@"; \
33                         echo "E $$EXPECTED F $$FOUND"; \
34                         echo UNEXPECTED ERROR: "$(MAP_UNIT) -d $(top_srcdir)/raddb -D $(top_srcdir)/share $<"; \
35                         exit 1; \
36                 fi; \
37         else \
38                 if ! diff $<.out $@; then \
39                         echo FAILED: " diff $<.out $@"; \
40                         echo FAILED: "$(MAP_UNIT) -d $(top_srcdir)/raddb -D $(top_srcdir)/share $<"; \
41                         exit 1; \
42                 fi; \
43         fi
44
45 TESTS.MAP_FILES := $(MAP_OUTPUT)
46
47 $(TESTS.MAP_FILES): $(TESTS.UNIT_FILES)
48
49 tests.map: $(MAP_OUTPUT)