From 0a7eca06548e7261e28ba49679cc2ba4e6851e59 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Fri, 8 Oct 2021 23:00:40 +0100 Subject: Fix running of tests using a Makefile --- Makefile | 3 ++- test/Makefile | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 test/Makefile diff --git a/Makefile b/Makefile index d14ef13..0749d1c 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ doc: Makefile.coq extraction: src/extraction/STAMP test: - ./test/test_all.sh ./test + $(MAKE) -C test compile: src/extraction/STAMP @echo "OCaml bin/vericert" @@ -73,6 +73,7 @@ Makefile.coq: clean:: Makefile.coq $(MAKE) -f Makefile.coq clean + $(MAKE) -C test clean rm -f Makefile.coq clean:: diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..f161386 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,34 @@ +CC ?= gcc +VERICERT ?= vericert +VERICERT_OPTS ?= -fschedule +IVERILOG ?= iverilog +IVERILOG_OPTS ?= + +TESTS := $(patsubst %.c,%.check,$(wildcard *.c)) + +all: $(TESTS) + +%.gcc.out: %.gcc + @./$< ; echo "$$?" >$@ + +%.o: %.c + @$(CC) $(CFLAGS) -c $< -o $@ + +%.gcc: %.o + @$(CC) $(CFLAGS) $< -o $@ + +%.v: %.c + @$(VERICERT) $(VERICERT_OPTS) $< -o $@ + +%.iver: %.v + @$(IVERILOG) $(IVERILOG_OPTS) -o $@ -- $< + +%.veri.out: %.iver + @./$< | tail -n1 | sed -r -e 's/[^0-9]*([0-9]+)/\1/' >$@ + +%.check: %.gcc.out %.veri.out + @diff $^ >$@ + @printf "\033[0;36mOK\033[0m\t$(patsubst %.check,%,$@)\n" + +clean: + rm -f *.check *.gcc *.gcc.out *.o *.v *.iver *.veri.out -- cgit