aboutsummaryrefslogtreecommitdiff
path: root/tests/ipc-notify/init.c
blob: 4626f1082378e21a169fbe63c6e12c6c8509d0dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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();
}