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