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