xref: /xnu-8796.121.2/tests/task_policy.c (revision c54f35ca767986246321eb901baf8f5ff7923f6a)
1*c54f35caSApple OSS Distributions #include <darwintest.h>
2*c54f35caSApple OSS Distributions #include <signal.h>
3*c54f35caSApple OSS Distributions #include <spawn.h>
4*c54f35caSApple OSS Distributions #include <unistd.h>
5*c54f35caSApple OSS Distributions 
6*c54f35caSApple OSS Distributions #include <mach/mach.h>
7*c54f35caSApple OSS Distributions #include <mach/mach_types.h>
8*c54f35caSApple OSS Distributions #include <mach/task.h>
9*c54f35caSApple OSS Distributions #include <mach/task_policy.h>
10*c54f35caSApple OSS Distributions 
11*c54f35caSApple OSS Distributions extern char **environ;
12*c54f35caSApple OSS Distributions 
13*c54f35caSApple OSS Distributions int task_inspect_for_pid(mach_port_name_t target_tport, int pid, mach_port_name_t *t);
14*c54f35caSApple OSS Distributions int task_for_pid(mach_port_name_t target_tport, int pid, mach_port_name_t *t);
15*c54f35caSApple OSS Distributions int task_name_for_pid(mach_port_name_t target_tport, int pid, mach_port_name_t *t);
16*c54f35caSApple OSS Distributions 
17*c54f35caSApple OSS Distributions T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
18*c54f35caSApple OSS Distributions 
19*c54f35caSApple OSS Distributions #if defined(UNENTITLED)
20*c54f35caSApple OSS Distributions 
21*c54f35caSApple OSS Distributions T_DECL(task_policy_set_task_name, "task_policy_set with task name (not entitled)")
22*c54f35caSApple OSS Distributions {
23*c54f35caSApple OSS Distributions 	struct task_qos_policy qosinfo = {
24*c54f35caSApple OSS Distributions 		.task_latency_qos_tier = LATENCY_QOS_TIER_0,
25*c54f35caSApple OSS Distributions 		.task_throughput_qos_tier = THROUGHPUT_QOS_TIER_0,
26*c54f35caSApple OSS Distributions 	};
27*c54f35caSApple OSS Distributions 	task_name_t task_name = TASK_NAME_NULL;
28*c54f35caSApple OSS Distributions 
29*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
30*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_name_for_pid(mach_task_self(), getpid(),
31*c54f35caSApple OSS Distributions 	    &task_name), NULL);
32*c54f35caSApple OSS Distributions 	T_SETUPEND;
33*c54f35caSApple OSS Distributions 
34*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_ERROR(task_policy_set(task_name,
35*c54f35caSApple OSS Distributions 	    TASK_BASE_QOS_POLICY,
36*c54f35caSApple OSS Distributions 	    (task_policy_t)&qosinfo,
37*c54f35caSApple OSS Distributions 	    TASK_QOS_POLICY_COUNT),
38*c54f35caSApple OSS Distributions 	    KERN_INVALID_ARGUMENT, NULL);
39*c54f35caSApple OSS Distributions }
40*c54f35caSApple OSS Distributions 
41*c54f35caSApple OSS Distributions T_DECL(task_policy_set_task, "task_policy_set with task (not entitled)")
42*c54f35caSApple OSS Distributions {
43*c54f35caSApple OSS Distributions 	struct task_qos_policy qosinfo = {
44*c54f35caSApple OSS Distributions 		.task_latency_qos_tier = LATENCY_QOS_TIER_0,
45*c54f35caSApple OSS Distributions 		.task_throughput_qos_tier = THROUGHPUT_QOS_TIER_0,
46*c54f35caSApple OSS Distributions 	};
47*c54f35caSApple OSS Distributions 
48*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_set(mach_task_self(),
49*c54f35caSApple OSS Distributions 	    TASK_BASE_QOS_POLICY,
50*c54f35caSApple OSS Distributions 	    (task_policy_t)&qosinfo,
51*c54f35caSApple OSS Distributions 	    TASK_QOS_POLICY_COUNT),
52*c54f35caSApple OSS Distributions 	    NULL);
53*c54f35caSApple OSS Distributions }
54*c54f35caSApple OSS Distributions 
55*c54f35caSApple OSS Distributions T_DECL(task_policy_set_inspect, "task_policy_set with task inspect (not entitled)")
56*c54f35caSApple OSS Distributions {
57*c54f35caSApple OSS Distributions 	struct task_qos_policy qosinfo = {
58*c54f35caSApple OSS Distributions 		.task_latency_qos_tier = LATENCY_QOS_TIER_0,
59*c54f35caSApple OSS Distributions 		.task_throughput_qos_tier = THROUGHPUT_QOS_TIER_0,
60*c54f35caSApple OSS Distributions 	};
61*c54f35caSApple OSS Distributions 	task_inspect_t task_inspect = TASK_INSPECT_NULL;
62*c54f35caSApple OSS Distributions 
63*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
64*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_inspect_for_pid(mach_task_self(), getpid(),
65*c54f35caSApple OSS Distributions 	    &task_inspect), NULL);
66*c54f35caSApple OSS Distributions 	T_SETUPEND;
67*c54f35caSApple OSS Distributions 
68*c54f35caSApple OSS Distributions 
69*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_ERROR(task_policy_set(task_inspect,
70*c54f35caSApple OSS Distributions 	    TASK_BASE_QOS_POLICY,
71*c54f35caSApple OSS Distributions 	    (task_policy_t)&qosinfo,
72*c54f35caSApple OSS Distributions 	    TASK_QOS_POLICY_COUNT),
73*c54f35caSApple OSS Distributions 	    KERN_INVALID_ARGUMENT, NULL);
74*c54f35caSApple OSS Distributions }
75*c54f35caSApple OSS Distributions 
76*c54f35caSApple OSS Distributions T_DECL(task_policy_set_foreign_task, "task_policy_set for foreign task (not entitled)", T_META_ASROOT(true))
77*c54f35caSApple OSS Distributions {
78*c54f35caSApple OSS Distributions 	struct task_qos_policy qosinfo = {
79*c54f35caSApple OSS Distributions 		.task_latency_qos_tier = LATENCY_QOS_TIER_0,
80*c54f35caSApple OSS Distributions 		.task_throughput_qos_tier = THROUGHPUT_QOS_TIER_0,
81*c54f35caSApple OSS Distributions 	};
82*c54f35caSApple OSS Distributions 	task_t task = TASK_NULL;
83*c54f35caSApple OSS Distributions 	kern_return_t ret = KERN_FAILURE;
84*c54f35caSApple OSS Distributions 	char *args[] = { "sleep", "10", NULL };
85*c54f35caSApple OSS Distributions 	pid_t pid = 0;
86*c54f35caSApple OSS Distributions 
87*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
88*c54f35caSApple OSS Distributions 
89*c54f35caSApple OSS Distributions 	ret = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
90*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "spawning sleep 10");
91*c54f35caSApple OSS Distributions 
92*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_for_pid(mach_task_self(), pid,
93*c54f35caSApple OSS Distributions 	    &task), NULL);
94*c54f35caSApple OSS Distributions 	T_SETUPEND;
95*c54f35caSApple OSS Distributions 
96*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_set(task,
97*c54f35caSApple OSS Distributions 	    TASK_BASE_QOS_POLICY,
98*c54f35caSApple OSS Distributions 	    (task_policy_t)&qosinfo,
99*c54f35caSApple OSS Distributions 	    TASK_QOS_POLICY_COUNT),
100*c54f35caSApple OSS Distributions 	    NULL);
101*c54f35caSApple OSS Distributions 
102*c54f35caSApple OSS Distributions 	ret = kill(pid, SIGTERM);
103*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "killing sleep");
104*c54f35caSApple OSS Distributions }
105*c54f35caSApple OSS Distributions 
106*c54f35caSApple OSS Distributions T_DECL(task_policy_set_foreign_task_name, "task_policy_set for foreign task name (not entitled)", T_META_ASROOT(true))
107*c54f35caSApple OSS Distributions {
108*c54f35caSApple OSS Distributions 	struct task_qos_policy qosinfo = {
109*c54f35caSApple OSS Distributions 		.task_latency_qos_tier = LATENCY_QOS_TIER_0,
110*c54f35caSApple OSS Distributions 		.task_throughput_qos_tier = THROUGHPUT_QOS_TIER_0,
111*c54f35caSApple OSS Distributions 	};
112*c54f35caSApple OSS Distributions 	task_name_t task_name = TASK_NAME_NULL;
113*c54f35caSApple OSS Distributions 	kern_return_t ret = KERN_FAILURE;
114*c54f35caSApple OSS Distributions 	char *args[] = { "sleep", "10", NULL };
115*c54f35caSApple OSS Distributions 	pid_t pid = 0;
116*c54f35caSApple OSS Distributions 
117*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
118*c54f35caSApple OSS Distributions 
119*c54f35caSApple OSS Distributions 	ret = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
120*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "spawning sleep 10");
121*c54f35caSApple OSS Distributions 
122*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_name_for_pid(mach_task_self(), pid,
123*c54f35caSApple OSS Distributions 	    &task_name), NULL);
124*c54f35caSApple OSS Distributions 	T_SETUPEND;
125*c54f35caSApple OSS Distributions 
126*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_ERROR(task_policy_set(task_name,
127*c54f35caSApple OSS Distributions 	    TASK_BASE_QOS_POLICY,
128*c54f35caSApple OSS Distributions 	    (task_policy_t)&qosinfo,
129*c54f35caSApple OSS Distributions 	    TASK_QOS_POLICY_COUNT),
130*c54f35caSApple OSS Distributions 	    KERN_INVALID_ARGUMENT, NULL);
131*c54f35caSApple OSS Distributions 
132*c54f35caSApple OSS Distributions 	ret = kill(pid, SIGTERM);
133*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "killing sleep");
134*c54f35caSApple OSS Distributions }
135*c54f35caSApple OSS Distributions 
136*c54f35caSApple OSS Distributions T_DECL(task_policy_set_foreign_task_inspect, "task_policy_set for foreign task inspect (not entitled)", T_META_ASROOT(true))
137*c54f35caSApple OSS Distributions {
138*c54f35caSApple OSS Distributions 	struct task_qos_policy qosinfo = {
139*c54f35caSApple OSS Distributions 		.task_latency_qos_tier = LATENCY_QOS_TIER_0,
140*c54f35caSApple OSS Distributions 		.task_throughput_qos_tier = THROUGHPUT_QOS_TIER_0,
141*c54f35caSApple OSS Distributions 	};
142*c54f35caSApple OSS Distributions 	task_inspect_t task_inspect = TASK_INSPECT_NULL;
143*c54f35caSApple OSS Distributions 	kern_return_t ret = KERN_FAILURE;
144*c54f35caSApple OSS Distributions 	char *args[] = { "sleep", "10", NULL };
145*c54f35caSApple OSS Distributions 	pid_t pid = 0;
146*c54f35caSApple OSS Distributions 
147*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
148*c54f35caSApple OSS Distributions 
149*c54f35caSApple OSS Distributions 	ret = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
150*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "spawning sleep 10");
151*c54f35caSApple OSS Distributions 
152*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_inspect_for_pid(mach_task_self(), pid,
153*c54f35caSApple OSS Distributions 	    &task_inspect), NULL);
154*c54f35caSApple OSS Distributions 	T_SETUPEND;
155*c54f35caSApple OSS Distributions 
156*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_ERROR(task_policy_set(task_inspect,
157*c54f35caSApple OSS Distributions 	    TASK_BASE_QOS_POLICY,
158*c54f35caSApple OSS Distributions 	    (task_policy_t)&qosinfo,
159*c54f35caSApple OSS Distributions 	    TASK_QOS_POLICY_COUNT),
160*c54f35caSApple OSS Distributions 	    KERN_INVALID_ARGUMENT, NULL);
161*c54f35caSApple OSS Distributions 
162*c54f35caSApple OSS Distributions 	ret = kill(pid, SIGTERM);
163*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "killing sleep");
164*c54f35caSApple OSS Distributions }
165*c54f35caSApple OSS Distributions 
166*c54f35caSApple OSS Distributions T_DECL(task_policy_get_name, "task_policy_get with task name (not entitled)")
167*c54f35caSApple OSS Distributions {
168*c54f35caSApple OSS Distributions 	task_name_t task_name = TASK_NAME_NULL;
169*c54f35caSApple OSS Distributions 	struct task_category_policy role[TASK_CATEGORY_POLICY_COUNT];
170*c54f35caSApple OSS Distributions 	mach_msg_type_number_t count = TASK_CATEGORY_POLICY_COUNT;
171*c54f35caSApple OSS Distributions 	boolean_t get_default = FALSE;
172*c54f35caSApple OSS Distributions 
173*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
174*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_name_for_pid(mach_task_self(), getpid(),
175*c54f35caSApple OSS Distributions 	    &task_name), NULL);
176*c54f35caSApple OSS Distributions 	T_SETUPEND;
177*c54f35caSApple OSS Distributions 
178*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_ERROR(task_policy_get(task_name,
179*c54f35caSApple OSS Distributions 	    TASK_CATEGORY_POLICY,
180*c54f35caSApple OSS Distributions 	    (task_policy_t)role,
181*c54f35caSApple OSS Distributions 	    &count,
182*c54f35caSApple OSS Distributions 	    &get_default),
183*c54f35caSApple OSS Distributions 	    KERN_INVALID_ARGUMENT, NULL);
184*c54f35caSApple OSS Distributions }
185*c54f35caSApple OSS Distributions 
186*c54f35caSApple OSS Distributions T_DECL(task_policy_get_task, "task_policy_get with task (not entitled)")
187*c54f35caSApple OSS Distributions {
188*c54f35caSApple OSS Distributions 	struct task_category_policy role[TASK_CATEGORY_POLICY_COUNT];
189*c54f35caSApple OSS Distributions 	mach_msg_type_number_t count = TASK_CATEGORY_POLICY_COUNT;
190*c54f35caSApple OSS Distributions 	boolean_t get_default = FALSE;
191*c54f35caSApple OSS Distributions 
192*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_get(mach_task_self(),
193*c54f35caSApple OSS Distributions 	    TASK_CATEGORY_POLICY,
194*c54f35caSApple OSS Distributions 	    (task_policy_t)role,
195*c54f35caSApple OSS Distributions 	    &count,
196*c54f35caSApple OSS Distributions 	    &get_default),
197*c54f35caSApple OSS Distributions 	    NULL);
198*c54f35caSApple OSS Distributions }
199*c54f35caSApple OSS Distributions 
200*c54f35caSApple OSS Distributions T_DECL(task_policy_get_inspect, "task_policy_get with task inspect (not entitled)")
201*c54f35caSApple OSS Distributions {
202*c54f35caSApple OSS Distributions 	task_inspect_t task_inspect = TASK_INSPECT_NULL;
203*c54f35caSApple OSS Distributions 	struct task_category_policy role[TASK_CATEGORY_POLICY_COUNT];
204*c54f35caSApple OSS Distributions 	mach_msg_type_number_t count = TASK_CATEGORY_POLICY_COUNT;
205*c54f35caSApple OSS Distributions 	boolean_t get_default = FALSE;
206*c54f35caSApple OSS Distributions 
207*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
208*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_inspect_for_pid(mach_task_self(), getpid(),
209*c54f35caSApple OSS Distributions 	    &task_inspect), NULL);
210*c54f35caSApple OSS Distributions 	T_SETUPEND;
211*c54f35caSApple OSS Distributions 
212*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_get(task_inspect,
213*c54f35caSApple OSS Distributions 	    TASK_CATEGORY_POLICY,
214*c54f35caSApple OSS Distributions 	    (task_policy_t)role,
215*c54f35caSApple OSS Distributions 	    &count,
216*c54f35caSApple OSS Distributions 	    &get_default),
217*c54f35caSApple OSS Distributions 	    NULL);
218*c54f35caSApple OSS Distributions }
219*c54f35caSApple OSS Distributions 
220*c54f35caSApple OSS Distributions T_DECL(task_policy_get_foreign_task_inspect, "task_policy_get for foreign task inspect (not entitled)", T_META_ASROOT(true))
221*c54f35caSApple OSS Distributions {
222*c54f35caSApple OSS Distributions 	task_inspect_t task_inspect = TASK_INSPECT_NULL;
223*c54f35caSApple OSS Distributions 	struct task_category_policy role[TASK_CATEGORY_POLICY_COUNT];
224*c54f35caSApple OSS Distributions 	mach_msg_type_number_t count = TASK_CATEGORY_POLICY_COUNT;
225*c54f35caSApple OSS Distributions 	boolean_t get_default = FALSE;
226*c54f35caSApple OSS Distributions 	kern_return_t ret = KERN_FAILURE;
227*c54f35caSApple OSS Distributions 	char *args[] = { "sleep", "10", NULL };
228*c54f35caSApple OSS Distributions 	pid_t pid = 0;
229*c54f35caSApple OSS Distributions 
230*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
231*c54f35caSApple OSS Distributions 
232*c54f35caSApple OSS Distributions 	ret = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
233*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "spawning sleep 10");
234*c54f35caSApple OSS Distributions 
235*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_inspect_for_pid(mach_task_self(), pid,
236*c54f35caSApple OSS Distributions 	    &task_inspect), NULL);
237*c54f35caSApple OSS Distributions 	T_SETUPEND;
238*c54f35caSApple OSS Distributions 
239*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_get(task_inspect,
240*c54f35caSApple OSS Distributions 	    TASK_CATEGORY_POLICY,
241*c54f35caSApple OSS Distributions 	    (task_policy_t)role,
242*c54f35caSApple OSS Distributions 	    &count,
243*c54f35caSApple OSS Distributions 	    &get_default),
244*c54f35caSApple OSS Distributions 	    NULL);
245*c54f35caSApple OSS Distributions 
246*c54f35caSApple OSS Distributions 	ret = kill(pid, SIGTERM);
247*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "killing sleep");
248*c54f35caSApple OSS Distributions }
249*c54f35caSApple OSS Distributions 
250*c54f35caSApple OSS Distributions T_DECL(task_policy_get_foreign_task, "task_policy_get for foreign task (not entitled)", T_META_ASROOT(true))
251*c54f35caSApple OSS Distributions {
252*c54f35caSApple OSS Distributions 	task_t task = TASK_NULL;
253*c54f35caSApple OSS Distributions 	struct task_category_policy role[TASK_CATEGORY_POLICY_COUNT];
254*c54f35caSApple OSS Distributions 	mach_msg_type_number_t count = TASK_CATEGORY_POLICY_COUNT;
255*c54f35caSApple OSS Distributions 	boolean_t get_default = FALSE;
256*c54f35caSApple OSS Distributions 	kern_return_t ret = KERN_FAILURE;
257*c54f35caSApple OSS Distributions 	char *args[] = { "sleep", "10", NULL };
258*c54f35caSApple OSS Distributions 	pid_t pid = 0;
259*c54f35caSApple OSS Distributions 
260*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
261*c54f35caSApple OSS Distributions 
262*c54f35caSApple OSS Distributions 	ret = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
263*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "spawning sleep 10");
264*c54f35caSApple OSS Distributions 
265*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_for_pid(mach_task_self(), pid,
266*c54f35caSApple OSS Distributions 	    &task), NULL);
267*c54f35caSApple OSS Distributions 	T_SETUPEND;
268*c54f35caSApple OSS Distributions 
269*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_get(task,
270*c54f35caSApple OSS Distributions 	    TASK_CATEGORY_POLICY,
271*c54f35caSApple OSS Distributions 	    (task_policy_t)role,
272*c54f35caSApple OSS Distributions 	    &count,
273*c54f35caSApple OSS Distributions 	    &get_default),
274*c54f35caSApple OSS Distributions 	    NULL);
275*c54f35caSApple OSS Distributions 
276*c54f35caSApple OSS Distributions 	ret = kill(pid, SIGTERM);
277*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "killing sleep");
278*c54f35caSApple OSS Distributions }
279*c54f35caSApple OSS Distributions 
280*c54f35caSApple OSS Distributions T_DECL(task_policy_get_foreign_task_name, "task_policy_get for foreign task name (not entitled)")
281*c54f35caSApple OSS Distributions {
282*c54f35caSApple OSS Distributions 	task_name_t task_name = TASK_NAME_NULL;
283*c54f35caSApple OSS Distributions 	struct task_category_policy role[TASK_CATEGORY_POLICY_COUNT];
284*c54f35caSApple OSS Distributions 	mach_msg_type_number_t count = TASK_CATEGORY_POLICY_COUNT;
285*c54f35caSApple OSS Distributions 	boolean_t get_default = FALSE;
286*c54f35caSApple OSS Distributions 	kern_return_t ret = KERN_FAILURE;
287*c54f35caSApple OSS Distributions 	char *args[] = { "sleep", "10", NULL };
288*c54f35caSApple OSS Distributions 	pid_t pid = 0;
289*c54f35caSApple OSS Distributions 
290*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
291*c54f35caSApple OSS Distributions 
292*c54f35caSApple OSS Distributions 	ret = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
293*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "spawning sleep 10");
294*c54f35caSApple OSS Distributions 
295*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_name_for_pid(mach_task_self(), pid,
296*c54f35caSApple OSS Distributions 	    &task_name), NULL);
297*c54f35caSApple OSS Distributions 	T_SETUPEND;
298*c54f35caSApple OSS Distributions 
299*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_ERROR(task_policy_get(task_name,
300*c54f35caSApple OSS Distributions 	    TASK_CATEGORY_POLICY,
301*c54f35caSApple OSS Distributions 	    (task_policy_t)role,
302*c54f35caSApple OSS Distributions 	    &count,
303*c54f35caSApple OSS Distributions 	    &get_default),
304*c54f35caSApple OSS Distributions 	    KERN_INVALID_ARGUMENT, NULL);
305*c54f35caSApple OSS Distributions 
306*c54f35caSApple OSS Distributions 	ret = kill(pid, SIGTERM);
307*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "killing sleep");
308*c54f35caSApple OSS Distributions }
309*c54f35caSApple OSS Distributions 
310*c54f35caSApple OSS Distributions #else /* ENTITLED */
311*c54f35caSApple OSS Distributions 
312*c54f35caSApple OSS Distributions T_DECL(task_policy_set_task_name_entitled, "task_policy_set with task name (entitled)", T_META_ASROOT(true), T_META_ASROOT(true))
313*c54f35caSApple OSS Distributions {
314*c54f35caSApple OSS Distributions 	struct task_qos_policy qosinfo = {
315*c54f35caSApple OSS Distributions 		.task_latency_qos_tier = LATENCY_QOS_TIER_0,
316*c54f35caSApple OSS Distributions 		.task_throughput_qos_tier = THROUGHPUT_QOS_TIER_0,
317*c54f35caSApple OSS Distributions 	};
318*c54f35caSApple OSS Distributions 	task_name_t task_name = TASK_NAME_NULL;
319*c54f35caSApple OSS Distributions 
320*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
321*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_name_for_pid(mach_task_self(), getpid(),
322*c54f35caSApple OSS Distributions 	    &task_name), NULL);
323*c54f35caSApple OSS Distributions 	T_SETUPEND;
324*c54f35caSApple OSS Distributions 
325*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_set(task_name,
326*c54f35caSApple OSS Distributions 	    TASK_BASE_QOS_POLICY,
327*c54f35caSApple OSS Distributions 	    (task_policy_t)&qosinfo,
328*c54f35caSApple OSS Distributions 	    TASK_QOS_POLICY_COUNT),
329*c54f35caSApple OSS Distributions 	    NULL);
330*c54f35caSApple OSS Distributions }
331*c54f35caSApple OSS Distributions 
332*c54f35caSApple OSS Distributions T_DECL(task_policy_set_task_entitled, "task_policy_set with task (entitled)")
333*c54f35caSApple OSS Distributions {
334*c54f35caSApple OSS Distributions 	struct task_qos_policy qosinfo = {
335*c54f35caSApple OSS Distributions 		.task_latency_qos_tier = LATENCY_QOS_TIER_0,
336*c54f35caSApple OSS Distributions 		.task_throughput_qos_tier = THROUGHPUT_QOS_TIER_0,
337*c54f35caSApple OSS Distributions 	};
338*c54f35caSApple OSS Distributions 
339*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_set(mach_task_self(),
340*c54f35caSApple OSS Distributions 	    TASK_BASE_QOS_POLICY,
341*c54f35caSApple OSS Distributions 	    (task_policy_t)&qosinfo,
342*c54f35caSApple OSS Distributions 	    TASK_QOS_POLICY_COUNT),
343*c54f35caSApple OSS Distributions 	    NULL);
344*c54f35caSApple OSS Distributions }
345*c54f35caSApple OSS Distributions 
346*c54f35caSApple OSS Distributions T_DECL(task_policy_set_inspect_entitled, "task_policy_set with task inspect (entitled)")
347*c54f35caSApple OSS Distributions {
348*c54f35caSApple OSS Distributions 	struct task_qos_policy qosinfo = {
349*c54f35caSApple OSS Distributions 		.task_latency_qos_tier = LATENCY_QOS_TIER_0,
350*c54f35caSApple OSS Distributions 		.task_throughput_qos_tier = THROUGHPUT_QOS_TIER_0,
351*c54f35caSApple OSS Distributions 	};
352*c54f35caSApple OSS Distributions 	task_inspect_t task_inspect = TASK_INSPECT_NULL;
353*c54f35caSApple OSS Distributions 
354*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
355*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_inspect_for_pid(mach_task_self(), getpid(),
356*c54f35caSApple OSS Distributions 	    &task_inspect), NULL);
357*c54f35caSApple OSS Distributions 	T_SETUPEND;
358*c54f35caSApple OSS Distributions 
359*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_set(task_inspect,
360*c54f35caSApple OSS Distributions 	    TASK_BASE_QOS_POLICY,
361*c54f35caSApple OSS Distributions 	    (task_policy_t)&qosinfo,
362*c54f35caSApple OSS Distributions 	    TASK_QOS_POLICY_COUNT),
363*c54f35caSApple OSS Distributions 	    NULL);
364*c54f35caSApple OSS Distributions }
365*c54f35caSApple OSS Distributions 
366*c54f35caSApple OSS Distributions T_DECL(task_policy_set_foreign_task_entitled, "task_policy_set for foreign task (entitled)", T_META_ASROOT(true))
367*c54f35caSApple OSS Distributions {
368*c54f35caSApple OSS Distributions 	struct task_qos_policy qosinfo = {
369*c54f35caSApple OSS Distributions 		.task_latency_qos_tier = LATENCY_QOS_TIER_0,
370*c54f35caSApple OSS Distributions 		.task_throughput_qos_tier = THROUGHPUT_QOS_TIER_0,
371*c54f35caSApple OSS Distributions 	};
372*c54f35caSApple OSS Distributions 	task_t task = TASK_NULL;
373*c54f35caSApple OSS Distributions 	kern_return_t ret = KERN_FAILURE;
374*c54f35caSApple OSS Distributions 	char *args[] = { "sleep", "10", NULL };
375*c54f35caSApple OSS Distributions 	pid_t pid = 0;
376*c54f35caSApple OSS Distributions 
377*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
378*c54f35caSApple OSS Distributions 
379*c54f35caSApple OSS Distributions 	ret = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
380*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "spawning sleep 10");
381*c54f35caSApple OSS Distributions 
382*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_for_pid(mach_task_self(), pid,
383*c54f35caSApple OSS Distributions 	    &task), NULL);
384*c54f35caSApple OSS Distributions 	T_SETUPEND;
385*c54f35caSApple OSS Distributions 
386*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_set(task,
387*c54f35caSApple OSS Distributions 	    TASK_BASE_QOS_POLICY,
388*c54f35caSApple OSS Distributions 	    (task_policy_t)&qosinfo,
389*c54f35caSApple OSS Distributions 	    TASK_QOS_POLICY_COUNT),
390*c54f35caSApple OSS Distributions 	    NULL);
391*c54f35caSApple OSS Distributions 
392*c54f35caSApple OSS Distributions 	ret = kill(pid, SIGTERM);
393*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "killing sleep");
394*c54f35caSApple OSS Distributions }
395*c54f35caSApple OSS Distributions 
396*c54f35caSApple OSS Distributions T_DECL(task_policy_set_foreign_task_name_entitled, "task_policy_set for foreign task name (entitled)", T_META_ASROOT(true), T_META_ASROOT(true))
397*c54f35caSApple OSS Distributions {
398*c54f35caSApple OSS Distributions 	struct task_qos_policy qosinfo = {
399*c54f35caSApple OSS Distributions 		.task_latency_qos_tier = LATENCY_QOS_TIER_0,
400*c54f35caSApple OSS Distributions 		.task_throughput_qos_tier = THROUGHPUT_QOS_TIER_0,
401*c54f35caSApple OSS Distributions 	};
402*c54f35caSApple OSS Distributions 	task_name_t task_name = TASK_NAME_NULL;
403*c54f35caSApple OSS Distributions 	kern_return_t ret = KERN_FAILURE;
404*c54f35caSApple OSS Distributions 	char *args[] = { "sleep", "10", NULL };
405*c54f35caSApple OSS Distributions 	pid_t pid = 0;
406*c54f35caSApple OSS Distributions 
407*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
408*c54f35caSApple OSS Distributions 
409*c54f35caSApple OSS Distributions 	ret = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
410*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "spawning sleep 10");
411*c54f35caSApple OSS Distributions 
412*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_name_for_pid(mach_task_self(), pid,
413*c54f35caSApple OSS Distributions 	    &task_name), NULL);
414*c54f35caSApple OSS Distributions 	T_SETUPEND;
415*c54f35caSApple OSS Distributions 
416*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_set(task_name,
417*c54f35caSApple OSS Distributions 	    TASK_BASE_QOS_POLICY,
418*c54f35caSApple OSS Distributions 	    (task_policy_t)&qosinfo,
419*c54f35caSApple OSS Distributions 	    TASK_QOS_POLICY_COUNT),
420*c54f35caSApple OSS Distributions 	    NULL);
421*c54f35caSApple OSS Distributions 
422*c54f35caSApple OSS Distributions 	ret = kill(pid, SIGTERM);
423*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "killing sleep");
424*c54f35caSApple OSS Distributions }
425*c54f35caSApple OSS Distributions 
426*c54f35caSApple OSS Distributions T_DECL(task_policy_set_foreign_task_inspect_entitled, "task_policy_set for foreign task inspect (entitled)", T_META_ASROOT(true))
427*c54f35caSApple OSS Distributions {
428*c54f35caSApple OSS Distributions 	struct task_qos_policy qosinfo = {
429*c54f35caSApple OSS Distributions 		.task_latency_qos_tier = LATENCY_QOS_TIER_0,
430*c54f35caSApple OSS Distributions 		.task_throughput_qos_tier = THROUGHPUT_QOS_TIER_0,
431*c54f35caSApple OSS Distributions 	};
432*c54f35caSApple OSS Distributions 	task_inspect_t task_inspect = TASK_INSPECT_NULL;
433*c54f35caSApple OSS Distributions 	kern_return_t ret = KERN_FAILURE;
434*c54f35caSApple OSS Distributions 	char *args[] = { "sleep", "10", NULL };
435*c54f35caSApple OSS Distributions 	pid_t pid = 0;
436*c54f35caSApple OSS Distributions 
437*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
438*c54f35caSApple OSS Distributions 
439*c54f35caSApple OSS Distributions 	ret = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
440*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "spawning sleep 10");
441*c54f35caSApple OSS Distributions 
442*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_inspect_for_pid(mach_task_self(), pid,
443*c54f35caSApple OSS Distributions 	    &task_inspect), NULL);
444*c54f35caSApple OSS Distributions 	T_SETUPEND;
445*c54f35caSApple OSS Distributions 
446*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_set(task_inspect,
447*c54f35caSApple OSS Distributions 	    TASK_BASE_QOS_POLICY,
448*c54f35caSApple OSS Distributions 	    (task_policy_t)&qosinfo,
449*c54f35caSApple OSS Distributions 	    TASK_QOS_POLICY_COUNT),
450*c54f35caSApple OSS Distributions 	    NULL);
451*c54f35caSApple OSS Distributions 
452*c54f35caSApple OSS Distributions 	ret = kill(pid, SIGTERM);
453*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "killing sleep");
454*c54f35caSApple OSS Distributions }
455*c54f35caSApple OSS Distributions 
456*c54f35caSApple OSS Distributions T_DECL(task_policy_get_name_entitled, "task_policy_get with task name (entitled)", T_META_ASROOT(true))
457*c54f35caSApple OSS Distributions {
458*c54f35caSApple OSS Distributions 	task_name_t task_name = TASK_NAME_NULL;
459*c54f35caSApple OSS Distributions 	struct task_category_policy role[TASK_CATEGORY_POLICY_COUNT];
460*c54f35caSApple OSS Distributions 	mach_msg_type_number_t count = TASK_CATEGORY_POLICY_COUNT;
461*c54f35caSApple OSS Distributions 	boolean_t get_default = FALSE;
462*c54f35caSApple OSS Distributions 
463*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
464*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_name_for_pid(mach_task_self(), getpid(),
465*c54f35caSApple OSS Distributions 	    &task_name), NULL);
466*c54f35caSApple OSS Distributions 	T_SETUPEND;
467*c54f35caSApple OSS Distributions 
468*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_get(task_name,
469*c54f35caSApple OSS Distributions 	    TASK_CATEGORY_POLICY,
470*c54f35caSApple OSS Distributions 	    (task_policy_t)role,
471*c54f35caSApple OSS Distributions 	    &count,
472*c54f35caSApple OSS Distributions 	    &get_default),
473*c54f35caSApple OSS Distributions 	    NULL);
474*c54f35caSApple OSS Distributions }
475*c54f35caSApple OSS Distributions 
476*c54f35caSApple OSS Distributions T_DECL(task_policy_get_task_entitled, "task_policy_get with task (entitled)")
477*c54f35caSApple OSS Distributions {
478*c54f35caSApple OSS Distributions 	struct task_category_policy role[TASK_CATEGORY_POLICY_COUNT];
479*c54f35caSApple OSS Distributions 	mach_msg_type_number_t count = TASK_CATEGORY_POLICY_COUNT;
480*c54f35caSApple OSS Distributions 	boolean_t get_default = FALSE;
481*c54f35caSApple OSS Distributions 
482*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_get(mach_task_self(),
483*c54f35caSApple OSS Distributions 	    TASK_CATEGORY_POLICY,
484*c54f35caSApple OSS Distributions 	    (task_policy_t)role,
485*c54f35caSApple OSS Distributions 	    &count,
486*c54f35caSApple OSS Distributions 	    &get_default),
487*c54f35caSApple OSS Distributions 	    NULL);
488*c54f35caSApple OSS Distributions }
489*c54f35caSApple OSS Distributions 
490*c54f35caSApple OSS Distributions T_DECL(task_policy_get_inspect_entitled, "task_policy_get with task inspect (entitled)")
491*c54f35caSApple OSS Distributions {
492*c54f35caSApple OSS Distributions 	task_inspect_t task_inspect = TASK_INSPECT_NULL;
493*c54f35caSApple OSS Distributions 	struct task_category_policy role[TASK_CATEGORY_POLICY_COUNT];
494*c54f35caSApple OSS Distributions 	mach_msg_type_number_t count = TASK_CATEGORY_POLICY_COUNT;
495*c54f35caSApple OSS Distributions 	boolean_t get_default = FALSE;
496*c54f35caSApple OSS Distributions 
497*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
498*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_inspect_for_pid(mach_task_self(), getpid(),
499*c54f35caSApple OSS Distributions 	    &task_inspect), NULL);
500*c54f35caSApple OSS Distributions 	T_SETUPEND;
501*c54f35caSApple OSS Distributions 
502*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_get(task_inspect,
503*c54f35caSApple OSS Distributions 	    TASK_CATEGORY_POLICY,
504*c54f35caSApple OSS Distributions 	    (task_policy_t)role,
505*c54f35caSApple OSS Distributions 	    &count,
506*c54f35caSApple OSS Distributions 	    &get_default),
507*c54f35caSApple OSS Distributions 	    NULL);
508*c54f35caSApple OSS Distributions }
509*c54f35caSApple OSS Distributions 
510*c54f35caSApple OSS Distributions T_DECL(task_policy_get_foreign_task_inspect_entitled, "task_policy_get for foreign task inspect (entitled)", T_META_ASROOT(true))
511*c54f35caSApple OSS Distributions {
512*c54f35caSApple OSS Distributions 	task_inspect_t task_inspect = TASK_INSPECT_NULL;
513*c54f35caSApple OSS Distributions 	struct task_category_policy role[TASK_CATEGORY_POLICY_COUNT];
514*c54f35caSApple OSS Distributions 	mach_msg_type_number_t count = TASK_CATEGORY_POLICY_COUNT;
515*c54f35caSApple OSS Distributions 	boolean_t get_default = FALSE;
516*c54f35caSApple OSS Distributions 	kern_return_t ret = KERN_FAILURE;
517*c54f35caSApple OSS Distributions 	char *args[] = { "sleep", "10", NULL };
518*c54f35caSApple OSS Distributions 	pid_t pid = 0;
519*c54f35caSApple OSS Distributions 
520*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
521*c54f35caSApple OSS Distributions 
522*c54f35caSApple OSS Distributions 	ret = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
523*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "spawning sleep 10");
524*c54f35caSApple OSS Distributions 
525*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_inspect_for_pid(mach_task_self(), pid,
526*c54f35caSApple OSS Distributions 	    &task_inspect), NULL);
527*c54f35caSApple OSS Distributions 	T_SETUPEND;
528*c54f35caSApple OSS Distributions 
529*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_get(task_inspect,
530*c54f35caSApple OSS Distributions 	    TASK_CATEGORY_POLICY,
531*c54f35caSApple OSS Distributions 	    (task_policy_t)role,
532*c54f35caSApple OSS Distributions 	    &count,
533*c54f35caSApple OSS Distributions 	    &get_default),
534*c54f35caSApple OSS Distributions 	    NULL);
535*c54f35caSApple OSS Distributions 
536*c54f35caSApple OSS Distributions 	ret = kill(pid, SIGTERM);
537*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "killing sleep");
538*c54f35caSApple OSS Distributions }
539*c54f35caSApple OSS Distributions 
540*c54f35caSApple OSS Distributions T_DECL(task_policy_get_foreign_task_entitled, "task_policy_get for foreign task (entitled)", T_META_ASROOT(true))
541*c54f35caSApple OSS Distributions {
542*c54f35caSApple OSS Distributions 	task_t task = TASK_NULL;
543*c54f35caSApple OSS Distributions 	struct task_category_policy role[TASK_CATEGORY_POLICY_COUNT];
544*c54f35caSApple OSS Distributions 	mach_msg_type_number_t count = TASK_CATEGORY_POLICY_COUNT;
545*c54f35caSApple OSS Distributions 	boolean_t get_default = FALSE;
546*c54f35caSApple OSS Distributions 	kern_return_t ret = KERN_FAILURE;
547*c54f35caSApple OSS Distributions 	char *args[] = { "sleep", "10", NULL };
548*c54f35caSApple OSS Distributions 	pid_t pid = 0;
549*c54f35caSApple OSS Distributions 
550*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
551*c54f35caSApple OSS Distributions 
552*c54f35caSApple OSS Distributions 	ret = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
553*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "spawning sleep 10");
554*c54f35caSApple OSS Distributions 
555*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_for_pid(mach_task_self(), pid,
556*c54f35caSApple OSS Distributions 	    &task), NULL);
557*c54f35caSApple OSS Distributions 	T_SETUPEND;
558*c54f35caSApple OSS Distributions 
559*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_get(task,
560*c54f35caSApple OSS Distributions 	    TASK_CATEGORY_POLICY,
561*c54f35caSApple OSS Distributions 	    (task_policy_t)role,
562*c54f35caSApple OSS Distributions 	    &count,
563*c54f35caSApple OSS Distributions 	    &get_default),
564*c54f35caSApple OSS Distributions 	    NULL);
565*c54f35caSApple OSS Distributions 
566*c54f35caSApple OSS Distributions 	ret = kill(pid, SIGTERM);
567*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "killing sleep");
568*c54f35caSApple OSS Distributions }
569*c54f35caSApple OSS Distributions 
570*c54f35caSApple OSS Distributions T_DECL(task_policy_get_foreign_task_name_entitled, "task_policy_get for foreign task name (entitled)", T_META_ASROOT(true))
571*c54f35caSApple OSS Distributions {
572*c54f35caSApple OSS Distributions 	task_name_t task_name = TASK_NAME_NULL;
573*c54f35caSApple OSS Distributions 	struct task_category_policy role[TASK_CATEGORY_POLICY_COUNT];
574*c54f35caSApple OSS Distributions 	mach_msg_type_number_t count = TASK_CATEGORY_POLICY_COUNT;
575*c54f35caSApple OSS Distributions 	boolean_t get_default = FALSE;
576*c54f35caSApple OSS Distributions 	kern_return_t ret = KERN_FAILURE;
577*c54f35caSApple OSS Distributions 	char *args[] = { "sleep", "10", NULL };
578*c54f35caSApple OSS Distributions 	pid_t pid = 0;
579*c54f35caSApple OSS Distributions 
580*c54f35caSApple OSS Distributions 	T_SETUPBEGIN;
581*c54f35caSApple OSS Distributions 
582*c54f35caSApple OSS Distributions 	ret = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
583*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "spawning sleep 10");
584*c54f35caSApple OSS Distributions 
585*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_name_for_pid(mach_task_self(), pid,
586*c54f35caSApple OSS Distributions 	    &task_name), NULL);
587*c54f35caSApple OSS Distributions 	T_SETUPEND;
588*c54f35caSApple OSS Distributions 
589*c54f35caSApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(task_policy_get(task_name,
590*c54f35caSApple OSS Distributions 	    TASK_CATEGORY_POLICY,
591*c54f35caSApple OSS Distributions 	    (task_policy_t)role,
592*c54f35caSApple OSS Distributions 	    &count,
593*c54f35caSApple OSS Distributions 	    &get_default),
594*c54f35caSApple OSS Distributions 	    NULL);
595*c54f35caSApple OSS Distributions 
596*c54f35caSApple OSS Distributions 	ret = kill(pid, SIGTERM);
597*c54f35caSApple OSS Distributions 	T_QUIET; T_ASSERT_POSIX_ZERO(ret, "killing sleep");
598*c54f35caSApple OSS Distributions }
599*c54f35caSApple OSS Distributions 
600*c54f35caSApple OSS Distributions #endif /* UNENTITLED */
601