1 #include <darwintest.h>
2 #include <mach/host_priv.h>
4 #include <mach/mach_types.h>
5 #include <mach/processor_set.h>
7 #include <sys/sysctl.h>
9 #include <mach-o/dyld.h>
10 #include <mach-o/dyld_images.h>
11 #include <sys/types.h>
15 T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
23 read(pipefd
[0], &exit
, sizeof(int));
24 T_QUIET
; T_EXPECT_EQ_INT(exit
, 1, "exit");
28 T_DECL(task_info_28439149
, "ensure that task_info has the correct permission",
29 T_META_CHECK_LEAKS(false), T_META_ASROOT(true))
33 T_QUIET
; T_ASSERT_POSIX_SUCCESS(pipe(pipefd
), "pipe");
36 T_QUIET
; T_ASSERT_POSIX_SUCCESS(pid
, "fork");
46 mach_msg_type_number_t count
;
47 struct task_basic_info_64 ti
;
48 task_dyld_info_data_t di
;
50 task_t self
= mach_task_self();
55 T_EXPECT_MACH_SUCCESS(task_for_pid(self
, pid
, &other
), NULL
);
56 T_EXPECT_MACH_SUCCESS(task_name_for_pid(self
, pid
, &other_name
), NULL
);
58 count
= TASK_BASIC_INFO_64_COUNT
;
59 T_EXPECT_MACH_SUCCESS(task_info(self
, TASK_BASIC_INFO_64
, (task_info_t
)&ti
,
60 &count
), "task_info(self, TASK_BASIC_INFO_64 ...)");
61 count
= TASK_BASIC_INFO_64_COUNT
;
62 T_EXPECT_MACH_SUCCESS(task_info(other
, TASK_BASIC_INFO_64
, (task_info_t
)&ti
,
63 &count
), "task_info(other_name, TASK_BASIC_INFO_64 ...)");
64 count
= TASK_BASIC_INFO_64_COUNT
;
65 T_EXPECT_MACH_SUCCESS(task_info(other_name
, TASK_BASIC_INFO_64
, (task_info_t
)&ti
,
66 &count
), "task_info(other_name, TASK_BASIC_INFO_64 ...)");
69 count
= TASK_DYLD_INFO_COUNT
;
70 T_EXPECT_MACH_SUCCESS(task_info(self
, TASK_DYLD_INFO
, (task_info_t
)&di
,
71 &count
), "task_info(self, TASK_DYLD_INFO ...)");
72 count
= TASK_DYLD_INFO_COUNT
;
73 T_EXPECT_MACH_SUCCESS(task_info(other
, TASK_DYLD_INFO
, (task_info_t
)&di
,
74 &count
), "task_info(other_name, TASK_DYLD_INFO ...)");
75 count
= TASK_DYLD_INFO_COUNT
;
76 ret
= task_info(other_name
, TASK_DYLD_INFO
, (task_info_t
)&di
, &count
);
77 T_EXPECT_EQ_INT(ret
, KERN_INVALID_ARGUMENT
, "task info TASK_DYLD_INFO should fail with mach_port_name");
80 write(pipefd
[1], &exit
, sizeof(int));