51c0d44065340fbacb9f52bacc3b35e0a1456811 braney Wed Sep 16 09:06:46 2026 -0700 sessionData: a test for the memory contract of sessionDataSaveTrashFile 133df533c4d made sessionDataSaveTrashFile return kent-allocated memory, since all three places that release its result do so through kent's own handler stack and it was handing back a pointer from the system malloc. Nothing failed at the time because the only program that reaches those release sites is hgSession, which installs no memory handler. That is the whole guard, and it was written down nowhere. sessionDataTester installs the careful handler itself and runs the function under it: it resolves a relative trash symlink, releases the result with freeMem, allocates again and checks the heap, then compares the allocated block count before and after so a leaked link target is caught too. The absolute symlink and the expired-file cases run alongside. Reverting either half of 133df533c4d fails the test; the plain-file branch that calls moveAndLink is not covered, since isTrashPath rejects a synthetic path with no trash dir configured. No database and no trash directory are needed, so the target runs ahead of spDbTest and hdbTest in hg/lib/tests. refs #38318 diff --git src/hg/lib/tests/expected/sessionDataTest src/hg/lib/tests/expected/sessionDataTest new file mode 100644 index 00000000000..abc666524f5 --- /dev/null +++ src/hg/lib/tests/expected/sessionDataTest @@ -0,0 +1,4 @@ +relative symlink: freed cleanly, nothing left behind +absolute symlink: freed cleanly, nothing left behind +missing file: returned NULL +passed