aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2021-10-08 23:00:40 +0100
committerYann Herklotz <git@yannherklotz.com>2021-10-08 23:00:40 +0100
commit0a7eca06548e7261e28ba49679cc2ba4e6851e59 (patch)
tree0f050c71616d047074b8b482339edb3270194e27
parent82604915aab691007abfa937fd5e90d646332034 (diff)
downloadvericert-kvx-0a7eca06548e7261e28ba49679cc2ba4e6851e59.tar.gz
vericert-kvx-0a7eca06548e7261e28ba49679cc2ba4e6851e59.zip
Fix running of tests using a Makefile
-rw-r--r--Makefile3
-rw-r--r--test/Makefile34
2 files changed, 36 insertions, 1 deletions
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