upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/xmem_test.cpp
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 17:01:52 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 17:01:52 -0500
commitcf82fc26fd0b013638833b16bd5507d3cd2de42a (patch)
tree102510b93ffc1f82099bca0a95cec728a4021d15 /runtime/test/xmem_test.cpp
parentf38f5fdeb7b038eb0640ae739c2b47a07333f3ec (diff)
parentc2ac1ea34f58b94419fcc4943a6c62754b95d270 (diff)
Merge pull request #3401 from 0xTehuti
Diffstat (limited to 'runtime/test/xmem_test.cpp')
-rw-r--r--runtime/test/xmem_test.cpp16
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) {