aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-04-22 21:09:09 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2025-04-22 21:09:09 +0300
commit9d735045e0b73b46443f9dacd1b42f5ac3e734de (patch)
treeaab90f47777ba3f8fb7b7760c4457426d7cf62a2 /tests
parent96eca4b42f1efc4fbb663dd6994a43fcdf26bf5d (diff)
downloadkmi-9d735045e0b73b46443f9dacd1b42f5ac3e734de.tar.gz
kmi-9d735045e0b73b46443f9dacd1b42f5ac3e734de.zip
simplify generator scripts
Diffstat (limited to 'tests')
-rwxr-xr-xtests/scripts/gen-simple48
-rwxr-xr-xtests/scripts/gen-tests31
-rw-r--r--tests/scripts/makefile13
3 files changed, 41 insertions, 51 deletions
diff --git a/tests/scripts/gen-simple b/tests/scripts/gen-simple
index fe2d7a4..b6688b6 100755
--- a/tests/scripts/gen-simple
+++ b/tests/scripts/gen-simple
@@ -10,7 +10,7 @@ while getopts "n:p:" opt; do
esac
done
-mkdir -p "build/$NAME"
+mkdir -p "build/$NAME" "reports/$NAME"
if [ -z "$NAME" ]; then
echo "No name given for tests" >&2; exit 2;
@@ -20,35 +20,29 @@ if [ -z "$PROGS" ]; then
echo "No programs to add to initrd" >&2; exit 3;
fi
-for p in $PROGS
-do
- dep="build/${NAME}/${p}.d"
+for p in $PROGS; do dep="build/${NAME}/${p}.d"; cat << ENDRULES >> tests.mk
- echo "${NAME}_PROGS += build/${NAME}/${p}" >> tests.mk
- echo "${dep}:" >> tests.mk
- echo "-include ${dep}" >> tests.mk
- echo "build/${NAME}/${p}: $NAME/$p.c \$(COMMON)" >> tests.mk
- echo " \$(COMPILE_TEST) $NAME/${p}.c \$(COMMON) \\" >> tests.mk
- echo " -o build/${NAME}/${p}" >> tests.mk
+${NAME}_PROGS += build/${NAME}/${p}
+${dep}:
+-include ${dep}
+
+build/${NAME}/${p}: $NAME/$p.c \$(COMMON)
+ \$(COMPILE_TEST) $NAME/${p}.c \$(COMMON) -o build/${NAME}/${p}
+
+ENDRULES
done
-echo "build/$NAME/initrd: \$(${NAME}_PROGS) \$(COMMON) \$(KMI)" >> tests.mk
-echo " for p in \$(${NAME}_PROGS); do \\" >> tests.mk
-echo " echo \$\$p; \\" >> tests.mk
-echo " done | \$(GEN_INITRD) build/$NAME/initrd" >> tests.mk
+cat << ENDRULES >> tests.mk
+
+build/$NAME/initrd: \$(${NAME}_PROGS) \$(COMMON) \$(KMI)
+ for p in \$(${NAME}_PROGS); do echo \$\$p; done \\
+ | \$(GEN_INITRD) build/$NAME/initrd
-echo "reports/$NAME/log: build/$NAME/initrd" >> tests.mk
-echo " mkdir -p reports/$NAME" >> tests.mk
-echo " rm -f reports/$NAME/*" >> tests.mk
-echo " timeout --foreground 30s \$(QEMU) \\" >> tests.mk
-echo " build/$NAME/initrd > reports/$NAME/log" >> tests.mk
+reports/$NAME/log: build/$NAME/initrd
+ timeout --foreground 30s \$(QEMU) build/$NAME/initrd > reports/$NAME/log
-echo "TESTS += $NAME" >> tests.mk
-echo ".PHONY: $NAME" >> tests.mk
-echo "reports/$NAME/OK: reports/$NAME/log" >> tests.mk
-echo " grep 'BUG' reports/$NAME/log \\" >> tests.mk
-echo " && echo 'BUG' > reports/$NAME/log \\" >> tests.mk
-echo " || tail -n1 reports/$NAME/log | tr -d '\\\\r' \\" >> tests.mk
-echo " > reports/$NAME/OK" >> tests.mk
+TESTS += $NAME
+.PHONY: $NAME
+$NAME: reports/$NAME/log
-echo "$NAME: reports/$NAME/OK" >> tests.mk
+ENDRULES
diff --git a/tests/scripts/gen-tests b/tests/scripts/gen-tests
index 3be204d..57dba8f 100755
--- a/tests/scripts/gen-tests
+++ b/tests/scripts/gen-tests
@@ -3,27 +3,22 @@
mkdir -p $(for d in "${@}"; do echo $d; done | sed "s|^|build/|")
mkdir -p $(for d in "${@}"; do echo $d; done | sed "s|^|reports/|")
-for NAME in "${@}"; do
- echo "build/$NAME/init.d:" >> tests.mk
- echo "-include build/$NAME/init.d" >> tests.mk
+for NAME in "${@}"; do cat << ENDRULES >> tests.mk
+build/$NAME/init.d:
+-include build/$NAME/init.d
- echo "build/$NAME/init: $NAME/init.c \$(COMMON) \$(KMI)" >> tests.mk
- echo " \$(COMPILE_TEST) $NAME/init.c \$(COMMON) -o build/$NAME/init" >> tests.mk
+build/$NAME/init: $NAME/init.c \$(COMMON) \$(KMI)
+ \$(COMPILE_TEST) $NAME/init.c \$(COMMON) -o build/$NAME/init
- echo "build/$NAME/initrd: build/$NAME/init" >> tests.mk
- echo " echo build/$NAME/init | \$(GEN_INITRD) build/$NAME/initrd" >> tests.mk
+build/$NAME/initrd: build/$NAME/init
+ echo build/$NAME/init | \$(GEN_INITRD) build/$NAME/initrd
- echo "reports/$NAME/log: build/$NAME/initrd" >> tests.mk
- echo " timeout --foreground 30s \$(QEMU) \
- build/$NAME/initrd > reports/$NAME/log" >> tests.mk
+reports/$NAME/log: build/$NAME/initrd
+ timeout --foreground 30s \$(QEMU) build/$NAME/initrd > reports/$NAME/log
- echo "reports/$NAME/OK: reports/$NAME/log" >> tests.mk
- echo " grep 'BUG|ERROR' reports/$NAME/log \\" >> tests.mk
- echo " && echo 'NOTOK' > reports/$NAME/log \\" >> tests.mk
- echo " || tail -n1 reports/$NAME/log | tr -d '\\\\r' \\" >> tests.mk
- echo " > reports/$NAME/OK" >> tests.mk
+TESTS += $NAME
+.PHONY: $NAME
+$NAME: reports/$NAME/log
- echo "TESTS += $NAME" >> tests.mk
- echo ".PHONY: $NAME" >> tests.mk
- echo "$NAME: reports/$NAME/OK" >> tests.mk
+ENDRULES
done
diff --git a/tests/scripts/makefile b/tests/scripts/makefile
index 63150b1..2161427 100644
--- a/tests/scripts/makefile
+++ b/tests/scripts/makefile
@@ -40,11 +40,12 @@ 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 \
+ @cd reports; for d in * ; do \
+ if [ ! -f "$$d/log" ]; then \
+ echo "BROKEN: $$d" ; \
+ elif grep 'BUG|ERR' $$d/log \
+ || [ "$$(tail -n1 $$d/log | tr -d '\r')" != "OK" ]; then \
+ echo "FAIL: $$d" ; \
+ fi \
done
@echo "Done."