From 50b37d4a27d3295a29afca2286f1a5a086142cec Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:49:46 +0200 Subject: Adding upstream version 3.2.1+dfsg. Signed-off-by: Daniel Baumann --- src/tests/map/map_tests.mk | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/tests/map/map_tests.mk (limited to 'src/tests/map/map_tests.mk') diff --git a/src/tests/map/map_tests.mk b/src/tests/map/map_tests.mk new file mode 100644 index 0000000..7474489 --- /dev/null +++ b/src/tests/map/map_tests.mk @@ -0,0 +1,50 @@ +MAP_TESTS := $(patsubst $(top_srcdir)/src/tests/map/%,%,$(filter-out %.conf %.md %.attrs %.c %.mk %~ %.rej %.out,$(wildcard $(top_srcdir)/src/tests/map/*))) +MAP_OUTPUT := $(addsuffix .out,$(addprefix $(BUILD_DIR)/tests/map/,$(MAP_TESTS))) +MAP_UNIT_BIN := $(BUILD_DIR)/bin/local/map_unit +MAP_UNIT := ./build/make/jlibtool --silent --mode=execute $(MAP_UNIT_BIN) + +.PHONY: $(BUILD_DIR)/tests/map/ +$(BUILD_DIR)/tests/map/: + @mkdir -p $@ + +# +# Re-run the tests if the test program changes +# +# Create the output directory before the files +# +$(MAP_OUTPUT): $(MAP_UNIT_BIN) | $(BUILD_DIR)/tests/map/ + +# +# Re-run the tests if the input file changes +# +$(BUILD_DIR)/tests/map/%.out: $(top_srcdir)/src/tests/map/% + @echo MAP_TEST $(notdir $<) + @if ! $(MAP_UNIT) -d $(top_srcdir)/raddb -D $(top_srcdir)/share $< > $@ 2>&1; then \ + if ! grep ERROR $< 2>&1 > /dev/null; then \ + cat $@; \ + echo "# $@"; \ + echo FAILED: "$(MAP_UNIT) -d $(top_srcdir)/raddb -D $(top_srcdir)/share $<"; \ + exit 1; \ + fi; \ + FOUND=$$(grep $< $@ | head -1 | sed 's,^.*$(top_srcdir),,;s/:.*//;s/.*\[//;s/\].*//'); \ + EXPECTED=$$(grep -n ERROR $< | sed 's/:.*//'); \ + if [ "$$EXPECTED" != "$$FOUND" ]; then \ + cat $@; \ + echo "# $@"; \ + echo "E $$EXPECTED F $$FOUND"; \ + echo UNEXPECTED ERROR: "$(MAP_UNIT) -d $(top_srcdir)/raddb -D $(top_srcdir)/share $<"; \ + exit 1; \ + fi; \ + else \ + if ! diff $<.out $@; then \ + echo FAILED: " diff $<.out $@"; \ + echo FAILED: "$(MAP_UNIT) -d $(top_srcdir)/raddb -D $(top_srcdir)/share $<"; \ + exit 1; \ + fi; \ + fi + +TESTS.MAP_FILES := $(MAP_OUTPUT) + +$(TESTS.MAP_FILES): $(TESTS.UNIT_FILES) + +tests.map: $(MAP_OUTPUT) -- cgit v1.2.3