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