]>
Commit | Line | Data |
---|---|---|
5ba3f43e A |
1 | #define T_NAMESPACE "xnu.ipc" |
2 | #include <darwintest.h> | |
3 | #include <mach/mach.h> | |
4 | #include <stdlib.h> | |
5 | #include <stdio.h> | |
6 | ||
cb323159 A |
7 | T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true)); |
8 | ||
5ba3f43e A |
9 | #define NR_PORTS 4 |
10 | ||
11 | T_DECL(mach_port_deallocate, "mach_port_deallocate deallocates also PORT_SET"){ | |
12 | mach_port_t port_set; | |
13 | mach_port_t port[NR_PORTS]; | |
0a7de745 | 14 | int i, ret; |
5ba3f43e | 15 | |
0a7de745 | 16 | ret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_PORT_SET, &port_set); |
5ba3f43e A |
17 | T_ASSERT_MACH_SUCCESS(ret, "mach_port_allocate MACH_PORT_RIGHT_PORT_SET"); |
18 | ||
0a7de745 A |
19 | for (i = 0; i < NR_PORTS; i++) { |
20 | ret = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &port[i]); | |
5ba3f43e A |
21 | T_ASSERT_MACH_SUCCESS(ret, "mach_port_allocate MACH_PORT_RIGHT_RECEIVE"); |
22 | ||
0a7de745 | 23 | ret = mach_port_move_member(mach_task_self(), port[i], port_set); |
5ba3f43e A |
24 | T_ASSERT_MACH_SUCCESS(ret, "mach_port_move_member"); |
25 | } | |
26 | ||
27 | T_LOG("Ports created"); | |
28 | ||
29 | /* do something */ | |
30 | ||
0a7de745 A |
31 | for (i = 0; i < NR_PORTS; i++) { |
32 | ret = mach_port_mod_refs(mach_task_self(), port[i], MACH_PORT_RIGHT_RECEIVE, -1); | |
5ba3f43e A |
33 | T_ASSERT_MACH_SUCCESS(ret, "mach_port_mod_refs -1 RIGHT_RECEIVE"); |
34 | } | |
35 | ||
0a7de745 | 36 | ret = mach_port_deallocate(mach_task_self(), port_set); |
5ba3f43e A |
37 | T_ASSERT_MACH_SUCCESS(ret, "mach_port_deallocate PORT_SET"); |
38 | ||
39 | T_LOG("Ports erased"); | |
40 | } |