xref: /xnu-11417.140.69/tests/vm/retired_pages.c (revision 43a90889846e00bfb5cf1d255cdc0a701a1e05a4)
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     T_META_TAG_VM_PREFERRED)
24 {
25 	/* TODO: Joe will update/enable test in rdar://70008487 */
26 
27 	int err;
28 	unsigned int count = 0;
29 	size_t s = sizeof(count);
30 
31 	/*
32 	 * Get the number of pages retired from the kernel
33 	 */
34 	err = sysctlbyname("vm.retired_pages_count", &count, &s, NULL, 0);
35 
36 	/* If the sysctl isn't supported, test succeeds */
37 	if (err == ENOENT) {
38 		T_SKIP("sysctl vm.retired_pages_count not found, skipping test");
39 	}
40 	T_ASSERT_POSIX_SUCCESS(err, "sysctl vm.retired_pages_count");
41 
42 	T_ASSERT_GT_INT(count, 0, "Expect retired pages");
43 }
44