From 25cd4b9e49dc43a1b0a78d5cfab68ac8a5fb8dc1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 30 May 2026 03:40:33 +0000 Subject: [PATCH] Add tests/oom_dump.phpt for the memory_limit auto-dump The phpt suite exercised rdump_dump() and the return value of rdump_set_oom_dump(), but nothing actually triggered the memory_limit path, so the OOM auto-dump hook itself was untested. Add a test that spawns a child which exhausts memory_limit with rdump.oom_dump set, then asserts from the parent that the extension auto-wrote a well-formed RDUMP file plus its .done marker. List the new file in package.xml so pecl packaging picks it up. https://claude.ai/code/session_0173cJdvKHwRMbKuMLMRxuqD --- package.xml | 1 + tests/oom_dump.phpt | 57 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 tests/oom_dump.phpt diff --git a/package.xml b/package.xml index 5e194da..1c7f31b 100644 --- a/package.xml +++ b/package.xml @@ -46,6 +46,7 @@ Initial release. + diff --git a/tests/oom_dump.phpt b/tests/oom_dump.phpt new file mode 100644 index 0000000..d3aa266 --- /dev/null +++ b/tests/oom_dump.phpt @@ -0,0 +1,57 @@ +--TEST-- +rdump.oom_dump writes a well-formed RDUMP dump when memory_limit is exhausted +--SKIPIF-- + +--FILE-- +&1"; +$output = (string) shell_exec($cmd); + +// The child died on the memory_limit error... +var_dump(strpos($output, "Allowed memory size") !== false); + +// ...and the OOM hook wrote the dump without any rdump_dump() call. +var_dump(is_file($dump)); + +// The dump is a well-formed RDUMP file. +var_dump(file_get_contents($dump, false, null, 0, 8) === "RDUMP\0\0\0"); + +// The completion marker was written (rdump.oom_dump_marker=1). +var_dump(is_file($dump . ".done")); + +@unlink($dump); +@unlink($dump . ".done"); +@unlink($child); +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true)