diff options
Diffstat (limited to 'runtime/test/xmem_test.cpp')
| -rw-r--r-- | runtime/test/xmem_test.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/runtime/test/xmem_test.cpp b/runtime/test/xmem_test.cpp index 127f11564..c40cae8fa 100644 --- a/runtime/test/xmem_test.cpp +++ b/runtime/test/xmem_test.cpp | |||
| @@ -83,10 +83,26 @@ void test_working_set(XMemGetWorkingSetStatisticsFn get_stats) { | |||
| 83 | const BOOL ok = get_stats(kMeasuredKind, stats); | 83 | const BOOL ok = get_stats(kMeasuredKind, stats); |
| 84 | check(ok != FALSE, "XMemGetWorkingSetStatistics(kind, 64-byte out) returns TRUE"); | 84 | check(ok != FALSE, "XMemGetWorkingSetStatistics(kind, 64-byte out) returns TRUE"); |
| 85 | 85 | ||
| 86 | uint64_t total_memory = 0; | ||
| 87 | std::memcpy(&total_memory, stats + 0, sizeof(total_memory)); | ||
| 88 | check(ok != FALSE && total_memory != 0, "XMemGetWorkingSetStatistics writes a non-zero total memory at +0"); | ||
| 89 | |||
| 90 | MEMORYSTATUSEX ms{sizeof(ms)}; | ||
| 91 | if (GlobalMemoryStatusEx(&ms) && ms.ullTotalPhys != 0) { | ||
| 92 | check(ok != FALSE && total_memory == ms.ullTotalPhys, | ||
| 93 | "XMemGetWorkingSetStatistics total memory (+0) matches GlobalMemoryStatusEx ullTotalPhys"); | ||
| 94 | } else { | ||
| 95 | check(ok != FALSE && total_memory == 12ULL * 1024 * 1024 * 1024, | ||
| 96 | "XMemGetWorkingSetStatistics total memory (+0) falls back to 12 GiB title limit"); | ||
| 97 | } | ||
| 98 | |||
| 86 | uint64_t working_set = 0; | 99 | uint64_t working_set = 0; |
| 87 | std::memcpy(&working_set, stats + 8, sizeof(working_set)); | 100 | std::memcpy(&working_set, stats + 8, sizeof(working_set)); |
| 88 | check(ok != FALSE && working_set != 0, "XMemGetWorkingSetStatistics writes a non-zero size at +8"); | 101 | check(ok != FALSE && working_set != 0, "XMemGetWorkingSetStatistics writes a non-zero size at +8"); |
| 89 | 102 | ||
| 103 | check(ok != FALSE && total_memory >= working_set, | ||
| 104 | "XMemGetWorkingSetStatistics total memory (+0) >= working set (+8)"); | ||
| 105 | |||
| 90 | bool tail_untouched = true; | 106 | bool tail_untouched = true; |
| 91 | for (size_t i = 16; i < sizeof(stats); ++i) { | 107 | for (size_t i = 16; i < sizeof(stats); ++i) { |
| 92 | if (stats[i] != 0xa5) { | 108 | if (stats[i] != 0xa5) { |