1 #include <darwintest.h>
2 #include <mach/mach.h>
3 #include <dlfcn.h>
4 #include <dlfcn_private.h>
5 #include <mach-o/dyld.h>
6 #include <dispatch/dispatch.h>
7 
8 T_GLOBAL_META(
9 	T_META_NAMESPACE("xnu.ipc"),
10 	T_META_RADAR_COMPONENT_NAME("xnu"),
11 	T_META_RADAR_COMPONENT_VERSION("IPC"),
12 	T_META_RUN_CONCURRENTLY(TRUE));
13 
14 T_DECL(task_dyld_process_info_notify_register,
15     "check that task_dyld_process_info_notify_register works")
16 {
17 	mach_port_name_t port = MACH_PORT_NULL;
18 	dispatch_source_t ds;
19 
20 	T_ASSERT_MACH_SUCCESS(mach_port_allocate(mach_task_self(),
21 	    MACH_PORT_RIGHT_RECEIVE, &port), "allocate notif port");
22 
23 	ds = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, port, 0,
24 	    dispatch_get_global_queue(0, 0));
25 	dispatch_source_set_event_handler(ds, ^{
26 		T_PASS("received a message for dlopen!");
27 		T_END;
28 	});
29 	dispatch_activate(ds);
30 
31 	T_ASSERT_MACH_SUCCESS(task_dyld_process_info_notify_register(mach_task_self(), port),
32 	    "register dyld notification");
33 
34 	dlopen("/usr/lib/swift/libswiftRemoteMirror.dylib", RTLD_LAZY);
35 }
36