1TESTS= test_unicode \
2		 test_state \
3		 test_xml \
4		 test_adacore_dom \
5		 test_schema \
6		 test_date_time \
7		 test_numbers \
8		 test_adacore_schema \
9		 test_multiple_xsd \
10		 test_examples_dom \
11		 test_examples_sax \
12		 test_examples_schema \
13		 test_base64
14
15
16# Force running all the tests
17.PHONY: ${TESTS}
18
19tests: ${TESTS}
20
21EXECDIR=./obj/
22RESULTS=$(shell pwd)/results
23EXAMPLE_EXPECTED=$(shell pwd)/examples
24
25test_unicode: EXEC=unicode/test_unicode
26test_unicode: generic_test_unicode
27
28test_base64: EXEC=base64/test_base64
29test_base64: generic_test_base64
30
31test_state: EXEC=sax/teststate
32test_state: generic_test_state
33
34test_xml: EXEC=dom/testxml
35test_xml: ARGS=-auto
36test_xml: generic_test_xml
37
38test_schema: EXEC=schema/schematest
39test_schema: ARGS=--xsd10
40test_schema: generic_test_schema
41
42test_date_time: EXEC=schema/test_date_time
43test_date_time: generic_test_date_time
44
45test_numbers: EXEC=schema/testnumbers
46test_numbers: generic_test_numbers
47
48test_adacore_dom: EXEC=adacore/dom/adacore_dom.sh
49test_adacore_dom: EXECDIR=./
50
51test_adacore_schema: EXEC=adacore/schema/adacore_schema.sh
52test_adacore_schema: EXECDIR=./
53
54ifneq ($(wildcard adacore/.*),)
55test_adacore_dom: generic_test_adacore_dom
56test_adacore_schema: generic_test_adacore_schema
57else
58test_adacore_dom: generic_not_run_adacore_dom
59test_adacore_schema: generic_not_run_adacore_schema
60endif
61
62generic_test_%: BASE=$(notdir $(EXEC))
63generic_test_%: DIR=$(dir $(EXEC))
64generic_test_%:
65	@echo "$(EXEC)"
66	@cd $(DIR); \
67		mkdir -p obj; \
68		$(EXECDIR)$(BASE) $(ARGS) > obj/$(BASE).tmp_out; \
69		tr -d '\r' < obj/$(BASE).tmp_out > $(RESULTS)/$(BASE).out ; \
70		diff $(BASE).expected $(RESULTS)/$(BASE).out > $(RESULTS)/$(BASE).diff; \
71	  	if test -s $(RESULTS)/$(BASE).diff; then \
72		   echo "DIFF"; \
73			cat $(RESULTS)/$(BASE).diff ; \
74		else \
75		   echo "OK"; \
76		fi
77
78generic_not_run_%:
79	@echo "$(EXEC) skipped"
80
81test_multiple_xsd:
82	@echo "multiple xsd"
83	@cd schema/multiple_xsd; \
84		gprbuild -q -Pdefault.gpr; \
85		./validate > $(RESULTS)/multiple_xsd.out; \
86		cp $(RESULTS)/multiple_xsd.out $(RESULTS)/multiple_xsd.diff; \
87		cat $(RESULTS)/multiple_xsd.diff
88
89test_examples_dom:
90	@echo "test examples dom"
91	@cd ../docs/dom; \
92		gprbuild -q -p -Pdefault.gpr 2> $(RESULTS)/domexample.out; \
93		./domexample >> $(RESULTS)/domexample.out; \
94		cp $(RESULTS)/domexample.out $(RESULTS)/domexample.diff; \
95		cat $(RESULTS)/domexample.diff; \
96		./domexample2 > $(RESULTS)/domexample2.out; \
97		diff -b $(EXAMPLE_EXPECTED)/domexample2.expected $(RESULTS)/domexample2.out > $(RESULTS)/domexample2.diff; \
98		if test -s $(RESULTS)/domexample2.diff; then \
99			cat $(RESULTS)/domexample2.diff; fi; \
100		./domschemaexample > $(RESULTS)/domschemaexample.out; \
101		cp $(RESULTS)/domschemaexample.out $(RESULTS)/domschemaexample.diff; \
102		cat $(RESULTS)/domschemaexample.diff
103
104test_examples_sax:
105	@echo "test examples sax"
106	@cd ../docs/sax; \
107		gprbuild -q -p -Pdefault.gpr 2> $(RESULTS)/saxexample_main.out; \
108		./saxexample_main >> $(RESULTS)/saxexample_main.out; \
109		diff -b $(EXAMPLE_EXPECTED)/saxexample_main.expected $(RESULTS)/saxexample_main.out > $(RESULTS)/saxexample_main.diff; \
110		if test -s $(RESULTS)/saxexample_main.diff; then \
111			cat $(RESULTS)/saxexample_main.diff; \
112		fi
113
114test_examples_schema:
115	@echo "test examples schema"
116	@cd ../docs/schema; \
117		gprbuild -q -p -Pdefault.gpr 2> $(RESULTS)/schemaexample.out; \
118		./schemaexample >> $(RESULTS)/schemaexample.out; \
119		cp $(RESULTS)/schemaexample.out $(RESULTS)/schemaexample.diff; \
120		cat $(RESULTS)/schemaexample.diff
121