xref: /xnu-11417.121.6/tests/readonly_proc_tests.c (revision a1e26a70f38d1d7daa7b49b258e2f8538ad81650)
1*a1e26a70SApple OSS Distributions #include <darwintest.h>
2*a1e26a70SApple OSS Distributions #include <sys/sysctl.h>
3*a1e26a70SApple OSS Distributions 
4*a1e26a70SApple OSS Distributions T_GLOBAL_META(
5*a1e26a70SApple OSS Distributions 	T_META_NAMESPACE("xnu.bsd"),
6*a1e26a70SApple OSS Distributions 	T_META_RADAR_COMPONENT_NAME("xnu"),
7*a1e26a70SApple OSS Distributions 	T_META_RADAR_COMPONENT_VERSION("bsd"),
8*a1e26a70SApple OSS Distributions 	T_META_OWNER("chrisjd")
9*a1e26a70SApple OSS Distributions 	);
10*a1e26a70SApple OSS Distributions 
11*a1e26a70SApple OSS Distributions T_DECL(readonly_proc_tests, "invoke the read-only proc unit test",
12*a1e26a70SApple OSS Distributions     T_META_ASROOT(true), T_META_REQUIRES_SYSCTL_EQ("kern.development", 1))
13*a1e26a70SApple OSS Distributions {
14*a1e26a70SApple OSS Distributions 	int64_t result = 0;
15*a1e26a70SApple OSS Distributions 	int64_t value = 0;
16*a1e26a70SApple OSS Distributions 	size_t s = sizeof(value);
17*a1e26a70SApple OSS Distributions 	int ret;
18*a1e26a70SApple OSS Distributions 	ret = sysctlbyname("debug.test.readonly_proc_test", &result, &s, &value, sizeof(value));
19*a1e26a70SApple OSS Distributions 	T_ASSERT_POSIX_SUCCESS(ret, "sysctlbyname(\"debug.test.readonly_proc_test\"");
20*a1e26a70SApple OSS Distributions 	T_EXPECT_EQ(1ull, result, "run readonly proc test");
21*a1e26a70SApple OSS Distributions }
22