2 .PHONY: prepare-check check clean prepare-expected expected all
6 -include ../../Makefile.local
10 OPTIONS=$(shell if test -f options; then cat options; else echo ""; fi)
11 PROGRAM=../../$(TARGET) -d $(OPTIONS)
13 # Compute the set of input files.
14 INPUTS=$(shell find . -name "*.$(IN_EXT)")
16 OUTPUTS=$(INPUTS:$(IN_EXT)=$(OUT_EXT))
18 # We run the compiler in debugging mode on each input file.
19 # This will produce an $(OUTEXT) file as well as a lot of
20 # files that contain execution traces. We check that these
21 # traces are the ones that are expected.
22 %.$(OUT_EXT): %.$(IN_EXT) ../../$(TARGET)
23 @ echo ----------------------------------------\
24 --------------------------------------
25 @ echo -n Checking $* ...
26 @ (($(PROGRAM) -d $< 2> $*.log 1> $*.log && (echo OK | tee -a ok-counter)) \
27 || (echo "KO"; echo " ($*.log for details)" | tee -a ko-counter))
28 @ for i in `ls $** | grep -v expected | grep -v log`; do \
29 if [ ! -e $$i.expected ]; then \
30 echo No reference to compare to.; \
31 if [ x`cat generate` == x1 ]; then \
32 echo "Current output becomes expected behavior, as asked."; \
33 cp $$i $$i.expected; \
35 elif diff -u $$i $$i.expected 2> /dev/null 1> /dev/null; then \
36 echo " [OK] $$i" | tee -a ok-counter; \
38 echo " [KO] $$i" | tee -a ko-counter; \
43 @ rm --force ok-counter ko-counter
47 check: clean prepare-check $(OUTPUTS)
48 @ cat ok-counter ko-counter > total-counter
49 @ echo ----------------------------------------\
50 --------------------------------------
51 @ echo ----------------------------------------\
52 --------------------------------------
54 `wc -l ok-counter | cut -f1 -d' '` \
55 /`wc -l total-counter | cut -f1 -d' '`
56 @ echo ----------------------------------------\
57 --------------------------------------
62 @ echo You asked for overwriting of the expected outputs.
63 @ echo -n "Are you sure? [Y/N] "
64 @ read R; if [ $$R == "Y" ]; then \
70 expected: clean prepare-expected check
73 rm --force *.ASM *.Clight *.Cminor *.RTLabs *.RTL *.ERTL *.LTL *.LIN *.log