[MG_Util, MG_Test, MG_IntegrationTest, CI] (P6): one log per role, and every reader moved with it

The spawn work had the two roles append to one MOBILEGL_LOG_FILE_PATH under
O_APPEND. It was correct - two processes at one offset would corrupt the file,
O_APPEND made each write atomic - but it put two sessions' lines in one place
and made every per-side assertion a search. This splits the sink: the client
role writes <base>.client.log and the server role writes <base>.server.log.

THE BASE NAME NAMES NO FILE ANY MORE, AND THAT IS THE POINT. Leaving the
client at the old unsuffixed path would have been the compatible choice and the
wrong one: a reader that was not updated would go on finding a file, go on
passing, and go on seeing only half the session - and a refusal census that
reports a confident zero for the half it cannot see is worse than one that
fails. With both names moved, an un-updated reader gets "file not found" and
says so. There were 34 such readers; every one is moved here.

THE ROLE IS PER-THREAD, not per-process, because under inproc both roles are
threads of one process. Log.cpp keys the sink on a thread-local role: the apply
thread declares itself server (ServerLoop.cpp), a spawned image is server for
its whole life (MOBILEGL_IPC_ROLE=server, read once), and everything else is
the client. The naming rule (RoleLogPath) and the two whole-log operations
(ReadRoleLogs / TruncateRoleLogs) are EXPORTED from the library, so no reader
reimplements the derivation - a second copy is the copy that falls behind.

Readers, by how they read:
 - unit mains set MOBILEGL_LOG_FILE_PATH and read a role file: they keep the
   base in the env and derive the client path from the library helper.
 - the death-test child runners (ReadLog) now concatenate BOTH roles: a death
   test asserts the CHILD said something, and the applier's refusals - the very
   diagnostics these check - are written under the server role.
 - the offset-based Emit readers derive the client path once after setenv.
 - PipeStatsWindow reads both, because draws/vbs increment in the backend's
   PrepareForDraw - the apply thread, the server role - so the summary line is
   in the server file even under inproc.
 - run_trace_case.cmake's split census reads both files; the client keeps the
   transport markers.
 - split_log_paths.py (and its self-test, and the control stub) derive both
   role files from the declared base.
 - the Android script pulls both role files off the device and concatenates
   them, so every downstream check is unchanged - and it judges a role file by
   CONTENT, because `run-as test -f` through `exec-out` returned 0 for a missing
   file on the device and `exec-out` folds cat's own not-found line into stdout.
   The monolith arm legitimately has no server file, and that is a silent skip
   rather than a one-line server log.

Guarded so a pull build is untouched: RoleLogPath and the role sink are wholly
inside MOBILEGL_BUILD_DISAGGREGATED; a non-disaggregated build writes the base
path exactly as before. G1 re-measured - 0 symbol diff, .text unchanged at
0xa52203.

