]>
Commit | Line | Data |
---|---|---|
c3c9b80d A |
1 | #include <sys/sysctl.h> |
2 | #include <time.h> | |
3 | ||
4 | #include <darwintest.h> | |
5 | ||
6 | /* | |
7 | * trying phys offsets from start of dram of: | |
8 | * watchOS 512Meg | |
9 | * macOS 3Gig | |
10 | * iOS,etc. 750Meg | |
11 | */ | |
12 | #if TARGET_OS_WATCH | |
13 | #define USEBOOTARG "bad_ram_pages=536870912 bad_static_mfree=1" | |
14 | #elif TARGET_OS_OSX | |
15 | #define USEBOOTARG "bad_ram_pages=3221225472 bad_static_mfree=1" | |
16 | #else | |
17 | #define USEBOOTARG "bad_ram_pages=786432000 bad_static_mfree=1" | |
18 | #endif | |
19 | ||
20 | T_DECL(retired_pages_test, | |
21 | "Test retiring pages at boot", | |
22 | T_META_NAMESPACE("xnu.vm"), | |
23 | T_META_BOOTARGS_SET(USEBOOTARG), | |
24 | T_META_ASROOT(true), | |
25 | T_META_CHECK_LEAKS(false)) | |
26 | { | |
27 | int err; | |
28 | unsigned int count = 0; | |
29 | size_t s = sizeof(count); | |
30 | ||
31 | #if !defined(__arm64__) || TARGET_OS_BRIDGE | |
32 | T_SKIP("No page retirement on x86, arm32 or bridgeOS kernels"); | |
33 | #endif | |
34 | /* | |
35 | * Get the number of pages retired from the kernel | |
36 | */ | |
37 | err = sysctlbyname("vm.retired_pages_count", &count, &s, NULL, 0); | |
38 | ||
39 | /* If the sysctl isn't supported, test succeeds */ | |
40 | if (err == ENOENT) { | |
41 | T_SKIP("sysctl vm.retired_pages_count not found, skipping test"); | |
42 | } | |
43 | T_ASSERT_POSIX_SUCCESS(err, "sysctl vm.retired_pages_count"); | |
44 | ||
45 | T_ASSERT_GT_INT(count, 0, "Expect retired pages"); | |
46 | } |