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