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-23 04:41:22 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-23 04:41:22 -0500
commite2ac2238fa5cb7ca23e653cce15fd5c1d004e0a7 (patch)
treef018a5ba2e68ee8659a278a3a525bcb3d7852eab /runtime/test/xmem_test.cpp
parent0e5ccb8c4ae01b82a52e031476dde1f0e6737621 (diff)
Runtime test clashes: typeless clears accept WARP's nearest-even tie (#521), three close-parity copies now match WARP, the source-size checks start from 300x200 again after ResizeTarget, one test_attribute_trace in xmem_test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/xmem_test.cpp')
-rw-r--r--runtime/test/xmem_test.cpp42
1 files changed, 0 insertions, 42 deletions
diff --git a/runtime/test/xmem_test.cpp b/runtime/test/xmem_test.cpp
index 4df6a4d57..bd38cab39 100644
--- a/runtime/test/xmem_test.cpp
+++ b/runtime/test/xmem_test.cpp
@@ -294,48 +294,6 @@ void test_title_virtual_alloc() {
294 } 294 }
295} 295}
296 296
297// gta6rt --trace: one "xmem_attributes" event per distinct raw attribute word and API, none with the trace off.
298void test_attribute_trace(XMemAllocFn alloc, XMemFreeFn free_mem) {
299 wchar_t temp[MAX_PATH];
300 GetTempPathW(MAX_PATH, temp);
301 const std::wstring path =
302 std::wstring(temp) + L"xmem_trace_test_" + std::to_wstring(GetCurrentProcessId()) + L".jsonl";
303 DeleteFileW(path.c_str());
304
305 void* untraced = alloc(64, 0x1111); // trace not open yet: nothing to write, nothing to crash
306 check(untraced != nullptr, "XMemAlloc with the trace off still allocates");
307 free_mem(untraced, 0x1111);
308
309 check(rt::startup_trace::open(path.c_str()), "open the startup trace file");
310 void* a = alloc(4096, 0x5e50000);
311 void* b = alloc(8192, 0x5e50000); // same word again: no second event
312 void* c = alloc(16, 0x99);
313 free_mem(a, 0x5e50000);
314 free_mem(b, 0x5e50000); // same word again: no second event
315 free_mem(c, 0x99);
316 free_mem(nullptr, 0x77); // a free-only word is recorded too
317 rt::startup_trace::close();
318
319 std::ifstream in(path);
320 std::stringstream text;
321 text << in.rdbuf();
322 const std::string log = text.str();
323 auto count = [&](const std::string& needle) {
324 int n = 0;
325 for (size_t at = log.find(needle); at != std::string::npos; at = log.find(needle, at + 1)) ++n;
326 return n;
327 };
328 check(count("\"kind\":\"xmem_attributes\"") == 5, "five events: two XMemAlloc words and three XMemFree words");
329 check(count("\"api\":\"XMemAlloc\",\"attributes\":\"0x5e50000\",\"size\":4096") == 1,
330 "XMemAlloc 0x5e50000 is recorded once, with the size of the first call");
331 check(count("\"api\":\"XMemAlloc\",\"attributes\":\"0x99\",\"size\":16") == 1, "XMemAlloc 0x99 is recorded once");
332 check(count("\"api\":\"XMemFree\",\"attributes\":\"0x5e50000\"") == 1, "XMemFree 0x5e50000 is recorded once");
333 check(count("\"api\":\"XMemFree\",\"attributes\":\"0x77\"") == 1, "XMemFree 0x77 is recorded");
334 check(count("\"attributes\":\"0x1111\"") == 0, "nothing was recorded while the trace was off");
335 check(count("\"caller\":\"") == 5, "every event names its caller");
336 DeleteFileW(path.c_str());
337}
338
339void print_result() { 297void print_result() {
340 if (g_failures == 0) { 298 if (g_failures == 0) {
341 std::printf("xmem_test: OK (%d checks)\n", g_checks); 299 std::printf("xmem_test: OK (%d checks)\n", g_checks);