[Test] (.github/workflows, docs/ci, MG_IntegrationTest, MG_IntegrationTest/Harness, scripts/data): assert each split entry's transport in-test

- the split fixture fails an armed Split/Spawn/Tcp entry whose process did not resolve the transport its registration claims, or whose server is not where the claim says: a thread here for inproc, a process of its own for spawn and tcp (SplitRuntimePeek now names spawn, reads ClientSession::PeerServerPid() and this process's pid, _getpid() on Windows; an unknown own pid leaves only that comparison unjudged)
- SplitLaneHarness.TransportClaimRule, a GL-free unit test, proves the rule red and green on canned inputs; skip census: added to junit-integration-split-strict/unit-strict (test/unit and unit-split borrow that list)
- integration-split drops its post-hoc grep of one entry's log; the step keeps the IPC default proof as 'Default-knob resolution check', on the disaggregation branches only, and a strict default that changed falls back to Transport A/B like the other two
This commit is contained in:
swung0x48 committed 2026-10-17 16:08:42 -04:00
1 parent 8b76a4e010
commit 91b889888e
9 files changed
+144 -28

No files matched your search

@@ -3697,4 +3697,11 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
add_test(NAME SplitLogPaths.ResultAccountingControls
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Harness/test_split_log_paths.py)
set_tests_properties(SplitLogPaths.ResultAccountingControls PROPERTIES LABELS "unit")
# The split fixture's transport-claim rule on canned inputs, so the rule itself can go red
# off a GPU: no GL, no library, just the pure function the fixture calls.
add_executable(SplitLaneHarnessTest Harness/SplitLaneHarnessTest.cpp)
target_link_libraries(SplitLaneHarnessTest PRIVATE GTest::gtest_main)
add_test(NAME SplitLaneHarness.TransportClaimRule COMMAND SplitLaneHarnessTest)
set_tests_properties(SplitLaneHarness.TransportClaimRule PROPERTIES LABELS "unit")
endif()
@@ -158,11 +158,21 @@ namespace MGITest {
// entries had no runtime evidence of anything, and their green meant only "the
// same GL workload passed").
const SplitRuntimeState state = PeekSplitRuntime();
// The transport the registration claims must be the one this process resolved,
// served where it says: a thread here for inproc, a process of its own for spawn
// and tcp. A lane that ran some other transport fails here, by name.
const std::string claimMismatch = SplitLane::TransportClaimMismatch(
SplitLane::MarkerValue("MOBILEGL_TRANSPORT"), SplitLane::MarkerValue("MOBILEGL_IPC_CONTROL"),
state.transportName, state.peerServerPid, state.selfPid);
if (!claimMismatch.empty()) {
FAIL() << claimMismatch;
}
m_splitAssertionsArmed = true;
m_emitSeqAtSetUp = state.emitSeq;
RecordProperty("split_transport", state.transportName);
RecordProperty("split_implemented_verbs", static_cast<int>(state.implementedVerbs));
RecordProperty("split_emit_seq_at_setup", static_cast<int>(state.emitSeq));
RecordProperty("split_peer_server_pid", std::to_string(state.peerServerPid));
#if defined(__linux__)
if (std::getenv("MGITEST_TCP_LANE")) {
// Connect must never silently launch a local server. The
@@ -84,6 +84,36 @@ namespace MGITest::SplitLane {
return SplitRuntimeSkipReason();
}
// The transport a registration claims, against what this process resolved and which process
// serves it; empty when they agree. claimedTransport and claimedControl are the entry's own
// MOBILEGL_TRANSPORT and MOBILEGL_IPC_CONTROL; the rest comes from PeekSplitRuntime(). In
// process, the server role is a thread here and states this process's pid; spawn and tcp
// need a server process of their own. A registration that claims no transport is not judged,
// and an unknown own pid (0) leaves only the comparison with it unjudged.
inline std::string TransportClaimMismatch(const std::string& claimedTransport, const std::string& claimedControl,
const std::string& resolvedName, unsigned long long peerPid,
unsigned long long selfPid) {
const bool tcp = claimedControl.rfind("tcp://", 0) == 0;
const bool selfKnown = selfPid != 0;
const std::string pids =
" (server pid " + std::to_string(peerPid) + ", this process " + std::to_string(selfPid) + ")";
if (claimedTransport == "inproc" && !tcp) {
if (resolvedName != "inproc" || peerPid == 0 || (selfKnown && peerPid != selfPid)) {
return "this registration claims MOBILEGL_TRANSPORT=inproc, but the process resolved '" + resolvedName +
"' with its server role in another process or none" + pids;
}
return {};
}
if (claimedTransport == "spawn" || tcp) {
const std::string claim = tcp ? "tcp (MOBILEGL_IPC_CONTROL=" + claimedControl + ")" : "spawn";
if (resolvedName != "spawn" || peerPid == 0 || (selfKnown && peerPid == selfPid)) {
return "this registration claims " + claim + ", but the process resolved '" + resolvedName +
"' without a server process of its own" + pids;
}
}
return {};
}
// "adopted", "emulated", or empty when the lane declared nothing.
inline std::string DeclaredPersistentMapArm() {
return MarkerValue("MGITEST_PERSISTENT_MAP_ARM");
@@ -0,0 +1,64 @@
// MobileGL - MobileGL/MG_IntegrationTest/Harness/SplitLaneHarnessTest.cpp
// Copyright (c) 2026 MobileGL-Dev
// Licensed under the GNU Lesser General Public License v3.0:
// https://www.gnu.org/licenses/gpl-3.0.txt
// https://www.gnu.org/licenses/lgpl-3.0.txt
// SPDX-License-Identifier: LGPL-3.0-only
// End of Source File Header
//
// SplitLane::TransportClaimMismatch on canned inputs: each claim must be refused when the process
// resolved another transport or the wrong process serves it, and accepted when both agree.
#include "SplitLane.h"
#include <gtest/gtest.h>
namespace {
using MGITest::SplitLane::TransportClaimMismatch;
constexpr unsigned long long kSelf = 4242;
constexpr unsigned long long kServer = 4343;
TEST(SplitLaneHarness, AnInprocClaimNeedsTheServerThreadHere) {
EXPECT_EQ(TransportClaimMismatch("inproc", "", "inproc", kSelf, kSelf), "");
EXPECT_NE(TransportClaimMismatch("inproc", "", "spawn", kServer, kSelf), "");
EXPECT_NE(TransportClaimMismatch("inproc", "", "inproc", kServer, kSelf), "");
EXPECT_NE(TransportClaimMismatch("inproc", "", "inproc", 0, kSelf), "");
EXPECT_NE(TransportClaimMismatch("inproc", "", "monolith", 0, kSelf), "");
}
TEST(SplitLaneHarness, ASpawnClaimNeedsAServerProcessOfItsOwn) {
EXPECT_EQ(TransportClaimMismatch("spawn", "", "spawn", kServer, kSelf), "");
EXPECT_NE(TransportClaimMismatch("spawn", "", "inproc", kSelf, kSelf), "");
EXPECT_NE(TransportClaimMismatch("spawn", "", "spawn", kSelf, kSelf), "");
EXPECT_NE(TransportClaimMismatch("spawn", "", "spawn", 0, kSelf), "");
}
TEST(SplitLaneHarness, ATcpClaimIsASpawnSessionToAnotherProcess) {
EXPECT_EQ(TransportClaimMismatch("spawn", "tcp://127.0.0.1:30613", "spawn", kServer, kSelf), "");
EXPECT_NE(TransportClaimMismatch("spawn", "tcp://127.0.0.1:30613", "spawn", kSelf, kSelf), "");
EXPECT_NE(TransportClaimMismatch("inproc", "tcp://127.0.0.1:30613", "inproc", kSelf, kSelf), "");
}
TEST(SplitLaneHarness, NoClaimIsNotJudged) {
EXPECT_EQ(TransportClaimMismatch("", "", "monolith", 0, kSelf), "");
EXPECT_EQ(TransportClaimMismatch("monolith", "", "monolith", 0, kSelf), "");
}
TEST(SplitLaneHarness, AnUnknownOwnPidStillJudgesTheTransportAndTheServer) {
EXPECT_EQ(TransportClaimMismatch("inproc", "", "inproc", kSelf, 0), "");
EXPECT_NE(TransportClaimMismatch("inproc", "", "spawn", kServer, 0), "");
EXPECT_NE(TransportClaimMismatch("inproc", "", "inproc", 0, 0), "");
EXPECT_EQ(TransportClaimMismatch("spawn", "", "spawn", kServer, 0), "");
EXPECT_NE(TransportClaimMismatch("spawn", "", "inproc", kSelf, 0), "");
EXPECT_NE(TransportClaimMismatch("spawn", "", "spawn", 0, 0), "");
}
TEST(SplitLaneHarness, TheRefusalNamesBothPids) {
const std::string message = TransportClaimMismatch("spawn", "", "spawn", kSelf, kSelf);
EXPECT_NE(message.find("server pid 4242"), std::string::npos) << message;
EXPECT_NE(message.find("this process 4242"), std::string::npos) << message;
}
} // namespace
@@ -25,6 +25,11 @@
#include <chrono>
#include <atomic>
#include <thread>
#if defined(_WIN32)
#include <process.h>
#else
#include <unistd.h>
#endif
#define MGITEST_SPLIT_RUNTIME_PEEK_LIVE 1
#endif
// P13 W5: THE RECORD-ARM HALF OF THE PEEK, which needs no transport. A library built with the
@@ -141,6 +146,9 @@ namespace MGITest {
case TransportMode::InProcess:
state.transportName = "inproc";
break;
case TransportMode::Spawn:
state.transportName = "spawn";
break;
default:
state.transportName = "non-monolith";
break;
@@ -154,11 +162,17 @@ namespace MGITest {
MobileGL::MG_Remote::Client::ClientSession* session = MobileGL::MG_Remote::Client::ClientSession::Active();
state.sessionActive = session != nullptr;
state.implementedVerbs = MobileGL::MG_Remote::Client::ImplementedVerbCount();
#if defined(_WIN32)
state.selfPid = static_cast<unsigned long long>(::_getpid());
#else
state.selfPid = static_cast<unsigned long long>(::getpid());
#endif
if (session != nullptr) {
// Encoder() returns the member; EmitSeq() returns m_emitSeq. Neither is a stub, and
// neither emits anything - this is a read.
const MobileGL::MG_Remote::Wire::PipeWireEncoder& encoder = session->Encoder();
state.emitSeq = encoder.EmitSeq();
state.peerServerPid = session->PeerServerPid();
state.runAheadArmed = session->RunAheadArmed();
// P7 wave 2 package C, OQ-10: read through the SAME accessor the frontend's own
// MGPipeResourceOpsHaveSubDataResident reads (MG_Impl/Pipe/PipeFill.cpp), so a
@@ -74,6 +74,11 @@ namespace MGITest {
unsigned int totalVerbSlots = 0;
// The encoder's highest produced record ordinal, or 0 when there is no session.
unsigned long long emitSeq = 0;
// ClientSession::PeerServerPid(), the pid the server stated in its Welcome (0 without a
// session), and this process's own (0 when unknown), so a lane can tell a server thread
// here from a server process elsewhere.
unsigned long long peerServerPid = 0;
unsigned long long selfPid = 0;
// Real session state/watermarks. Only the client thread reads this snapshot;
// the scheduling observer below reads producerParked separately.
bool runAheadArmed = false;