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 "bad_ram_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(TARGET_OS_OSX && TARGET_CPU_ARM64)) 23 { 24 int err; 25 unsigned int count = 0; 26 size_t s = sizeof(count); 27 28 /* 29 * Get the number of pages retired from the kernel 30 */ 31 err = sysctlbyname("vm.retired_pages_count", &count, &s, NULL, 0); 32 33 /* If the sysctl isn't supported, test succeeds */ 34 if (err == ENOENT) { 35 T_SKIP("sysctl vm.retired_pages_count not found, skipping test"); 36 } 37 T_ASSERT_POSIX_SUCCESS(err, "sysctl vm.retired_pages_count"); 38 39 T_ASSERT_GT_INT(count, 0, "Expect retired pages"); 40 } 41