xref: /xnu-11417.121.6/tests/mach_service_port.c (revision a1e26a70f38d1d7daa7b49b258e2f8538ad81650)
1*a1e26a70SApple OSS Distributions #include <darwintest.h>
2*a1e26a70SApple OSS Distributions #include <servers/bootstrap.h>
3*a1e26a70SApple OSS Distributions #include <mach/mach.h>
4*a1e26a70SApple OSS Distributions #include <mach/message.h>
5*a1e26a70SApple OSS Distributions #include <stdlib.h>
6*a1e26a70SApple OSS Distributions #include <sys/sysctl.h>
7*a1e26a70SApple OSS Distributions #include <unistd.h>
8*a1e26a70SApple OSS Distributions #include <mach/port.h>
9*a1e26a70SApple OSS Distributions #include <mach/mach_port.h>
10*a1e26a70SApple OSS Distributions #include <stdint.h>
11*a1e26a70SApple OSS Distributions #include <stdio.h>
12*a1e26a70SApple OSS Distributions #include <unistd.h>
13*a1e26a70SApple OSS Distributions #include <pthread.h>
14*a1e26a70SApple OSS Distributions #include <err.h>
15*a1e26a70SApple OSS Distributions #include <sysexits.h>
16*a1e26a70SApple OSS Distributions 
17*a1e26a70SApple OSS Distributions #include "notifyServer.h"
18*a1e26a70SApple OSS Distributions 
19*a1e26a70SApple OSS Distributions T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true),
20*a1e26a70SApple OSS Distributions     T_META_NAMESPACE("xnu.ipc"),
21*a1e26a70SApple OSS Distributions     T_META_RADAR_COMPONENT_NAME("xnu"),
22*a1e26a70SApple OSS Distributions     T_META_RADAR_COMPONENT_VERSION("IPC"),
23*a1e26a70SApple OSS Distributions     T_META_TAG_VM_PREFERRED);
24*a1e26a70SApple OSS Distributions 
25*a1e26a70SApple OSS Distributions static mach_port_t service_port = MACH_PORT_NULL;
26*a1e26a70SApple OSS Distributions 
27*a1e26a70SApple OSS Distributions #define SP_CONTEXT (0x1803)
28*a1e26a70SApple OSS Distributions #define NEW_SP_CONTEXT (0x0318)
29*a1e26a70SApple OSS Distributions #define SERVICE_NAME "com.apple.testservice"
30*a1e26a70SApple OSS Distributions #define SERVICE_DOMAIN (1)
31*a1e26a70SApple OSS Distributions 
32*a1e26a70SApple OSS Distributions static inline kern_return_t
service_port_set_throttled(int is_throttled)33*a1e26a70SApple OSS Distributions service_port_set_throttled(int is_throttled)
34*a1e26a70SApple OSS Distributions {
35*a1e26a70SApple OSS Distributions 	return mach_port_set_attributes(mach_task_self(), service_port, MACH_PORT_SERVICE_THROTTLED, (mach_port_info_t)(&is_throttled),
36*a1e26a70SApple OSS Distributions 	           MACH_PORT_SERVICE_THROTTLED_COUNT);
37*a1e26a70SApple OSS Distributions }
38*a1e26a70SApple OSS Distributions 
39*a1e26a70SApple OSS Distributions static inline kern_return_t
service_port_get_throttled(int * is_throttled)40*a1e26a70SApple OSS Distributions service_port_get_throttled(int *is_throttled)
41*a1e26a70SApple OSS Distributions {
42*a1e26a70SApple OSS Distributions 	natural_t count = 0;
43*a1e26a70SApple OSS Distributions 	kern_return_t kr;
44*a1e26a70SApple OSS Distributions 
45*a1e26a70SApple OSS Distributions 	kr = mach_port_get_attributes(mach_task_self(), service_port, MACH_PORT_SERVICE_THROTTLED, (mach_port_info_t)(is_throttled), &count);
46*a1e26a70SApple OSS Distributions 	T_QUIET; T_ASSERT_EQ(count, MACH_PORT_SERVICE_THROTTLED_COUNT, NULL);
47*a1e26a70SApple OSS Distributions 
48*a1e26a70SApple OSS Distributions 	return kr;
49*a1e26a70SApple OSS Distributions }
50*a1e26a70SApple OSS Distributions 
51*a1e26a70SApple OSS Distributions T_DECL(mach_service_port, "Create a port with a service port label", T_META_CHECK_LEAKS(false)) {
52*a1e26a70SApple OSS Distributions 	mach_port_t connection_port;
53*a1e26a70SApple OSS Distributions 	mach_port_t notify_port;
54*a1e26a70SApple OSS Distributions 	mach_port_t previous;
55*a1e26a70SApple OSS Distributions 	uint64_t fpid = 0;
56*a1e26a70SApple OSS Distributions 	boolean_t is_throttled;
57*a1e26a70SApple OSS Distributions 
58*a1e26a70SApple OSS Distributions 	struct mach_service_port_info sp_info = {};
59*a1e26a70SApple OSS Distributions 
60*a1e26a70SApple OSS Distributions 	strcpy(sp_info.mspi_string_name, SERVICE_NAME);
61*a1e26a70SApple OSS Distributions 	sp_info.mspi_domain_type = (uint8_t)SERVICE_DOMAIN;
62*a1e26a70SApple OSS Distributions 	kern_return_t kr;
63*a1e26a70SApple OSS Distributions 
64*a1e26a70SApple OSS Distributions 	mach_port_options_t opts = {
65*a1e26a70SApple OSS Distributions 		.flags = MPO_SERVICE_PORT | MPO_INSERT_SEND_RIGHT | MPO_CONTEXT_AS_GUARD | MPO_STRICT,
66*a1e26a70SApple OSS Distributions 		.service_port_info = &sp_info,
67*a1e26a70SApple OSS Distributions 	};
68*a1e26a70SApple OSS Distributions 
69*a1e26a70SApple OSS Distributions 	kr = mach_port_construct(mach_task_self(), &opts, SP_CONTEXT, &service_port);
70*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_port_construct %u", service_port);
71*a1e26a70SApple OSS Distributions 
72*a1e26a70SApple OSS Distributions 	mach_port_options_t opts2 = {
73*a1e26a70SApple OSS Distributions 		.flags = MPO_CONNECTION_PORT,
74*a1e26a70SApple OSS Distributions 		.service_port_name = service_port,
75*a1e26a70SApple OSS Distributions 	};
76*a1e26a70SApple OSS Distributions 
77*a1e26a70SApple OSS Distributions 	kr = mach_port_construct(mach_task_self(), &opts2, 0x0, &connection_port);
78*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_port_construct %u", connection_port);
79*a1e26a70SApple OSS Distributions 
80*a1e26a70SApple OSS Distributions 	kr = mach_port_is_connection_for_service(mach_task_self(), connection_port, service_port, &fpid);
81*a1e26a70SApple OSS Distributions 	if (kr != KERN_SUCCESS || kr != KERN_NOT_SUPPORTED) {
82*a1e26a70SApple OSS Distributions 		T_LOG("mach_port_is_connection_for_service kr = %d, fpid = %llu", kr, fpid);
83*a1e26a70SApple OSS Distributions 	}
84*a1e26a70SApple OSS Distributions 
85*a1e26a70SApple OSS Distributions 	// notification port for the service port to come back on
86*a1e26a70SApple OSS Distributions 	kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &notify_port);
87*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_port_allocate notify_port");
88*a1e26a70SApple OSS Distributions 
89*a1e26a70SApple OSS Distributions 	kr = mach_port_insert_right(mach_task_self(), notify_port, notify_port, MACH_MSG_TYPE_MAKE_SEND);
90*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_port_insert_right notify_port");
91*a1e26a70SApple OSS Distributions 
92*a1e26a70SApple OSS Distributions 	T_LOG("service port: 0x%x, notify port: 0x%x\n", service_port, notify_port);
93*a1e26a70SApple OSS Distributions 
94*a1e26a70SApple OSS Distributions 	kr = mach_port_request_notification(mach_task_self(), service_port, MACH_NOTIFY_PORT_DESTROYED, 0, notify_port,
95*a1e26a70SApple OSS Distributions 	    MACH_MSG_TYPE_MAKE_SEND_ONCE, &previous);
96*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_port_request_notification service_port");
97*a1e26a70SApple OSS Distributions 	T_ASSERT_EQ(previous, MACH_PORT_NULL, "previous null");
98*a1e26a70SApple OSS Distributions 
99*a1e26a70SApple OSS Distributions 	/* Test port throttling flag */
100*a1e26a70SApple OSS Distributions 	kr = service_port_get_throttled(&is_throttled);
101*a1e26a70SApple OSS Distributions 	T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "get throttled flag value on port");
102*a1e26a70SApple OSS Distributions 	T_ASSERT_EQ(is_throttled, 0, "newly created service port is not throttled");
103*a1e26a70SApple OSS Distributions 
104*a1e26a70SApple OSS Distributions 	kr = service_port_set_throttled(1);
105*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "set throttled flag on port");
106*a1e26a70SApple OSS Distributions 
107*a1e26a70SApple OSS Distributions 	kr = service_port_get_throttled(&is_throttled);
108*a1e26a70SApple OSS Distributions 	T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "get throttled flag value on port");
109*a1e26a70SApple OSS Distributions 	T_ASSERT_EQ(is_throttled, 1, "port is throttled");
110*a1e26a70SApple OSS Distributions 
111*a1e26a70SApple OSS Distributions 	kr = service_port_set_throttled(0);
112*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "unset throttled flag on port");
113*a1e26a70SApple OSS Distributions 
114*a1e26a70SApple OSS Distributions 	kr = service_port_get_throttled(&is_throttled);
115*a1e26a70SApple OSS Distributions 	T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "get throttled flag value on port");
116*a1e26a70SApple OSS Distributions 	T_ASSERT_EQ(is_throttled, false, "port is no longer throttled");
117*a1e26a70SApple OSS Distributions 
118*a1e26a70SApple OSS Distributions 	/* Attempt to destroy port */
119*a1e26a70SApple OSS Distributions 	kr = mach_port_destruct(mach_task_self(), service_port, 0, SP_CONTEXT);
120*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_port_destruct service_port");
121*a1e26a70SApple OSS Distributions 
122*a1e26a70SApple OSS Distributions 	/*
123*a1e26a70SApple OSS Distributions 	 * Recover the service port because the port must have been destroyed and sent the notification by now
124*a1e26a70SApple OSS Distributions 	 */
125*a1e26a70SApple OSS Distributions 	kr = mach_msg_server_once(notify_server, MACH_MSG_SIZE_RELIABLE, notify_port, MACH_RCV_TIMEOUT);
126*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_msg_server_once notify_port");
127*a1e26a70SApple OSS Distributions 
128*a1e26a70SApple OSS Distributions 	T_LOG("done");
129*a1e26a70SApple OSS Distributions }
130*a1e26a70SApple OSS Distributions 
131*a1e26a70SApple OSS Distributions kern_return_t
do_mach_notify_port_destroyed(mach_port_t notify,mach_port_t name)132*a1e26a70SApple OSS Distributions do_mach_notify_port_destroyed(mach_port_t notify, mach_port_t name)
133*a1e26a70SApple OSS Distributions {
134*a1e26a70SApple OSS Distributions 	kern_return_t kr;
135*a1e26a70SApple OSS Distributions 
136*a1e26a70SApple OSS Distributions 	T_LOG("Received a service port destroyed notification notify = 0x%x name = 0x%x", notify, name);
137*a1e26a70SApple OSS Distributions 	if (name == MACH_PORT_NULL) {
138*a1e26a70SApple OSS Distributions 		T_FAIL("do_mach_notify_port_destroyed: MACH_PORT_NULL?");
139*a1e26a70SApple OSS Distributions 	}
140*a1e26a70SApple OSS Distributions 
141*a1e26a70SApple OSS Distributions 	if (name != service_port) {
142*a1e26a70SApple OSS Distributions 		T_FAIL("do_mach_notify_port_destroyed: name 0x%x != service_port: 0x%x", name, service_port);
143*a1e26a70SApple OSS Distributions 	}
144*a1e26a70SApple OSS Distributions 
145*a1e26a70SApple OSS Distributions 	struct mach_service_port_info sp_info = {};
146*a1e26a70SApple OSS Distributions 	kr = mach_port_get_service_port_info(mach_task_self(), service_port, &sp_info);
147*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_port_get_service_port_info");
148*a1e26a70SApple OSS Distributions 
149*a1e26a70SApple OSS Distributions 	if (strcmp(sp_info.mspi_string_name, SERVICE_NAME)) {
150*a1e26a70SApple OSS Distributions 		T_FAIL("Service port name = %s is incorrect", sp_info.mspi_string_name);
151*a1e26a70SApple OSS Distributions 	}
152*a1e26a70SApple OSS Distributions 	T_ASSERT_EQ(sp_info.mspi_domain_type, SERVICE_DOMAIN, "Service domain = %u", sp_info.mspi_domain_type);
153*a1e26a70SApple OSS Distributions 
154*a1e26a70SApple OSS Distributions 	mach_port_guard_info_t mpgi = {SP_CONTEXT};
155*a1e26a70SApple OSS Distributions 	kr = mach_port_assert_attributes(mach_task_self(), service_port, MACH_PORT_GUARD_INFO, (mach_port_info_t)&mpgi, MACH_PORT_GUARD_INFO_COUNT);
156*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_port_assert_attributes");
157*a1e26a70SApple OSS Distributions 
158*a1e26a70SApple OSS Distributions 	return KERN_SUCCESS;
159*a1e26a70SApple OSS Distributions }
160*a1e26a70SApple OSS Distributions 
161*a1e26a70SApple OSS Distributions kern_return_t
do_mach_notify_port_deleted(__unused mach_port_t notify,__unused mach_port_name_t name)162*a1e26a70SApple OSS Distributions do_mach_notify_port_deleted(__unused mach_port_t notify, __unused mach_port_name_t name)
163*a1e26a70SApple OSS Distributions {
164*a1e26a70SApple OSS Distributions 	return KERN_SUCCESS;
165*a1e26a70SApple OSS Distributions }
166*a1e26a70SApple OSS Distributions 
167*a1e26a70SApple OSS Distributions kern_return_t
do_mach_notify_no_senders(__unused mach_port_t notify,__unused mach_port_mscount_t mscount)168*a1e26a70SApple OSS Distributions do_mach_notify_no_senders(__unused mach_port_t notify, __unused mach_port_mscount_t mscount)
169*a1e26a70SApple OSS Distributions {
170*a1e26a70SApple OSS Distributions 	return KERN_SUCCESS;
171*a1e26a70SApple OSS Distributions }
172*a1e26a70SApple OSS Distributions 
173*a1e26a70SApple OSS Distributions kern_return_t
do_mach_notify_send_once(__unused mach_port_t notify)174*a1e26a70SApple OSS Distributions do_mach_notify_send_once(__unused mach_port_t notify)
175*a1e26a70SApple OSS Distributions {
176*a1e26a70SApple OSS Distributions 	return KERN_SUCCESS;
177*a1e26a70SApple OSS Distributions }
178*a1e26a70SApple OSS Distributions 
179*a1e26a70SApple OSS Distributions kern_return_t
do_mach_notify_dead_name(__unused mach_port_t notify,__unused mach_port_name_t name)180*a1e26a70SApple OSS Distributions do_mach_notify_dead_name(__unused mach_port_t notify, __unused mach_port_name_t name)
181*a1e26a70SApple OSS Distributions {
182*a1e26a70SApple OSS Distributions 	return KERN_SUCCESS;
183*a1e26a70SApple OSS Distributions }
184*a1e26a70SApple OSS Distributions 
185*a1e26a70SApple OSS Distributions #define SERVICE_NAME_2 "com.apple.testservice2"
186*a1e26a70SApple OSS Distributions #define SERVICE_DOMAIN_2 (2)
187*a1e26a70SApple OSS Distributions 
188*a1e26a70SApple OSS Distributions T_DECL(mach_fake_service_port, "Create a connection port with a fake service port", T_META_CHECK_LEAKS(false))
189*a1e26a70SApple OSS Distributions {
190*a1e26a70SApple OSS Distributions 	mach_port_t connection_port;
191*a1e26a70SApple OSS Distributions 	mach_port_t fake_service_port;
192*a1e26a70SApple OSS Distributions 	mach_port_t service_port_2;
193*a1e26a70SApple OSS Distributions 
194*a1e26a70SApple OSS Distributions 	kern_return_t kr;
195*a1e26a70SApple OSS Distributions 
196*a1e26a70SApple OSS Distributions 	struct mach_service_port_info sp_info = {};
197*a1e26a70SApple OSS Distributions 
198*a1e26a70SApple OSS Distributions 	strcpy(sp_info.mspi_string_name, SERVICE_NAME_2);
199*a1e26a70SApple OSS Distributions 	sp_info.mspi_domain_type = (uint8_t)SERVICE_DOMAIN_2;
200*a1e26a70SApple OSS Distributions 
201*a1e26a70SApple OSS Distributions 	mach_port_options_t opts = {
202*a1e26a70SApple OSS Distributions 		.flags = MPO_CONNECTION_PORT | MPO_SERVICE_PORT | MPO_INSERT_SEND_RIGHT | MPO_CONTEXT_AS_GUARD,
203*a1e26a70SApple OSS Distributions 		.service_port_info = &sp_info,
204*a1e26a70SApple OSS Distributions 	};
205*a1e26a70SApple OSS Distributions 
206*a1e26a70SApple OSS Distributions 	kr = mach_port_construct(mach_task_self(), &opts, SP_CONTEXT, &service_port_2);
207*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_ERROR(kr, KERN_INVALID_ARGUMENT, "mach_port_construct with extra flags %u", service_port_2);
208*a1e26a70SApple OSS Distributions 
209*a1e26a70SApple OSS Distributions 	mach_port_options_t opts2 = {
210*a1e26a70SApple OSS Distributions 		.flags = MPO_SERVICE_PORT | MPO_INSERT_SEND_RIGHT | MPO_CONTEXT_AS_GUARD,
211*a1e26a70SApple OSS Distributions 		.service_port_info = NULL,
212*a1e26a70SApple OSS Distributions 	};
213*a1e26a70SApple OSS Distributions 
214*a1e26a70SApple OSS Distributions 	kr = mach_port_construct(mach_task_self(), &opts2, SP_CONTEXT, &service_port_2);
215*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_ERROR(kr, KERN_INVALID_ARGUMENT, "mach_port_construct with missing service port info %u", service_port_2);
216*a1e26a70SApple OSS Distributions 
217*a1e26a70SApple OSS Distributions 	mach_port_options_t opts3 = {
218*a1e26a70SApple OSS Distributions 		.flags = MPO_INSERT_SEND_RIGHT | MPO_CONTEXT_AS_GUARD,
219*a1e26a70SApple OSS Distributions 	};
220*a1e26a70SApple OSS Distributions 
221*a1e26a70SApple OSS Distributions 	kr = mach_port_construct(mach_task_self(), &opts3, SP_CONTEXT, &fake_service_port);
222*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_port_construct with missing flag %u", fake_service_port);
223*a1e26a70SApple OSS Distributions 
224*a1e26a70SApple OSS Distributions 	struct mach_service_port_info sp_info3 = {};
225*a1e26a70SApple OSS Distributions 	kr = mach_port_get_service_port_info(mach_task_self(), fake_service_port, &sp_info3);
226*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_ERROR(kr, KERN_INVALID_CAPABILITY, "mach_port_get_service_port_info");
227*a1e26a70SApple OSS Distributions 
228*a1e26a70SApple OSS Distributions 	mach_port_options_t opts4 = {
229*a1e26a70SApple OSS Distributions 		.flags = MPO_CONNECTION_PORT,
230*a1e26a70SApple OSS Distributions 		.service_port_name = fake_service_port,
231*a1e26a70SApple OSS Distributions 	};
232*a1e26a70SApple OSS Distributions 
233*a1e26a70SApple OSS Distributions 	kr = mach_port_construct(mach_task_self(), &opts4, 0x0, &connection_port);
234*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_ERROR(kr, KERN_INVALID_CAPABILITY, "mach_port_construct connection port %u", connection_port);
235*a1e26a70SApple OSS Distributions 
236*a1e26a70SApple OSS Distributions 	T_LOG("done");
237*a1e26a70SApple OSS Distributions }
238*a1e26a70SApple OSS Distributions 
239*a1e26a70SApple OSS Distributions T_DECL(mach_dead_service_port, "Create a connection port with a dead service port", T_META_CHECK_LEAKS(false))
240*a1e26a70SApple OSS Distributions {
241*a1e26a70SApple OSS Distributions 	mach_port_t connection_port;
242*a1e26a70SApple OSS Distributions 	mach_port_t service_port_2;
243*a1e26a70SApple OSS Distributions 
244*a1e26a70SApple OSS Distributions 	kern_return_t kr;
245*a1e26a70SApple OSS Distributions 
246*a1e26a70SApple OSS Distributions 	struct mach_service_port_info sp_info = {};
247*a1e26a70SApple OSS Distributions 
248*a1e26a70SApple OSS Distributions 	strcpy(sp_info.mspi_string_name, SERVICE_NAME_2);
249*a1e26a70SApple OSS Distributions 	sp_info.mspi_domain_type = (uint8_t)SERVICE_DOMAIN_2;
250*a1e26a70SApple OSS Distributions 
251*a1e26a70SApple OSS Distributions 	mach_port_options_t opts = {
252*a1e26a70SApple OSS Distributions 		.flags = MPO_SERVICE_PORT | MPO_INSERT_SEND_RIGHT,
253*a1e26a70SApple OSS Distributions 		.service_port_info = &sp_info,
254*a1e26a70SApple OSS Distributions 	};
255*a1e26a70SApple OSS Distributions 
256*a1e26a70SApple OSS Distributions 	kr = mach_port_construct(mach_task_self(), &opts, 0, &service_port_2);
257*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_port_construct %u", service_port_2);
258*a1e26a70SApple OSS Distributions 
259*a1e26a70SApple OSS Distributions 	kr = mach_port_mod_refs(mach_task_self(), service_port_2, MACH_PORT_RIGHT_RECEIVE, -1);
260*a1e26a70SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(kr, "mach_port_mod_refs");
261*a1e26a70SApple OSS Distributions 
262*a1e26a70SApple OSS Distributions 	mach_port_options_t opts3 = {
263*a1e26a70SApple OSS Distributions 		.flags = MPO_CONNECTION_PORT,
264*a1e26a70SApple OSS Distributions 		.service_port_name = service_port_2,
265*a1e26a70SApple OSS Distributions 	};
266*a1e26a70SApple OSS Distributions 
267*a1e26a70SApple OSS Distributions 	kr = mach_port_construct(mach_task_self(), &opts3, 0x0, &connection_port);
268*a1e26a70SApple OSS Distributions 	T_LOG("mach_port_construct connection port kr = %d", kr);
269*a1e26a70SApple OSS Distributions 
270*a1e26a70SApple OSS Distributions 	if (kr == KERN_INVALID_RIGHT || kr == KERN_INVALID_NAME) {
271*a1e26a70SApple OSS Distributions 		T_PASS("Invalid service port");
272*a1e26a70SApple OSS Distributions 	} else {
273*a1e26a70SApple OSS Distributions 		T_FAIL("mach_port_construct incorrect return value");
274*a1e26a70SApple OSS Distributions 	}
275*a1e26a70SApple OSS Distributions 
276*a1e26a70SApple OSS Distributions 	T_LOG("done");
277*a1e26a70SApple OSS Distributions }
278