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