aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ipc-fwd/init.c63
-rw-r--r--tests/ipc-fwd/source.mk1
-rw-r--r--tests/ipc-kick/init.c54
-rw-r--r--tests/ipc-kick/source.mk1
-rw-r--r--tests/ipc-req-exhaustion/init.c27
-rw-r--r--tests/ipc-req-exhaustion/source.mk1
-rw-r--r--tests/ipc-root/init.c51
-rw-r--r--tests/ipc-root/source.mk1
-rw-r--r--tests/ipc-tail/init.c54
-rw-r--r--tests/ipc-tail/source.mk1
-rwxr-xr-xtests/scripts/gen-tests4
11 files changed, 256 insertions, 2 deletions
diff --git a/tests/ipc-fwd/init.c b/tests/ipc-fwd/init.c
new file mode 100644
index 0000000..2f04f3f
--- /dev/null
+++ b/tests/ipc-fwd/init.c
@@ -0,0 +1,63 @@
+#include <common/test.h>
+
+START(pid, tid, d0, d1, d2, d3)
+{
+ check(pid == 0 || pid == 1, "illegal pid for init");
+ if (pid == 0) {
+ printf("creating pid 2\n");
+ id_t id1 = sys_fork(NULL);
+ check(id1 == 2, "unexpected pid?\n");
+
+ printf("creating pid 3\n");
+ id_t id2 = sys_fork(NULL);
+ check(id2 == 3, "unexpected pid?\n");
+
+ struct sys_ret r = sys_ipc_req4(2, 1, 2, 3, 4);
+ check(r.s == 0, "failed request?\n");
+ check(r.id == 2, "wrong responder?\n");
+ check(r.a0 == 1, "wrong a0?\n");
+ check(r.a1 == 2, "wrong a1?\n");
+ check(r.a2 == 3, "wrong a2?\n");
+ check(r.a3 == 4, "wrong a3?\n");
+ }
+ else if (pid == 1 && d0 == 1) {
+ printf("pid 2 caught ipc req\n");
+ check(pid == 1, "illegal pid source\n");
+ check(tid == 1, "illegal tid source\n");
+ check(d0 == 1, "illegal d0\n");
+ check(d1 == 2, "illegal d1\n");
+ check(d2 == 3, "illegal d2\n");
+ check(d3 == 4, "illegal d3\n");
+
+ printf("pid 2 forwarding\n");
+ struct sys_ret r = sys_ipc_fwd4(3, 5, 6, 7, 8);
+ check(r.s == 0, "failed request?\n");
+ check(r.id == 3, "wrong responder?\n");
+ check(r.a0 == 5, "wrong a0?\n");
+ check(r.a1 == 6, "wrong a1?\n");
+ check(r.a2 == 7, "wrong a2?\n");
+ check(r.a3 == 8, "wrong a3?\n");
+
+ printf("pid 2 responding\n");
+ sys_ipc_resp4(1, 2, 3, 4);
+ error("pid 2 ipc_resp failed\n");
+ }
+ else if (pid == 1 && d0 == 5) {
+ printf("pid 3 caught ipc fwd\n");
+ check(pid == 1, "illegal pid source\n");
+ check(tid == 1, "illegal tid source\n");
+ check(d0 == 5, "illegal d0\n");
+ check(d1 == 6, "illegal d1\n");
+ check(d2 == 7, "illegal d2\n");
+ check(d3 == 8, "illegal d3\n");
+
+ printf("pid 3 responding\n");
+ sys_ipc_resp4(5, 6, 7, 8);
+ error("pid 3 ipc_resp failed\n");
+ }
+ else {
+ error("weird pid: %ld\n", pid);
+ }
+
+ ok();
+}
diff --git a/tests/ipc-fwd/source.mk b/tests/ipc-fwd/source.mk
new file mode 100644
index 0000000..ed0078f
--- /dev/null
+++ b/tests/ipc-fwd/source.mk
@@ -0,0 +1 @@
+TESTS += ipc-fwd
diff --git a/tests/ipc-kick/init.c b/tests/ipc-kick/init.c
new file mode 100644
index 0000000..3be4dee
--- /dev/null
+++ b/tests/ipc-kick/init.c
@@ -0,0 +1,54 @@
+#include <common/test.h>
+
+START(pid, tid, d0, d1, d2, d3)
+{
+ check(pid == 0 || pid == 1, "illegal pid for init\n");
+ if (pid == 0) {
+ printf("creating pid 2\n");
+ id_t id1 = sys_fork(NULL);
+ check(id1 == 2, "unexpected pid?\n");
+
+ printf("creating pid 3\n");
+ id_t id2 = sys_fork(NULL);
+ check(id2 == 3, "unexpected pid?\n");
+
+ struct sys_ret r = sys_ipc_req4(2, 1, 2, 3, 4);
+ check(r.s == 0, "failed request?\n");
+ check(r.id == 3, "wrong responder?\n");
+ check(r.a0 == 5, "wrong a0?\n");
+ check(r.a1 == 6, "wrong a1?\n");
+ check(r.a2 == 7, "wrong a2?\n");
+ check(r.a3 == 8, "wrong a3?\n");
+ }
+ else if (pid == 1 && d0 == 1) {
+ printf("pid 2 caught ipc req\n");
+ check(pid == 1, "illegal pid source\n");
+ check(tid == 1, "illegal tid source\n");
+ check(d0 == 1, "illegal d0\n");
+ check(d1 == 2, "illegal d1\n");
+ check(d2 == 3, "illegal d2\n");
+ check(d3 == 4, "illegal d3\n");
+
+ printf("pid 2 kicking\n");
+ sys_ipc_kick4(3, 5, 6, 7, 8);
+ error("pid 2 ipc_tail failed\n");
+ }
+ else if (pid == 1 && d0 == 5) {
+ printf("pid 3 caught ipc kick\n");
+ check(pid == 1, "illegal pid source\n");
+ check(tid == 1, "illegal tid source\n");
+ check(d0 == 5, "illegal d0\n");
+ check(d1 == 6, "illegal d1\n");
+ check(d2 == 7, "illegal d2\n");
+ check(d3 == 8, "illegal d3\n");
+
+ printf("pid 3 responding\n");
+ sys_ipc_resp4(5, 6, 7, 8);
+ error("pid 3 ipc_resp failed\n");
+ }
+ else {
+ error("weird pid: %ld\n", pid);
+ }
+
+ ok();
+}
diff --git a/tests/ipc-kick/source.mk b/tests/ipc-kick/source.mk
new file mode 100644
index 0000000..838a651
--- /dev/null
+++ b/tests/ipc-kick/source.mk
@@ -0,0 +1 @@
+TESTS += ipc-kick
diff --git a/tests/ipc-req-exhaustion/init.c b/tests/ipc-req-exhaustion/init.c
new file mode 100644
index 0000000..6dd1a04
--- /dev/null
+++ b/tests/ipc-req-exhaustion/init.c
@@ -0,0 +1,27 @@
+#include <common/test.h>
+
+long counter = 0;
+
+START(pid, tid, d0, d1, d2, d3)
+{
+ (void)tid;
+ (void)d0;
+ (void)d1;
+ (void)d2;
+ (void)d3;
+
+ check(pid == 0 || pid == 1, "illegal pid for init");
+ printf("sending ipc req %zd to ourselves\n", counter++);
+ struct sys_ret r = sys_ipc_req4(1, 1, 2, 3, 4);
+ if (r.s) {
+ printf("ran out of stack space at %ld\n", counter);
+ printf("starting to unwind\n");
+ }
+
+ printf("unwinding at %ld\n", counter--);
+
+ /* the final resp0 should fail, since we're back in our root process */
+ sys_ipc_resp0();
+
+ ok();
+}
diff --git a/tests/ipc-req-exhaustion/source.mk b/tests/ipc-req-exhaustion/source.mk
new file mode 100644
index 0000000..3dc2ff3
--- /dev/null
+++ b/tests/ipc-req-exhaustion/source.mk
@@ -0,0 +1 @@
+TESTS += ipc-req-exhaustion
diff --git a/tests/ipc-root/init.c b/tests/ipc-root/init.c
new file mode 100644
index 0000000..8b43b4f
--- /dev/null
+++ b/tests/ipc-root/init.c
@@ -0,0 +1,51 @@
+#include <common/test.h>
+
+START(pid, tid, d0, d1, d2, d3)
+{
+ check(pid == 0 || pid == 1, "illegal pid for init");
+ if (pid == 0) {
+ printf("sending ipc fwd from root\n");
+ struct sys_ret r = sys_ipc_fwd4(1, 1, 2, 3, 4);
+ 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("sending ipc tail from root\n");
+ r = sys_ipc_tail4(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("sending ipc kick from root\n");
+ r = sys_ipc_kick4(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");
+ }
+ else if (pid == 1) {
+ printf("caught ipc\n");
+ check(pid == 1, "illegal pid source\n");
+ check(tid == 1, "illegal tid source\n");
+ check(d0 == 1, "illegal d0\n");
+ check(d1 == 2, "illegal d1\n");
+ check(d2 == 3, "illegal d2\n");
+ check(d3 == 4, "illegal d3\n");
+
+ printf("sending response\n");
+ sys_ipc_resp4(1, 2, 3, 4);
+ error("ipc resp failed\n");
+ }
+
+ ok();
+}
diff --git a/tests/ipc-root/source.mk b/tests/ipc-root/source.mk
new file mode 100644
index 0000000..fe98f64
--- /dev/null
+++ b/tests/ipc-root/source.mk
@@ -0,0 +1 @@
+TESTS += ipc-root
diff --git a/tests/ipc-tail/init.c b/tests/ipc-tail/init.c
new file mode 100644
index 0000000..8f3efdd
--- /dev/null
+++ b/tests/ipc-tail/init.c
@@ -0,0 +1,54 @@
+#include <common/test.h>
+
+START(pid, tid, d0, d1, d2, d3)
+{
+ check(pid == 0 || pid == 1 || pid == 2, "illegal pid for init\n");
+ if (pid == 0) {
+ printf("creating pid 2\n");
+ id_t id1 = sys_fork(NULL);
+ check(id1 == 2, "unexpected pid?\n");
+
+ printf("creating pid 3\n");
+ id_t id2 = sys_fork(NULL);
+ check(id2 == 3, "unexpected pid?\n");
+
+ struct sys_ret r = sys_ipc_req4(2, 1, 2, 3, 4);
+ check(r.s == 0, "failed request?\n");
+ check(r.id == 3, "wrong responder?\n");
+ check(r.a0 == 5, "wrong a0?\n");
+ check(r.a1 == 6, "wrong a1?\n");
+ check(r.a2 == 7, "wrong a2?\n");
+ check(r.a3 == 8, "wrong a3?\n");
+ }
+ else if (pid == 1) {
+ printf("pid 2 caught ipc req\n");
+ check(pid == 1, "illegal pid source\n");
+ check(tid == 1, "illegal tid source\n");
+ check(d0 == 1, "illegal d0\n");
+ check(d1 == 2, "illegal d1\n");
+ check(d2 == 3, "illegal d2\n");
+ check(d3 == 4, "illegal d3\n");
+
+ printf("pid 2 tailing\n");
+ sys_ipc_tail4(3, 5, 6, 7, 8);
+ error("pid 2 ipc_tail failed\n");
+ }
+ else if (pid == 2) {
+ printf("pid 3 caught ipc tail\n");
+ check(pid == 2, "illegal pid source\n");
+ check(tid == 1, "illegal tid source\n");
+ check(d0 == 5, "illegal d0\n");
+ check(d1 == 6, "illegal d1\n");
+ check(d2 == 7, "illegal d2\n");
+ check(d3 == 8, "illegal d3\n");
+
+ printf("pid 3 responding\n");
+ sys_ipc_resp4(5, 6, 7, 8);
+ error("pid 3 ipc_resp failed\n");
+ }
+ else {
+ error("weird pid: %ld\n", pid);
+ }
+
+ ok();
+}
diff --git a/tests/ipc-tail/source.mk b/tests/ipc-tail/source.mk
new file mode 100644
index 0000000..e91a864
--- /dev/null
+++ b/tests/ipc-tail/source.mk
@@ -0,0 +1 @@
+TESTS += ipc-tail
diff --git a/tests/scripts/gen-tests b/tests/scripts/gen-tests
index 7095e30..3be204d 100755
--- a/tests/scripts/gen-tests
+++ b/tests/scripts/gen-tests
@@ -18,8 +18,8 @@ for NAME in "${@}"; do
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 " 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