From 7cb29d460b1ac1f892b775416f31e940f8dd087d Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Wed, 16 Sep 2026 20:33:38 -0400 Subject: [PATCH] [Fix, Test] (MG_Test/Wire): empty the log before each forked child and read it whole - the library truncates its log per process, so a case that forks three times to drive one refusal through the encoder, the decoder and the sink read the second and third child's diagnostic from an offset past the end and saw nothing --- MobileGL/MG_Test/Wire/PipeWireCodecTest.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/MobileGL/MG_Test/Wire/PipeWireCodecTest.cpp b/MobileGL/MG_Test/Wire/PipeWireCodecTest.cpp index 389d5d2c..aaa95ff4 100644 --- a/MobileGL/MG_Test/Wire/PipeWireCodecTest.cpp +++ b/MobileGL/MG_Test/Wire/PipeWireCodecTest.cpp @@ -366,10 +366,19 @@ namespace { // Runs `body` in a forked child. The child must not use gtest assertions; it _exit(0)s // when `body` returns, so a body expected to die must be ASSERTED dead by the parent // (WIFSIGNALED), never assumed. + // + // THE LOG IS EMPTIED FIRST, AND READ WHOLE. The library TRUNCATES its log file the first + // time a process writes to it, so a child's diagnostic is not an append to what the parent + // already holds. Reading the delta (the file minus the parent's length before the fork) + // works for one child and silently reads NOTHING for the second: the file the second child + // truncated is shorter than the offset the delta slices from. That is how P5b's user-index + // span cases - one refusal driven through the encoder, the forged decoder and the sink, so + // no layer leans on the one before it - passed their first side and lost the diagnostic of + // the other two. template ChildResult RunInChild(Body body) { ChildResult result; - const std::string before = ReadLog(); + { std::ofstream empty(g_logPath, std::ios::binary | std::ios::trunc); } std::fflush(nullptr); const pid_t pid = ::fork(); if (pid < 0) return result; @@ -380,7 +389,7 @@ namespace { int status = 0; if (::waitpid(pid, &status, 0) != pid) return result; result.Status = status; - result.Log = ReadLog().substr(before.size()); + result.Log = ReadLog(); return result; }