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