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