Files
MobileGL/MobileGL/MG_IntegrationTest/Harness/SplitLaneHarnessTest.cpp
T
swung0x48 91b889888e [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
2026-10-17 16:08:42 -04:00

65 lines
3.1 KiB
C++

// 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