source: Deliverables/D2.2/8051/tests/clight/Makefile @ 486

Last change on this file since 486 was 486, checked in by ayache, 9 years ago

Deliverable D2.2

File size: 2.4 KB
Line 
1# -*- Makefile -*-
2.PHONY: prepare-check check clean prepare-expected expected all
3
4all: check
5
6-include ../../Makefile.local
7
8IN_EXT=c
9OUT_EXT=ASM
10OPTIONS=$(shell if test -f options; then cat options; else echo ""; fi)
11PROGRAM=../../$(TARGET) -d $(OPTIONS)
12
13# Compute the set of input files.
14INPUTS=$(shell find . -name "*.$(IN_EXT)")
15
16OUTPUTS=$(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
42prepare-check:
43        @ rm --force ok-counter ko-counter
44        @ touch ok-counter
45        @ touch ko-counter
46
47check: 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
59prepare-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
70expected: clean prepare-expected check
71
72clean:
73        rm --force *.ASM *.Clight *.Cminor *.RTLabs *.RTL *.ERTL *.LTL *.LIN *.log
Note: See TracBrowser for help on using the repository browser.