aboutsummaryrefslogtreecommitdiff
path: root/tests/scripts
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2026-05-01 18:37:38 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2026-05-01 18:42:08 +0300
commit7790e27b3423901e2080bfd3c600a65a48d42886 (patch)
treee53f3d2b01fd24ade5eff042cb5d09bd1865c540 /tests/scripts
parentdbf8737fd34a0766691999e3271e9c5662ffae0d (diff)
downloadfwd-7790e27b3423901e2080bfd3c600a65a48d42886.tar.gz
fwd-7790e27b3423901e2080bfd3c600a65a48d42886.zip
start adding proper tests
Diffstat (limited to 'tests/scripts')
-rwxr-xr-xtests/scripts/gen-xfail29
-rwxr-xr-xtests/scripts/gen-xpass15
-rw-r--r--tests/scripts/makefile19
3 files changed, 63 insertions, 0 deletions
diff --git a/tests/scripts/gen-xfail b/tests/scripts/gen-xfail
new file mode 100755
index 0000000..c4cf382
--- /dev/null
+++ b/tests/scripts/gen-xfail
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+mkdir -p $(for d in "${@}"; do echo "$d"; done \
+ | sed "s|,.*||" | uniq | sed "s|^|reports/|")
+
+for s in "${@}"
+do
+ NAME=${s%%,*}
+ EMSG=${s#${NAME},}
+ echo ".PHONY: $NAME" >> tests.mk
+ echo "$NAME:" >> tests.mk
+ echo " ../fwd $NAME/$NAME.fwd \\" >> tests.mk
+ echo " > reports/$NAME/gen.c 2> reports/$NAME/log \\" >> tests.mk
+ echo " && echo 'Wrong retval' > reports/$NAME/OK \\" >> tests.mk
+ echo " || :" >> tests.mk
+ echo " grep '$EMSG' reports/$NAME/log > /dev/null \\" >> tests.mk
+ echo " && echo OK > reports/$NAME/OK \\" >> tests.mk
+ echo " || echo EMSG > reports/$NAME/OK" >> tests.mk
+done
+
+echo -n "TESTS +=" >> tests.mk
+for s in "${@}"
+do
+ NAME=${s%%,*}
+ echo -n " $NAME" >> tests.mk
+done
+
+# append newline
+echo "" >> tests.mk
diff --git a/tests/scripts/gen-xpass b/tests/scripts/gen-xpass
new file mode 100755
index 0000000..762650e
--- /dev/null
+++ b/tests/scripts/gen-xpass
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+mkdir -p $(for d in "${@}"; do echo "$d"; done | uniq | sed "s|^|reports/|")
+
+for s in "${@}"
+do
+ echo ".PHONY: $s" >> tests.mk
+ echo "$s:" >> tests.mk
+ echo " ../fwd $s/$s.fwd > reports/$s/gen.c 2> reports/$s/log" >> tests.mk
+ echo " \$(COMPILE_TEST) reports/$s/gen.c -o reports/$s/$s \\" >> tests.mk
+ echo " \$(TEST_LIBS)" >> tests.mk
+ echo " ./reports/$s/$s > reports/$s/OK 2>&1" >> tests.mk
+done
+
+echo "TESTS += " "${@}" >> tests.mk
diff --git a/tests/scripts/makefile b/tests/scripts/makefile
new file mode 100644
index 0000000..21b1418
--- /dev/null
+++ b/tests/scripts/makefile
@@ -0,0 +1,19 @@
+.PHONY: all
+all: check
+
+COMPILE_TEST := $(CC) -L../mod -I../include -I../lib -Wl,-rpath=../mod -O2
+TEST_LIBS := -lfwdio -lfwdmem -lfwdutil
+
+TESTS :=
+include tests.mk
+
+.PHONY: check
+check: $(TESTS)
+ @cd reports; for d in * ; do \
+ if [ ! -f "$$d/OK" ]; then \
+ echo "BROKEN: $$d" ; \
+ elif [ "$$(tail -n1 $$d/OK)" != "OK" ]; then \
+ echo "FAIL: $$d" ; \
+ fi \
+ done
+ @echo "Done."