xref: /xnu-12377.81.4/tests/regression_17272465.c (revision 043036a2b3718f7f0be807e2870f8f47d3fa0796)
1*043036a2SApple OSS Distributions #include <darwintest.h>
2*043036a2SApple OSS Distributions #include <stdio.h>
3*043036a2SApple OSS Distributions #include <mach/mach.h>
4*043036a2SApple OSS Distributions #include <mach/host_priv.h>
5*043036a2SApple OSS Distributions 
6*043036a2SApple OSS Distributions 
7*043036a2SApple OSS Distributions T_DECL(regression_17272465,
8*043036a2SApple OSS Distributions     "Test for host_set_special_port Mach port over-release, rdr: 17272465", T_META_CHECK_LEAKS(false))
9*043036a2SApple OSS Distributions {
10*043036a2SApple OSS Distributions 	kern_return_t kr;
11*043036a2SApple OSS Distributions 	mach_port_t port = MACH_PORT_NULL;
12*043036a2SApple OSS Distributions 
13*043036a2SApple OSS Distributions 	T_SETUPBEGIN;
14*043036a2SApple OSS Distributions 	T_QUIET;
15*043036a2SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &port), NULL);
16*043036a2SApple OSS Distributions 	T_QUIET;
17*043036a2SApple OSS Distributions 	T_ASSERT_MACH_SUCCESS(mach_port_insert_right(mach_task_self(), port, port, MACH_MSG_TYPE_MAKE_SEND), NULL);
18*043036a2SApple OSS Distributions 	T_SETUPEND;
19*043036a2SApple OSS Distributions 
20*043036a2SApple OSS Distributions 	(void)host_set_special_port(mach_host_self(), 30, port);
21*043036a2SApple OSS Distributions 	(void)host_set_special_port(mach_host_self(), 30, port);
22*043036a2SApple OSS Distributions 	(void)host_set_special_port(mach_host_self(), 30, port);
23*043036a2SApple OSS Distributions 
24*043036a2SApple OSS Distributions 	T_PASS("No panic occurred");
25*043036a2SApple OSS Distributions }
26