aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-10-30 13:34:18 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2024-11-01 10:27:36 +0200
commitf139fff6ae7063c1965fa3085bb2585d7d838d72 (patch)
tree7ee9f7c6a1ee09dba93c086cd66861474b821c97 /tests
parentb576c1d477bf476f277d32ecf60c312e4a97490d (diff)
downloadkmi-f139fff6ae7063c1965fa3085bb2585d7d838d72.tar.gz
kmi-f139fff6ae7063c1965fa3085bb2585d7d838d72.zip
rpc actually marks and unmarks stack regions
+ Processes won't be able to read previous stack frames etc
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile4
-rw-r--r--tests/create-exhaustion/source.mk3
-rw-r--r--tests/create/source.mk3
-rw-r--r--tests/detach/source.mk3
-rw-r--r--tests/fork-exhaustion/source.mk3
-rw-r--r--tests/fork/source.mk3
-rw-r--r--tests/hello-world/source.mk3
-rw-r--r--tests/ipc-notify/source.mk3
-rw-r--r--tests/ipc-req/init.c28
-rw-r--r--tests/ipc-req/source.mk3
-rw-r--r--tests/malloc/source.mk3
-rw-r--r--tests/noop/source.mk3
-rwxr-xr-xtests/scripts/gen-simple4
-rwxr-xr-xtests/scripts/gen-tests29
14 files changed, 63 insertions, 32 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 0a662f7..105b9bb 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -6,8 +6,12 @@ check:
SOURCES != echo */source.mk
DO != echo -n > tests.mk
+
+TESTS :=
include $(SOURCES)
+DO != ./scripts/gen-tests $(TESTS)
+
RM ?= rm
.PHONY: clean
diff --git a/tests/create-exhaustion/source.mk b/tests/create-exhaustion/source.mk
index d096746..5b90073 100644
--- a/tests/create-exhaustion/source.mk
+++ b/tests/create-exhaustion/source.mk
@@ -1,2 +1 @@
-DO != ./scripts/gen-prog -n create-exhaustion -p init init.c
-DO != ./scripts/gen-simple -n create-exhaustion -p init
+TESTS += create-exhaustion
diff --git a/tests/create/source.mk b/tests/create/source.mk
index b9f8efe..7aa5eb7 100644
--- a/tests/create/source.mk
+++ b/tests/create/source.mk
@@ -1,2 +1 @@
-DO != ./scripts/gen-prog -n create -p init init.c
-DO != ./scripts/gen-simple -n create -p init
+TESTS += create
diff --git a/tests/detach/source.mk b/tests/detach/source.mk
index 843562f..c248759 100644
--- a/tests/detach/source.mk
+++ b/tests/detach/source.mk
@@ -1,2 +1 @@
-DO != ./scripts/gen-prog -n detach -p init init.c
-DO != ./scripts/gen-simple -n detach -p init
+TESTS += detach
diff --git a/tests/fork-exhaustion/source.mk b/tests/fork-exhaustion/source.mk
index 458973d..7dc7d36 100644
--- a/tests/fork-exhaustion/source.mk
+++ b/tests/fork-exhaustion/source.mk
@@ -1,2 +1 @@
-DO != ./scripts/gen-prog -n fork-exhaustion -p init init.c
-DO != ./scripts/gen-simple -n fork-exhaustion -p init
+TESTS += fork-exhaustion
diff --git a/tests/fork/source.mk b/tests/fork/source.mk
index 47572e6..e78d467 100644
--- a/tests/fork/source.mk
+++ b/tests/fork/source.mk
@@ -1,2 +1 @@
-DO != ./scripts/gen-prog -n fork -p init init.c
-DO != ./scripts/gen-simple -n fork -p init
+TEST += fork
diff --git a/tests/hello-world/source.mk b/tests/hello-world/source.mk
index 5fd60ff..a24092c 100644
--- a/tests/hello-world/source.mk
+++ b/tests/hello-world/source.mk
@@ -1,2 +1 @@
-DO != ./scripts/gen-prog -n hello-world -p init init.c
-DO != ./scripts/gen-simple -n hello-world -p init
+TESTS += hello-world
diff --git a/tests/ipc-notify/source.mk b/tests/ipc-notify/source.mk
index e154996..635d335 100644
--- a/tests/ipc-notify/source.mk
+++ b/tests/ipc-notify/source.mk
@@ -1,2 +1 @@
-DO != ./scripts/gen-prog -n ipc-notify -p init init.c
-DO != ./scripts/gen-simple -n ipc-notify -p init
+TESTS += ipc-notify
diff --git a/tests/ipc-req/init.c b/tests/ipc-req/init.c
index 3439335..90e04a7 100644
--- a/tests/ipc-req/init.c
+++ b/tests/ipc-req/init.c
@@ -4,19 +4,25 @@ START(pid, tid, d0, d1, d2, d3)
{
check(pid == 0 || pid == 1, "illegal pid for init");
if (pid == 0) {
- /* send request to ourselves */
- printf("sending ipc req to ourselves\n");
- struct sys_ret r = sys_ipc_req4(1, 1, 2, 3, 4);
- printf("returned ipc req to ourselves\n");
- check(r.s == OK, "not OK return\n");
- check(r.id == 1, "not OK response ID\n");
- check(r.a0 == 1, "not OK d0 response\n");
- check(r.a1 == 2, "not OK d1 response\n");
- check(r.a2 == 3, "not OK d2 response\n");
- check(r.a3 == 4, "not OK d3 response\n");
+ printf("doing nonsense response\n");
+ enum sys_status s = sys_ipc_resp0();
+ check(s != OK, "OK return?\n");
+
+ for (size_t i = 0; i < 3; ++i) {
+ printf("sending ipc req %zd to ourselves\n", i);
+ struct sys_ret r = sys_ipc_req4(1, 1, 2, 3, 4);
+
+ printf("returned ipc req to ourselves\n");
+ check(r.s == OK, "not OK return\n");
+ check(r.id == 1, "not OK response ID\n");
+ check(r.a0 == 1, "not OK d0 response\n");
+ check(r.a1 == 2, "not OK d1 response\n");
+ check(r.a2 == 3, "not OK d2 response\n");
+ check(r.a3 == 4, "not OK d3 response\n");
+ }
/* try to request to non-existing proc */
- r = sys_ipc_req0(200);
+ struct sys_ret r = sys_ipc_req0(200);
check(r.s != OK, "got OK return for illegal pid\n");
}
else if (pid == 1) {
diff --git a/tests/ipc-req/source.mk b/tests/ipc-req/source.mk
index 0e65407..4b77d99 100644
--- a/tests/ipc-req/source.mk
+++ b/tests/ipc-req/source.mk
@@ -1,2 +1 @@
-DO != ./scripts/gen-prog -n ipc-req -p init init.c
-DO != ./scripts/gen-simple -n ipc-req -p init
+TESTS += ipc-req
diff --git a/tests/malloc/source.mk b/tests/malloc/source.mk
index 9498682..01b4d6e 100644
--- a/tests/malloc/source.mk
+++ b/tests/malloc/source.mk
@@ -1,2 +1 @@
-DO != ./scripts/gen-prog -n malloc -p init init.c
-DO != ./scripts/gen-simple -n malloc -p init
+TESTS += malloc
diff --git a/tests/noop/source.mk b/tests/noop/source.mk
index cbb87b7..0663967 100644
--- a/tests/noop/source.mk
+++ b/tests/noop/source.mk
@@ -1,2 +1 @@
-DO != ./scripts/gen-prog -n noop -p init init.c
-DO != ./scripts/gen-simple -n noop -p init
+TESTS += noop
diff --git a/tests/scripts/gen-simple b/tests/scripts/gen-simple
index 418cc02..a942fb3 100755
--- a/tests/scripts/gen-simple
+++ b/tests/scripts/gen-simple
@@ -28,8 +28,10 @@ echo " timeout --foreground 30s \$(QEMU) \
echo "TESTS += $NAME" >> tests.mk
echo ".PHONY: $NAME" >> tests.mk
-echo "$NAME: reports/$NAME/log" >> 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
+
+echo "$NAME: reports/$NAME/OK" >> tests.mk
diff --git a/tests/scripts/gen-tests b/tests/scripts/gen-tests
new file mode 100755
index 0000000..7095e30
--- /dev/null
+++ b/tests/scripts/gen-tests
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+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
+
+ echo "build/$NAME/init: $NAME/init.c \$(COMMON) \$(KMI)" >> tests.mk
+ echo " \$(COMPILE_TEST) $NAME/init.c \$(COMMON) -o build/$NAME/init" >> tests.mk
+
+ echo "build/$NAME/initrd: build/$NAME/init" >> tests.mk
+ echo " echo build/$NAME/init | \$(GEN_INITRD) build/$NAME/initrd" >> tests.mk
+
+ echo "reports/$NAME/log: build/$NAME/initrd" >> tests.mk
+ echo " timeout --foreground 30s \$(QEMU) \
+ build/$NAME/initrd > reports/$NAME/log" >> 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
+
+ echo "TESTS += $NAME" >> tests.mk
+ echo ".PHONY: $NAME" >> tests.mk
+ echo "$NAME: reports/$NAME/OK" >> tests.mk
+done