]>
git.saurik.com Git - apple/xnu.git/blob - tests/mach_port_insert_right.c
3 #include <mach/message.h>
4 #include <darwintest.h>
6 T_DECL(mach_port_insert_right
,"insert send right for an existing right", T_META_CHECK_LEAKS(false))
8 mach_port_t port
= MACH_PORT_NULL
;
9 mach_port_t port2
= MACH_PORT_NULL
;
12 mach_port_t task
= mach_task_self();
14 retval
= mach_port_allocate(task
, MACH_PORT_RIGHT_RECEIVE
, &port
);
15 T_ASSERT_MACH_SUCCESS(retval
, "allocate a port=[%d]", port
);
17 mach_port_name_t name
= 123;
19 retval
= mach_port_insert_right(task
, name
, port
, MACH_MSG_TYPE_MAKE_SEND
);
20 T_ASSERT_MACH_ERROR(retval
, KERN_FAILURE
, "insert a send right for port=[%d] with name=[%d]", port
, name
);
23 retval
= mach_port_insert_right(task
, name
, port
, MACH_MSG_TYPE_MAKE_SEND
);
24 T_ASSERT_MACH_ERROR(retval
, KERN_FAILURE
, "insert a send right for port=[%d] with name=[%d]", port
, name
);
26 retval
= mach_port_allocate(task
, MACH_PORT_RIGHT_RECEIVE
, &port2
);
27 T_ASSERT_MACH_SUCCESS(retval
, "allocate a port=[%d]", port2
);
30 retval
= mach_port_insert_right(task
, name
, port2
, MACH_MSG_TYPE_MAKE_SEND
);
31 T_ASSERT_MACH_ERROR(retval
, KERN_RIGHT_EXISTS
, "insert a send right for port=[%d] with name=[%d]", port2
, name
);