diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/common/test.h | 50 | ||||
| -rw-r--r-- | tests/ipc-notify/check.mk | 4 | ||||
| -rw-r--r-- | tests/ipc-notify/init.c | 42 | ||||
| -rw-r--r-- | tests/ipc-notify/source.mk | 2 |
4 files changed, 82 insertions, 16 deletions
diff --git a/tests/common/test.h b/tests/common/test.h index 2738bcd..18ac388 100644 --- a/tests/common/test.h +++ b/tests/common/test.h @@ -177,27 +177,45 @@ static inline id_t sys_req_abs_timer(uint64_t ticks) #define sys_ipc_kick3(pid, d0, d1, d2) syscall4(SYS_IPC_KICK, pid, d0, d1, d2) #define sys_ipc_kick4(pid, d0, d1, d2, d3) syscall5(SYS_IPC_KICK, pid, d0, d1, d2, d3) -#define sys_ipc_resp0() syscall0(SYS_IPC_RESP) -#define sys_ipc_resp1(d0) syscall1(SYS_IPC_RESP, d0) -#define sys_ipc_resp2(d0, d1) syscall2(SYS_IPC_RESP, d0, d1) -#define sys_ipc_resp3(d0, d1, d2) syscall3(SYS_IPC_RESP, d0, d1, d2) -#define sys_ipc_resp4(d0, d1, d2, d3) syscall4(SYS_IPC_RESP, d0, d1, d2, d3) - -#define sys_ipc_ghost0() syscall1(SYS_IPC_GHOST) -#define sys_ipc_ghost1(d0) syscall2(SYS_IPC_GHOST, d0) -#define sys_ipc_ghost2(d0, d1) syscall3(SYS_IPC_GHOST, d0, d1) -#define sys_ipc_ghost3(d0, d1, d2) syscall4(SYS_IPC_GHOST, d0, d1, d2) -#define sys_ipc_ghost4(d0, d1, d2, d3) syscall5(SYS_IPC_GHOST, d0, d1, d2, d3) - static inline enum sys_status sys_set_handler(id_t tid, id_t pid) { struct sys_ret r = syscall2(SYS_SET_HANDLER, tid, pid); return r.s; } -static inline enum sys_status sys_notify(id_t tid) +static inline enum sys_status sys_ipc_notify(id_t tid) +{ + struct sys_ret r = syscall1(SYS_IPC_NOTIFY, tid); + return r.s; +} + +static inline enum sys_status sys_ipc_resp0() +{ + struct sys_ret r = syscall0(SYS_IPC_RESP); + return r.s; +} + +static inline enum sys_status sys_ipc_resp1(sys_arg_t a) +{ + struct sys_ret r = syscall1(SYS_IPC_RESP, a); + return r.s; +} + +static inline enum sys_status sys_ipc_resp2(sys_arg_t a, sys_arg_t b) +{ + struct sys_ret r = syscall2(SYS_IPC_RESP, a, b); + return r.s; +} + +static inline enum sys_status sys_ipc_resp3(sys_arg_t a, sys_arg_t b, sys_arg_t c) +{ + struct sys_ret r = syscall3(SYS_IPC_RESP, a, b, c); + return r.s; +} + +static inline enum sys_status sys_ipc_resp4(sys_arg_t a, sys_arg_t b, sys_arg_t c, sys_arg_t d) { - struct sys_ret r = syscall1(SYS_NOTIFY, tid); + struct sys_ret r = syscall4(SYS_IPC_RESP, a, b, c, d); return r.s; } @@ -314,11 +332,11 @@ static inline enum sys_status sys_exit() int printf(const char *fmt, ...) __printf; #define error(x, ...)\ - printf("ERROR: " x # __VA_ARGS__) + printf("ERROR: " x, ## __VA_ARGS__) #define check(x, y, ...)\ if (!(x)) {\ - error(y #__VA_ARGS__);\ + error(y, ##__VA_ARGS__);\ sys_poweroff(SYS_SHUTDOWN);\ } diff --git a/tests/ipc-notify/check.mk b/tests/ipc-notify/check.mk new file mode 100644 index 0000000..54da852 --- /dev/null +++ b/tests/ipc-notify/check.mk @@ -0,0 +1,4 @@ +ipc-notify: do-ipc-notify + @grep 'BUG' reports/ipc-notify/log \ + && echo 'BUG' > reports/ipc-notify/OK \ + || tail -n1 reports/ipc-notify/log | tr -d '\r' > reports/ipc-notify/OK diff --git a/tests/ipc-notify/init.c b/tests/ipc-notify/init.c new file mode 100644 index 0000000..4626f10 --- /dev/null +++ b/tests/ipc-notify/init.c @@ -0,0 +1,42 @@ +#include <common/test.h> + +START(pid, tid, d0, d1, d2, d3) +{ + UNUSED(d3); + check(pid == 0, "illegal pid for init\n"); + check(d0 == SYS_USER_NOTIFY || d0 == SYS_USER_SPAWNED, + "illegal d0 for init\n"); + + if (d0 == SYS_USER_SPAWNED) { + /* send request to ourselves */ + printf("sending ipc notify to ourselves\n"); + check(tid == 1, "illegal init thread ID\n"); + struct sys_ret r = syscall5(SYS_IPC_NOTIFY, 1, 1, 2, 3, 4); + printf("returned ipc notify to ourselves\n"); + + check(r.s == OK, "illegal notify status\n"); + check(r.id == 0, "illegal notify id\n"); + check(r.a0 != 10, "ipc resp leaked through?\n"); + check(r.a1 != 11, "ipc resp leaked through?\n"); + check(r.a2 != 12, "ipc resp leaked through?\n"); + check(r.a3 != 13, "ipc resp leaked through?\n"); + + /* try to notify to non-existing proc */ + enum sys_status s = sys_ipc_notify(200); + check(s != OK, "got OK return for illegal pid\n"); + } + else if (d0 == SYS_USER_NOTIFY) { + printf("caught ipc notify\n"); + check(tid == 1, "illegal tid source\n"); + check(d1 & NOTIFY_SIGNAL, "illegal d1\n"); + check(d2 == 1, "illegal d2\n"); + + printf("doing ipc resp in notification\n"); + /* whatever we respond here should not be visible in whoever ran + * the notification */ + sys_ipc_resp4(10, 11, 12, 13); + check(0, "ipc resp failed\n"); + } + + ok(); +} diff --git a/tests/ipc-notify/source.mk b/tests/ipc-notify/source.mk new file mode 100644 index 0000000..e154996 --- /dev/null +++ b/tests/ipc-notify/source.mk @@ -0,0 +1,2 @@ +DO != ./scripts/gen-prog -n ipc-notify -p init init.c +DO != ./scripts/gen-simple -n ipc-notify -p init |
