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