# -*- Makefile -*- .PHONY: prepare-check check clean prepare-expected expected all all: check -include ../../Makefile.local IN_EXT=c OUT_EXT=ASM OPTIONS=$(shell if test -f options; then cat options; else echo ""; fi) PROGRAM=../../$(TARGET) -d $(OPTIONS) # Compute the set of input files. INPUTS=$(shell find . -name "*.$(IN_EXT)") OUTPUTS=$(INPUTS:$(IN_EXT)=$(OUT_EXT)) # We run the compiler in debugging mode on each input file. # This will produce an $(OUTEXT) file as well as a lot of # files that contain execution traces. We check that these # traces are the ones that are expected. %.$(OUT_EXT): %.$(IN_EXT) ../../$(TARGET) @ echo ----------------------------------------\ -------------------------------------- @ echo -n Checking $* ... @ (($(PROGRAM) -d $< 2> $*.log 1> $*.log && (echo OK | tee -a ok-counter)) \ || (echo "KO"; echo " ($*.log for details)" | tee -a ko-counter)) @ for i in `ls $** | grep -v expected | grep -v log`; do \ if [ ! -e $$i.expected ]; then \ echo No reference to compare to.; \ if [ x`cat generate` == x1 ]; then \ echo "Current output becomes expected behavior, as asked."; \ cp $$i $$i.expected; \ fi; \ elif diff -u $$i $$i.expected 2> /dev/null 1> /dev/null; then \ echo " [OK] $$i" | tee -a ok-counter; \ else \ echo " [KO] $$i" | tee -a ko-counter; \ fi; \ done prepare-check: @ rm --force ok-counter ko-counter @ touch ok-counter @ touch ko-counter check: clean prepare-check $(OUTPUTS) @ cat ok-counter ko-counter > total-counter @ echo ----------------------------------------\ -------------------------------------- @ echo ----------------------------------------\ -------------------------------------- @ echo Total: \ `wc -l ok-counter | cut -f1 -d' '` \ /`wc -l total-counter | cut -f1 -d' '` @ echo ----------------------------------------\ -------------------------------------- prepare-expected: @ GENERATE=1 @ export GENERATE @ echo You asked for overwriting of the expected outputs. @ echo -n "Are you sure? [Y/N] " @ read R; if [ $$R == "Y" ]; then \ echo 1 > generate; \ else \ echo 0 > generate; \ fi expected: clean prepare-expected check clean: rm --force *.ASM *.Clight *.Cminor *.RTLabs *.RTL *.ERTL *.LTL *.LIN *.log