xref: /xnu-10063.121.3/tests/vm/retired_pages.c (revision 2c2f96dc2b9a4408a43d3150ae9c105355ca3daa)
1 #include <sys/sysctl.h>
2 #include <time.h>
3 
4 #include <darwintest.h>
5 
6 T_GLOBAL_META(
7 	T_META_NAMESPACE("xnu.vm"),
8 	T_META_RADAR_COMPONENT_NAME("xnu"),
9 	T_META_RADAR_COMPONENT_VERSION("VM"));
10 
11 /*
12  * trying phys offsets from start of dram of:
13  * macOS 3Gig
14  */
15 #define USEBOOTARG "ecc_bad_pages=3221225472 bad_static_mfree=1"
16 
17 T_DECL(retired_pages_test,
18     "Test retiring pages at boot",
19     T_META_BOOTARGS_SET(USEBOOTARG),
20     T_META_ASROOT(true),
21     T_META_CHECK_LEAKS(false),
22     T_META_ENABLED(0))
23 {
24 	/* TODO: Joe will update/enable test in rdar://70008487 */
25 
26 	int err;
27 	unsigned int count = 0;
28 	size_t s = sizeof(count);
29 
30 	/*
31 	 * Get the number of pages retired from the kernel
32 	 */
33 	err = sysctlbyname("vm.retired_pages_count", &count, &s, NULL, 0);
34 
35 	/* If the sysctl isn't supported, test succeeds */
36 	if (err == ENOENT) {
37 		T_SKIP("sysctl vm.retired_pages_count not found, skipping test");
38 	}
39 	T_ASSERT_POSIX_SUCCESS(err, "sysctl vm.retired_pages_count");
40 
41 	T_ASSERT_GT_INT(count, 0, "Expect retired pages");
42 }
43