]> matita.cs.unibo.it Git - pkg-cerco/acc.git/blob - tests/clight/Makefile
Imported Upstream version 0.2
[pkg-cerco/acc.git] / tests / clight / Makefile
1 # -*- Makefile -*-
2 .PHONY: prepare-check check clean prepare-expected expected all
3
4 all: check
5
6 -include ../../Makefile.local
7
8 IN_EXT=c
9 OUT_EXT=ASM
10 OPTIONS=$(shell if test -f options; then cat options; else echo ""; fi)
11 PROGRAM=../../$(TARGET) -d $(OPTIONS)
12
13 # Compute the set of input files. 
14 INPUTS=$(shell find . -name "*.$(IN_EXT)")
15
16 OUTPUTS=$(INPUTS:$(IN_EXT)=$(OUT_EXT))
17
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;                                         \
34                 fi;                                                             \
35           elif diff -u $$i $$i.expected 2> /dev/null 1> /dev/null; then         \
36                 echo "  [OK] $$i" | tee -a ok-counter;                          \
37           else                                                                  \
38                 echo "  [KO] $$i" | tee -a ko-counter;                          \
39           fi;                                                                   \
40         done
41
42 prepare-check:
43         @ rm --force ok-counter ko-counter
44         @ touch ok-counter
45         @ touch ko-counter
46
47 check: clean prepare-check $(OUTPUTS)
48         @ cat ok-counter ko-counter > total-counter
49         @ echo ----------------------------------------\
50                --------------------------------------
51         @ echo ----------------------------------------\
52                --------------------------------------
53         @ echo Total:                           \
54           `wc -l ok-counter | cut -f1 -d' '`    \
55          /`wc -l total-counter | cut -f1 -d' '`
56         @ echo ----------------------------------------\
57                --------------------------------------
58
59 prepare-expected:
60         @ GENERATE=1
61         @ export GENERATE
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       \
65                 echo 1 > generate;              \
66           else                                  \
67                 echo 0 > generate;              \
68           fi
69
70 expected: clean prepare-expected check
71
72 clean:
73         rm --force *.ASM *.Clight *.Cminor *.RTLabs *.RTL *.ERTL *.LTL *.LIN *.log