Verified on device 2f7cbe2e: monolith writes only the client log (no phantom
server log), inproc and spawn each write both and pass their transport proofs
(spawn: server role in pid 16125). Unit 2353 (one pre-existing environmental
failure), integration-split 186/186, integration-spawn 102/102, retrace 6/6,
control smoke 12/12, split-log-paths self-test 9/9.
This commit is contained in:
2026-09-21 21:26:05 -04:00
parent 15f5b54bbd
commit 5fb54f03fe
38 changed files with 524 additions and 146 deletions
@@ -30,6 +30,7 @@
// pull and the push trees.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <filesystem>
#include <fstream>
@@ -776,6 +777,13 @@ int main(int argc, char** argv) {
#else
setenv("MOBILEGL_LOG_FILE_PATH", g_logPath.c_str(), 1);
#endif
// P6: MOBILEGL_LOG_FILE_PATH is a BASE NAME and the library writes one file per role. These
// cases read the log by OFFSET (a single growing file), and every marker they assert is
// raised by the encoder on THIS thread - the client role. So g_logPath, which is the read
// path from here on, becomes the client-derived name; the env keeps the base. The rule is
// the library's own, not a copy.
g_logPath = MobileGL::MG_Util::Debug::RoleLogPath(g_logPath.c_str(),
MobileGL::MG_Util::Debug::LogRole::Client);
#if MOBILEGL_PIPE_PUSH
MobileGL::Initialize();
#endif
+5 -4
View File
@@ -27,6 +27,7 @@
// logs.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <cctype>
#include <cstdio>
@@ -65,10 +66,10 @@ namespace {
std::string g_logPath;
std::string ReadLog() {
std::ifstream in(g_logPath, std::ios::binary);
std::ostringstream ss;
ss << in.rdbuf();
return ss.str();
// BOTH ROLES' LOGS (P6). A death test asserts that the CHILD said something; which
// role's thread said it is not what these cases are about, and refusals raised on the
// apply thread are written under the SERVER role by construction.
return MobileGL::MG_Util::Debug::ReadRoleLogs(g_logPath.c_str());
}
long ProcessId() {
@@ -37,6 +37,7 @@
// stays name-for-name identical between the pull and the push trees.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <filesystem>
#include <fstream>
@@ -92,10 +93,10 @@ namespace {
#if MOBILEGL_PIPE_PUSH
std::string ReadLog() {
std::ifstream in(g_logPath, std::ios::binary);
std::ostringstream ss;
ss << in.rdbuf();
return ss.str();
// BOTH ROLES' LOGS (P6). A death test asserts that the CHILD said something; which
// role's thread said it is not what these cases are about, and refusals raised on the
// apply thread are written under the SERVER role by construction.
return MobileGL::MG_Util::Debug::ReadRoleLogs(g_logPath.c_str());
}
// A fresh applier per case, BOTH SCOPES, and it takes both because there are two: a reset
+8
View File
@@ -24,6 +24,7 @@
// pull and the push trees.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <filesystem>
#include <fstream>
@@ -698,6 +699,13 @@ int main(int argc, char** argv) {
#else
setenv("MOBILEGL_LOG_FILE_PATH", g_logPath.c_str(), 1);
#endif
// P6: MOBILEGL_LOG_FILE_PATH is a BASE NAME and the library writes one file per role. These
// cases read the log by OFFSET (a single growing file), and every marker they assert is
// raised by the encoder on THIS thread - the client role. So g_logPath, which is the read
// path from here on, becomes the client-derived name; the env keeps the base. The rule is
// the library's own, not a copy.
g_logPath = MobileGL::MG_Util::Debug::RoleLogPath(g_logPath.c_str(),
MobileGL::MG_Util::Debug::LogRole::Client);
#if MOBILEGL_PIPE_PUSH
MobileGL::Initialize();
#endif
+5 -4
View File
@@ -18,6 +18,7 @@
// line land in this process's read. A forked child inherits its parent's path on purpose.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <cstdio>
#include <cstdlib>
@@ -53,10 +54,10 @@ namespace {
std::string g_logPath;
std::string ReadLog() {
std::ifstream in(g_logPath, std::ios::binary);
std::ostringstream ss;
ss << in.rdbuf();
return ss.str();
// BOTH ROLES' LOGS (P6). A death test asserts that the CHILD said something; which
// role's thread said it is not what these cases are about, and refusals raised on the
// apply thread are written under the SERVER role by construction.
return MobileGL::MG_Util::Debug::ReadRoleLogs(g_logPath.c_str());
}
long ProcessId() {
@@ -29,6 +29,7 @@
// pull and the push trees.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <filesystem>
#include <fstream>
@@ -1017,6 +1018,13 @@ int main(int argc, char** argv) {
#else
setenv("MOBILEGL_LOG_FILE_PATH", g_logPath.c_str(), 1);
#endif
// P6: MOBILEGL_LOG_FILE_PATH is a BASE NAME and the library writes one file per role. These
// cases read the log by OFFSET (a single growing file), and every marker they assert is
// raised by the encoder on THIS thread - the client role. So g_logPath, which is the read
// path from here on, becomes the client-derived name; the env keeps the base. The rule is
// the library's own, not a copy.
g_logPath = MobileGL::MG_Util::Debug::RoleLogPath(g_logPath.c_str(),
MobileGL::MG_Util::Debug::LogRole::Client);
#if MOBILEGL_PIPE_PUSH
MobileGL::Initialize();
#endif
@@ -36,6 +36,7 @@
// rather than a vanishing test - and the four names are the SAME four in every build, which
// is what keeps `ctest -N` name-for-name identical between the pull and the push tree.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <cstdio>
#include <cstring>
@@ -79,10 +80,10 @@ namespace {
std::string g_logPath;
std::string ReadLog() {
std::ifstream in(g_logPath, std::ios::binary);
std::ostringstream ss;
ss << in.rdbuf();
return ss.str();
// BOTH ROLES' LOGS (P6). A death test asserts that the CHILD said something; which
// role's thread said it is not what these cases are about, and refusals raised on the
// apply thread are written under the SERVER role by construction.
return MobileGL::MG_Util::Debug::ReadRoleLogs(g_logPath.c_str());
}
long ProcessId() {
+5 -4
View File
@@ -34,6 +34,7 @@
// between the pull and the push trees.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <cstring>
#include <filesystem>
@@ -95,10 +96,10 @@ namespace {
}
std::string ReadLog() {
std::ifstream in(g_logPath, std::ios::binary);
std::ostringstream ss;
ss << in.rdbuf();
return ss.str();
// BOTH ROLES' LOGS (P6). A death test asserts that the CHILD said something; which
// role's thread said it is not what these cases are about, and refusals raised on the
// apply thread are written under the SERVER role by construction.
return MobileGL::MG_Util::Debug::ReadRoleLogs(g_logPath.c_str());
}
// The op table is INSTALLED BY A BACKEND, at its own bring-up, and uninstalled at its
@@ -33,6 +33,7 @@
// pull and the push trees.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <filesystem>
#include <fstream>
@@ -1150,6 +1151,13 @@ int main(int argc, char** argv) {
#else
setenv("MOBILEGL_LOG_FILE_PATH", g_logPath.c_str(), 1);
#endif
// P6: MOBILEGL_LOG_FILE_PATH is a BASE NAME and the library writes one file per role. These
// cases read the log by OFFSET (a single growing file), and every marker they assert is
// raised by the encoder on THIS thread - the client role. So g_logPath, which is the read
// path from here on, becomes the client-derived name; the env keeps the base. The rule is
// the library's own, not a copy.
g_logPath = MobileGL::MG_Util::Debug::RoleLogPath(g_logPath.c_str(),
MobileGL::MG_Util::Debug::LogRole::Client);
#if MOBILEGL_PIPE_PUSH
// ONE process-wide context for the whole suite, because half these cases need a really
// linked program and glslang lives behind this call. Each case uses GL names of its own.
@@ -29,6 +29,7 @@
// `ctest -N` stays name-for-name identical between the pull and the push trees (G2/G14).
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <filesystem>
#include <fstream>
@@ -498,6 +499,13 @@ int main(int argc, char** argv) {
#else
setenv("MOBILEGL_LOG_FILE_PATH", g_logPath.c_str(), 1);
#endif
// P6: MOBILEGL_LOG_FILE_PATH is a BASE NAME and the library writes one file per role. These
// cases read the log by OFFSET (a single growing file), and every marker they assert is
// raised by the encoder on THIS thread - the client role. So g_logPath, which is the read
// path from here on, becomes the client-derived name; the env keeps the base. The rule is
// the library's own, not a copy.
g_logPath = MobileGL::MG_Util::Debug::RoleLogPath(g_logPath.c_str(),
MobileGL::MG_Util::Debug::LogRole::Client);
#if MOBILEGL_PIPE_PUSH
MobileGL::Initialize();
#endif
+5 -4
View File
@@ -37,6 +37,7 @@
// stays name-for-name identical between the pull and the push trees.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <filesystem>
#include <fstream>
@@ -99,10 +100,10 @@ namespace {
#if MOBILEGL_PIPE_PUSH
std::string ReadLog() {
std::ifstream in(g_logPath, std::ios::binary);
std::ostringstream ss;
ss << in.rdbuf();
return ss.str();
// BOTH ROLES' LOGS (P6). A death test asserts that the CHILD said something; which
// role's thread said it is not what these cases are about, and refusals raised on the
// apply thread are written under the SERVER role by construction.
return MobileGL::MG_Util::Debug::ReadRoleLogs(g_logPath.c_str());
}
// A fresh applier per case, BOTH SCOPES, and it takes both because there are two: a reset
@@ -33,6 +33,7 @@
// stays name-for-name identical between the pull and the push trees.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <filesystem>
#include <string>
+22 -1
View File
@@ -2113,7 +2113,16 @@ TEST(LogSanity, UsesEnvOverrideForFilePath) {
UnsetEnvVar("MOBILEGL_LOG_FILE_PATH");
{
std::ifstream logFile(logPath);
// P6: the sink writes ONE FILE PER ROLE, so the base name is not itself a file. This
// process logs on the main thread - the client role - so the line landed in the
// client-derived path. In a pull build there is no split and the base IS the file.
#if MOBILEGL_BUILD_DISAGGREGATED
const fs::path readPath = MobileGL::MG_Util::Debug::RoleLogPath(
logPath.string().c_str(), MobileGL::MG_Util::Debug::LogRole::Client);
#else
const fs::path readPath = logPath;
#endif
std::ifstream logFile(readPath);
ASSERT_TRUE(logFile.good());
const std::string contents((std::istreambuf_iterator<char>(logFile)), std::istreambuf_iterator<char>());
@@ -2121,6 +2130,10 @@ TEST(LogSanity, UsesEnvOverrideForFilePath) {
}
fs::remove(logPath);
#if MOBILEGL_BUILD_DISAGGREGATED
fs::remove(MobileGL::MG_Util::Debug::RoleLogPath(
logPath.string().c_str(), MobileGL::MG_Util::Debug::LogRole::Client));
#endif
}
// ---- Pure-state entry points: glHint / glPointParameter* / glPixelStoref / glGetDoublev -----------
@@ -3549,11 +3562,19 @@ namespace {
ScopedLogFileRedirect& operator=(const ScopedLogFileRedirect&) = delete;
// Everything written so far. Closes the log first so the last line is on disk.
//
// P6: BOTH ROLES, because "everything written" now spans two files - the sink writes one
// per role - and a caller of a general "give me the log" helper cannot know which role
// wrote the line it wants. In a pull build there is no split and m_path is the file.
std::string Contents() const {
MobileGL::MG_Util::Debug::Close();
#if MOBILEGL_BUILD_DISAGGREGATED
return MobileGL::MG_Util::Debug::ReadRoleLogs(m_path.string().c_str());
#else
std::ifstream logFile(m_path);
if (!logFile.good()) return {};
return std::string(std::istreambuf_iterator<char>(logFile), std::istreambuf_iterator<char>());
#endif
}
private:
+7
View File
@@ -198,6 +198,13 @@ int main(int argc, char** argv) {
#else
setenv("MOBILEGL_LOG_FILE_PATH", g_logPath.c_str(), 1);
#endif
// P6: the sink writes one file per role and the env is a BASE NAME. This suite emits on the
// main thread (client role), so the read path is the client-derived one; a pull build has
// no split and keeps the base. The env keeps the base either way.
#if MOBILEGL_BUILD_DISAGGREGATED
g_logPath = MobileGL::MG_Util::Debug::RoleLogPath(g_logPath.c_str(),
MobileGL::MG_Util::Debug::LogRole::Client);
#endif
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
+5 -4
View File
@@ -22,6 +22,7 @@
// comes back through the recording ReplySink on the record's own seq (R-3/R-5).
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <cstdio>
#include <cstdlib>
@@ -75,10 +76,10 @@ namespace {
std::string g_logPath;
std::string ReadLog() {
std::ifstream in(g_logPath, std::ios::binary);
std::ostringstream ss;
ss << in.rdbuf();
return ss.str();
// BOTH ROLES' LOGS (P6). A death test asserts that the CHILD said something; which
// role's thread said it is not what these cases are about, and refusals raised on the
// apply thread are written under the SERVER role by construction.
return MobileGL::MG_Util::Debug::ReadRoleLogs(g_logPath.c_str());
}
long ProcessId() {
+12 -6
View File
@@ -18,6 +18,7 @@
// assert ITS OWN failure string (R-16) instead of asserting that something, somewhere, died.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <cstdio>
#include <cstdlib>
@@ -78,12 +79,17 @@ namespace {
std::string g_logPath;
// BOTH ROLES' LOGS. P6 gives the client and the server role a file each, and a death test
// asserts that the CHILD said something - which role's thread said it is not what these
// cases are about. The refusals raised on the apply thread (RefuseFromApplyThread and every
// guard that rides it) are written under the SERVER role by construction, so a reader that
// took only g_logPath would report "the child aborted, but said nothing" for the very
// diagnostics it exists to check.
std::string ReadLog() {
std::ifstream in(g_logPath, std::ios::binary);
if (!in) return {};
std::ostringstream out;
out << in.rdbuf();
return out.str();
// BOTH ROLES' LOGS (P6). A death test asserts that the CHILD said something; which
// role's thread said it is not what these cases are about, and refusals raised on the
// apply thread are written under the SERVER role by construction.
return MobileGL::MG_Util::Debug::ReadRoleLogs(g_logPath.c_str());
}
int ProcessId() {
@@ -146,7 +152,7 @@ namespace {
// child's output. That is how the second death case in this file came to see the first
// one's slot name and assert on it: a control reading another control's message, which
// is one of the three shapes R-16 was written after.
{ std::ofstream truncate(g_logPath, std::ios::trunc | std::ios::binary); }
MobileGL::MG_Util::Debug::TruncateRoleLogs(g_logPath.c_str());
std::fflush(nullptr);
const pid_t pid = ::fork();
if (pid < 0) return result;
+5 -3
View File
@@ -29,6 +29,7 @@
// exists to test: bytes that were copied survive the source being overwritten with 0xDD.
#include <Config.h>
#include <MG_Util/Debug/Log.h>
#include <MG_Backend/BackendObject.h>
#include <MG_Backend/BackendObjects.h>
#include <MG_Backend/DirectGLES/BackendObject_DirectGLES.h>
@@ -102,9 +103,10 @@ namespace {
std::string g_logPath;
std::string ReadLog() {
std::ifstream in(g_logPath, std::ios::binary);
if (!in) return {};
return std::string(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>());
// BOTH ROLES' LOGS (P6). A death test asserts that the CHILD said something; which
// role's thread said it is not what these cases are about, and refusals raised on the
// apply thread are written under the SERVER role by construction.
return MobileGL::MG_Util::Debug::ReadRoleLogs(g_logPath.c_str());
}
unsigned ProcessId() {
@@ -23,6 +23,7 @@
// EVERY CASE BELOW CARRIES ITS RED-ONCE LINE, and each of those perturbations was run.
#include <gtest/gtest.h>
#include <MG_Util/Debug/Log.h>
#include <cstdint>
#include <cstdlib>
@@ -66,10 +67,10 @@ namespace {
std::string g_logPath;
std::string ReadLog() {
std::ifstream in(g_logPath, std::ios::binary);
std::ostringstream ss;
ss << in.rdbuf();
return ss.str();
// BOTH ROLES' LOGS (P6). A death test asserts that the CHILD said something; which
// role's thread said it is not what these cases are about, and refusals raised on the
// apply thread are written under the SERVER role by construction.
return MobileGL::MG_Util::Debug::ReadRoleLogs(g_logPath.c_str());
}
long ProcessId() {
@@ -22,6 +22,7 @@
// staged bytes" a checked fact rather than a design intention.
#include <Config.h>
#include <MG_Util/Debug/Log.h>
#include <MG_Backend/DirectGLES/Managers.h>
#include <MG_Pipe/PipeApply.h>
#include <MG_Remote/Server/StagedTextureStore.h>
@@ -51,9 +52,10 @@ namespace {
std::string g_logPath;
std::string ReadLog() {
std::ifstream in(g_logPath, std::ios::binary);
if (!in) return {};
return std::string(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>());
// BOTH ROLES' LOGS (P6). A death test asserts that the CHILD said something; which
// role's thread said it is not what these cases are about, and refusals raised on the
// apply thread are written under the SERVER role by construction.
return MobileGL::MG_Util::Debug::ReadRoleLogs(g_logPath.c_str());
}
unsigned ProcessId() {
@@ -24,6 +24,7 @@
// ServerLoopEglTest fixture, which now drives every forwarder through the frame channel).
#include <MG_Remote/Protocol/SurfaceOpCodec.h>
#include <MG_Util/Debug/Log.h>
#include <MG_Remote/Protocol/generated/protocol_generated.h>
#include <MG_Remote/Server/ServerLoop.h>
#include <MG_Remote/Server/SurfaceControlFrame.h>
@@ -63,9 +64,10 @@ namespace {
std::string g_logPath;
std::string ReadLog() {
std::ifstream in(g_logPath, std::ios::binary);
if (!in) return {};
return std::string(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>());
// BOTH ROLES' LOGS (P6). A death test asserts that the CHILD said something; which
// role's thread said it is not what these cases are about, and refusals raised on the
// apply thread are written under the SERVER role by construction.
return MobileGL::MG_Util::Debug::ReadRoleLogs(g_logPath.c_str());
}
unsigned ProcessId() {