1*94d3b452SApple OSS Distributions #include <stdio.h> 2*94d3b452SApple OSS Distributions #include <errno.h> 3*94d3b452SApple OSS Distributions #include <string.h> 4*94d3b452SApple OSS Distributions #include <unistd.h> 5*94d3b452SApple OSS Distributions #include <mach/mach.h> 6*94d3b452SApple OSS Distributions #include <mach/mach_types.h> 7*94d3b452SApple OSS Distributions #include <darwintest.h> 8*94d3b452SApple OSS Distributions #include <darwintest_utils.h> 9*94d3b452SApple OSS Distributions 10*94d3b452SApple OSS Distributions T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true)); 11*94d3b452SApple OSS Distributions 12*94d3b452SApple OSS Distributions T_DECL(debug_control_port_for_pid_success, 13*94d3b452SApple OSS Distributions "Verify that with debug_port entitlement you can call debug_control_port_for_pid", 14*94d3b452SApple OSS Distributions T_META_ASROOT(true), T_META_CHECK_LEAKS(false)) 15*94d3b452SApple OSS Distributions { 16*94d3b452SApple OSS Distributions if (geteuid() != 0) { 17*94d3b452SApple OSS Distributions T_SKIP("test requires root privileges to run."); 18*94d3b452SApple OSS Distributions } 19*94d3b452SApple OSS Distributions 20*94d3b452SApple OSS Distributions mach_port_t port = MACH_PORT_NULL; 21*94d3b452SApple OSS Distributions T_ASSERT_MACH_SUCCESS(debug_control_port_for_pid(mach_task_self(), 1, &port), "debug_control_port_for_pid"); 22*94d3b452SApple OSS Distributions T_EXPECT_NE(port, MACH_PORT_NULL, "debug_port"); 23*94d3b452SApple OSS Distributions mach_port_deallocate(mach_task_self(), port); 24*94d3b452SApple OSS Distributions } 25