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