[Fix] (P11 A1): settle MOBILEGL_IPC_ADOPT_TIER at the handshake from the data plane - a stream refuses T0/T1 by name and runs T2 on either side, a client over shared segments dies by name before any record, the at-use check trusts the settlement; unit gates on a real tcp session and a real inproc handshake

This commit is contained in:
2026-09-29 07:23:41 -04:00
parent 1797db0070
commit 3c72e5c637
16 changed files with 500 additions and 73 deletions
+25 -6
View File
@@ -30,6 +30,7 @@
#if MOBILEGL_BUILD_DISAGGREGATED
#include <MG_Remote/Client/GpuWritePending.h>
#include <MG_Remote/Client/PersistentMapTracker.h>
#include <MG_Remote/Transport/AdoptTier.h>
#endif
using namespace MobileGL;
@@ -84,6 +85,7 @@ namespace {
// membership assertion in this file would then be about a different code path.
MG_State::GLState::SetBufferBackendOps(nullptr);
g_mintedPersistentBase = nullptr;
MG_Remote::Transport::ForgetAdoptTierSettlementForTest();
PersistentMapTracker::Instance().ClearForTest();
MG_State::pGLContext = Move(m_context);
MG_Config::Transport = m_transport;
@@ -536,14 +538,31 @@ TEST_F(SplitBufferSet, UnderSplitTheWritebackClearsThePendingFlagAndNotTheReques
EXPECT_FALSE(buffer->HasOutstandingGpuWrite());
}
// R-6's tier gate. T2 is the only tier P5 implements; the other two are a NAMED refusal and
// their spelling exists now so the P11 negative control has one.
// R-6's tier gate in P11 A1's shape (CONTRACT-P11 §1). T2 is the only implemented tier, and 0 / 1
// are SETTLED AT THE HANDSHAKE by the data plane rather than discovered at the first
// map_persistent: a stream refuses them by name and runs T2 on either side, a client over shared
// segments dies there by name, a server over shared segments serves T2. The at-use check trusts a
// settled session and still dies by name for a map_persistent no handshake settled. The session
// halves are RemoteClientControls.AdoptTier*OverSharedSegments* and AdoptTierStreamTest.
TEST_F(SplitBufferSet, OnlyAdoptTierTwoIsImplemented) {
namespace Tier = MG_Remote::Transport;
EXPECT_TRUE(MG_Remote::Client::AdoptTierIsEmulate());
MG_Config::Ipc.AdoptTier = 0;
EXPECT_DEATH(MG_Remote::Client::AdoptTierIsEmulate(), "");
MG_Config::Ipc.AdoptTier = 1;
EXPECT_DEATH(MG_Remote::Client::AdoptTierIsEmulate(), "");
for (const Uint32 tier : {0u, 1u}) {
SCOPED_TRACE(tier);
MG_Config::Ipc.AdoptTier = tier;
Tier::ForgetAdoptTierSettlementForTest();
EXPECT_DEATH(MG_Remote::Client::AdoptTierIsEmulate(), "UnimplementedAdoptTier.*no handshake settled");
EXPECT_DEATH(Tier::SettleAdoptTierAtHandshake(false, Tier::AdoptTierSide::Client),
"UnimplementedAdoptTier.*refused at the handshake over shared segments");
for (const auto side : {Tier::AdoptTierSide::Client, Tier::AdoptTierSide::Server}) {
Tier::ForgetAdoptTierSettlementForTest();
EXPECT_EQ(Tier::SettleAdoptTierAtHandshake(true, side), 2u);
EXPECT_TRUE(MG_Remote::Client::AdoptTierIsEmulate());
}
Tier::ForgetAdoptTierSettlementForTest();
EXPECT_EQ(Tier::SettleAdoptTierAtHandshake(false, Tier::AdoptTierSide::Server), 2u);
EXPECT_TRUE(MG_Remote::Client::AdoptTierIsEmulate());
}
MG_Config::Ipc.AdoptTier = 2;
}
@@ -0,0 +1,179 @@
// MobileGL - MobileGL/MG_Test/Wire/AdoptTierStreamTest.cpp
// Copyright (c) 2025-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
// P11 A1 (MG_Remote/CONTRACT-P11.md §1): MOBILEGL_IPC_ADOPT_TIER=0/1 ON A STREAM DATA PLANE.
//
// Real servers on loopback TCP and forked peers (P12ServerRig.h), so the session is the product's
// two-process tcp session and each side reads its OWN knob, as on the tcp lane:
// * a client that names T0 or T1 against a `--serve` supervisor comes up, says
// `Refuse{AdoptTierOnStream, "T<n>"}` exactly once, gets DECLINED for its map_persistent and
// goes on applying records;
// * an in-process display server (the render-server Activity's shape) that names T0 says the
// same line once per session, never dies, and serves T2.
// The shared-segment half (a client naming T0/T1 dies at the handshake, before any map_persistent)
// is RemoteClientControls.AdoptTier*OverSharedSegmentsDiesAtTheHandshakeBeforeAnyMapPersistent.
//
// RED-ONCE: delete the stream branch of Transport::SettleAdoptTierAtHandshake -> the client peers
// die at the handshake (started 0, Fatal{UnimplementedAdoptTier}) and the server case finds no
// refusal line.
#include "P12ServerRig.h"
#include <MG_Remote/Server/InProcessServer.h>
#include <MG_Remote/Wire/PipeWireCodec.h>
#include <atomic>
#include <csignal>
#include <pthread.h>
using namespace MobileGL;
using namespace P12;
namespace {
// A SERVER WHOSE OWN KNOB SAYS T0. Not the exec'd `--serve` supervisor: ServerSpawn scrubs
// every MOBILEGL_IPC_* but five server-owned knobs from a child it launches, so a knob set here
// would never reach it. The in-process display server (InProcessServerTest's shape - the device
// render-server Activity FCL reaches over tcp) is a process forked from this one, sets the
// knob in its own environment, and RunSession re-reads the environment for every session.
[[noreturn]] void RunInProcessServerWithAdoptTier(const std::string& endpoint, const std::string& logBase,
const char* adoptTier) {
::setenv("MOBILEGL_LOG_FILE_PATH", logBase.c_str(), 1);
::setenv("MOBILEGL_IPC_ROLE", "server", 1);
::setenv("MOBILEGL_IPC_DIAL", "no", 1);
::setenv("MOBILEGL_IPC_ADOPT_TIER", adoptTier, 1);
for (const char* name : {"MOBILEGL_TRANSPORT", "MOBILEGL_IPC_SERVER_PATH", "MOBILEGL_IPC_RING_MB",
"MOBILEGL_IPC_STAGE_MB", "MOBILEGL_IPC_CONTROL", "MOBILEGL_IPC_SURFACE",
"MOBILEGL_BACKEND_TYPE"})
::unsetenv(name);
sigset_t stop;
sigemptyset(&stop);
sigaddset(&stop, SIGTERM);
pthread_sigmask(SIG_BLOCK, &stop, nullptr);
std::atomic<bool> returned{false};
std::thread server([&] {
(void)mobilegl_server_serve_inprocess(endpoint.c_str());
returned.store(true);
});
bool stopping = false;
while (!returned.load()) {
timespec slice{0, 100 * 1000 * 1000};
if (sigtimedwait(&stop, nullptr, &slice) == SIGTERM && !stopping) {
stopping = true;
mobilegl_server_stop_inprocess();
}
}
server.join();
std::fflush(nullptr);
::_exit(0);
}
// THE SERVER GETS A LOG BASE OF ITS OWN (`server->logBase`), the peers another (`peerBase`, which
// this process exports for the forks): a peer writes the lines the server forwards into
// `<its base>.server.log`, opened "w", so sharing one base truncates the server's own file under
// it (measured: NUL holes and the handshake's lines gone).
bool LaunchInProcessServerWithAdoptTier(const std::string& label, const char* adoptTier, const std::string& peerBase,
ServerProcess* server) {
server->logBase = "/tmp/mgl-p11-" + label + "-server-" + std::to_string(::getpid()) + ".log";
::setenv("MOBILEGL_LOG_FILE_PATH", peerBase.c_str(), 1);
Debug::TruncateRoleLogs(peerBase.c_str());
PinHeadlessEgl();
for (int attempt = 0; attempt < 5; ++attempt) {
const int port = FreeLoopbackPort();
if (port <= 0) return false;
server->endpoint = "tcp://127.0.0.1:" + std::to_string(port);
Debug::TruncateRoleLogs(server->logBase.c_str());
std::fflush(nullptr);
const pid_t pid = ::fork();
if (pid < 0) return false;
if (pid == 0) RunInProcessServerWithAdoptTier(server->endpoint, server->logBase, adoptTier);
server->pid = pid;
bool listening = false;
(void)WaitFor(
[&] {
if (server->Log().find("listening on") != std::string::npos) return listening = true;
return server->WaitExit(0) && server->pid <= 0;
},
10000);
if (listening) return true;
if (server->pid > 0) return false;
}
return false;
}
// The client's own role log for this rig's base (the peers inherit it from LaunchSupervisor).
std::string ClientLog(const ServerProcess& server) {
return ReadFile(Debug::RoleLogPath(server.logBase.c_str(), Debug::LogRole::Client));
}
std::string RefusalLine(Uint32 tier) {
return "Refuse{AdoptTierOnStream, \"T" + std::to_string(tier) + "\"}";
}
// One map_persistent, then one ordinary record: the answer to the first and proof the session
// is still applying after it.
void MapPersistentThenARecord(Remote::Client::ClientSession& client, PeerReport& r) {
P::MGPHandleOnly handle{};
handle.Kind = static_cast<Uint32>(P::MGPipeKind::Buffer);
Int32 status = Remote::Wire::ReplySink::kStatusError;
const Uint64 seq =
client.EmitAndWait(P::MGPWireOp::MapPersistent, &handle, sizeof(handle), nullptr, 0, nullptr, 0, &status);
r.status = seq == Remote::Wire::kInvalidSeq ? -98 : status;
P::MGPMemoryBarrier barrier{};
barrier.Bits = 0x2000u;
r.applied = Emit(client, P::MGPWireOp::MemoryBarrier, &barrier, sizeof(barrier)) ? 1 : 0;
}
} // namespace
TEST(AdoptTierStream, AClientNamingT0OrT1IsRefusedOnceAndItsMapPersistentIsDeclined) {
ServerProcess server;
ASSERT_TRUE(LaunchSupervisor("adopt-client", &server)) << server.Log();
for (Uint32 tier : {0u, 1u}) {
SCOPED_TRACE(tier);
const PeerReport r = RunPeer(server.endpoint, MapPersistentThenARecord, /*stopCleanly=*/true, 30000, 0,
nullptr, [tier] { MG_Config::Ipc.AdoptTier = tier; });
const std::string client = ClientLog(server);
ASSERT_EQ(r.started, 1) << "the session did not come up: " << r.note << "\n" << client;
EXPECT_EQ(r.status, Remote::Wire::ReplySink::kStatusDeclined)
<< "map_persistent was not DECLINED on a stream session\n" << client;
EXPECT_EQ(r.applied, 1) << "the session stopped applying after the map_persistent\n" << client;
EXPECT_EQ(Count(client, RefusalLine(tier)), 1u)
<< "a stream session names T" << tier << " exactly once, at the handshake\n" << client;
EXPECT_EQ(Count(client, "Fatal{"), 0u) << client;
EXPECT_EQ(Count(server.Log(), "AdoptTierOnStream"), 0u)
<< "the server's own knob is 2; the line is the client's\n" << server.Log();
}
}
TEST(AdoptTierStream, AServerNamingT0RefusesOncePerSessionAndServesT2) {
ServerProcess server;
const std::string peerBase = "/tmp/mgl-p11-adopt-server-peers-" + std::to_string(::getpid()) + ".log";
ASSERT_TRUE(LaunchInProcessServerWithAdoptTier("adopt-server", "0", peerBase, &server)) << server.Log();
// Both role files of the server's own base: which role a session thread of the in-process
// server logs under is not what this case is about.
const auto serverLog = [&server] { return Debug::ReadRoleLogs(server.logBase.c_str()); };
for (Uint32 session = 1; session <= 2; ++session) {
SCOPED_TRACE(session);
const PeerReport r = RunPeer(server.endpoint, MapPersistentThenARecord, /*stopCleanly=*/true, 30000, 0,
nullptr, [] { MG_Config::Ipc.AdoptTier = 2u; });
const std::string client = ReadFile(Debug::RoleLogPath(peerBase.c_str(), Debug::LogRole::Client));
ASSERT_EQ(r.started, 1) << r.note << "\n" << serverLog();
EXPECT_EQ(r.status, Remote::Wire::ReplySink::kStatusDeclined) << serverLog();
EXPECT_EQ(r.applied, 1) << serverLog();
EXPECT_EQ(Count(client, "AdoptTierOnStream"), 0u) << "the client's knob is 2\n" << client;
EXPECT_EQ(Count(serverLog(), RefusalLine(0)), session)
<< "one refusal line per server session, at its handshake\n" << serverLog();
}
EXPECT_EQ(Count(serverLog(), "Fatal{UnimplementedAdoptTier"), 0u) << serverLog();
if (!::testing::Test::HasFailure()) {
std::error_code ec;
std::filesystem::remove(Debug::RoleLogPath(peerBase.c_str(), Debug::LogRole::Client), ec);
std::filesystem::remove(Debug::RoleLogPath(peerBase.c_str(), Debug::LogRole::Server), ec);
}
}
+7 -2
View File
@@ -46,6 +46,10 @@ if (NOT WIN32)
# MOBILEGL_IPC_SURFACE=server against a display-less `--serve` supervisor. Both drive real peers
# and (the second, and D8's case) the real server image, as PeerLatchTest does.
list(APPEND MOBILEGL_WIRE_TESTS InProcessServerTest ServerOwnedSurfaceTest)
# P11 A1: MOBILEGL_IPC_ADOPT_TIER=0/1 on a stream data plane, against a real `--serve`
# supervisor over loopback TCP (P12ServerRig.h): refused by name once per session on the side
# that names it, map_persistent DECLINED, never a Fatal. Needs the server image too.
list(APPEND MOBILEGL_WIRE_TESTS AdoptTierStreamTest)
endif()
include(GoogleTest)
@@ -63,7 +67,8 @@ foreach (test IN LISTS MOBILEGL_WIRE_TESTS)
${MGL_ROOT}/MobileGL
${MGL_ROOT}/3rdparty/flatbuffers/include
)
if (test STREQUAL "PeerLatchTest" OR test STREQUAL "InProcessServerTest" OR test STREQUAL "ServerOwnedSurfaceTest")
if (test STREQUAL "PeerLatchTest" OR test STREQUAL "InProcessServerTest" OR test STREQUAL "ServerOwnedSurfaceTest" OR
test STREQUAL "AdoptTierStreamTest")
# It builds records and a program archive by hand, so it reaches MG_Pipe and MG_State
# the way the codec suites do. (P12's two server suites share PeerLatchTest's healthy
# session, P12ServerRig.h, and so its include paths.)
@@ -81,7 +86,7 @@ foreach (test IN LISTS MOBILEGL_WIRE_TESTS)
)
if (test STREQUAL "ServerSpawnTest" OR test STREQUAL "PeerLatchTest" OR test STREQUAL "InProcessServerTest" OR
test STREQUAL "ServerOwnedSurfaceTest")
test STREQUAL "ServerOwnedSurfaceTest" OR test STREQUAL "AdoptTierStreamTest")
# It execs the real image, so it must be built first and must be told
# where it is. MOBILEGL_TEST_SERVER_PATH is read by the test's
# ServerImage() helper; without it the test would depend on the working
+64 -35
View File
@@ -51,6 +51,7 @@
#include <MG_Pipe/MGPipeRenderStateSpans.h>
#include <MG_Pipe/PipeApply.h>
#include <MG_Remote/CapsCodec.h>
#include <MG_Remote/Transport/AdoptTier.h>
#include <MG_Remote/Transport/Ring.h>
#include <MG_Remote/Wire/PipeWireCodec.h>
#include <MG_State/GLState/ProgramState/ProgramArtifactsCodec.h>
@@ -2947,31 +2948,76 @@ TEST_F(PipeWireCodecTest, ASecondProcessResolverIsFatalRatherThanASilentRace) {
EXPECT_NE(r.Log.find("already installed"), std::string::npos) << r.Log;
}
// ---- R-6 / contract §5: the two forbidden adoption tiers die ON THE WIRE PATH TOO --------
// ---- R-6 / P11 A1 (CONTRACT-P11 §1): the codec's MapPersistent arm and the adopt tier -----
//
// wave1-codex-verify.md §4: `AdoptTier` had ZERO references anywhere on the codec path, so
// MOBILEGL_IPC_ADOPT_TIER=0 and =1 - which contract §5 promises "parse and are Fatal at use,
// naming P11" - decoded as an ordinary DECLINED. The verifier set each forbidden tier inside
// KReplySlotMapPersistentIsAConstantDecline and watched its successful-decline assertions
// still pass, on BOTH tiers.
//
// THESE ARE FORKED, NOT EXPECT_DEATH, for the reason at the top of this file - and forking is
// what lets the case REQUIRE THE DIAGNOSTIC rather than any abort: r.Log is searched for the
// exact sentence AdoptTierIsEmulate prints. ID-46 finding 10 is an empty death regex; the
// EXPECT_NE lines below are the opposite of that, and a crash for any other reason fails the
// case on the log it prints.
//
// I made both red once, by doing X: X = restoring the unconditional decline in
// PipeWireCodec.cpp's MapPersistent arm (deleting the AdoptTierIsEmulate call). Both children
// then exit 0 having posted a clean DECLINED, and both cases fail on DiedOfAbort.
// wave1-codex-verify.md §4 found `AdoptTier` had ZERO references on the codec path, so a T0/T1
// run decoded as an ordinary DECLINED and looked like a working T0. The arm has asked the tier
// since. P11 A1 moved the VERDICT to the handshake (Transport/AdoptTier.h): a stream refuses
// T0/T1 by name there and runs T2, shared segments die there. So this arm now sees two shapes:
// * after a stream handshake settled the tier, T0/T1 DECLINE like T2, with no second refusal
// line - the two cases below that used to be "dies at use";
// * with no handshake behind it, the arm still dies by name (forked, for the log), which keeps
// the wave-1 finding pinned: red once by deleting the arm's AdoptTierIsEmulate call - the
// child then exits 0 having posted a clean DECLINED.
// The session-level halves are AdoptTierStreamTest and RemoteClientControls.AdoptTier*.
TEST_F(PipeWireCodecTest, AdoptTierZeroIsFatalOnTheWirePathAndNamesP11) {
namespace {
void ExpectStreamSettledTierDeclinesOnTheWire(Uint32 tier) {
const MG_Config::TransportMode savedTransport = MG_Config::Transport;
const Uint32 savedTier = MG_Config::Ipc.AdoptTier;
struct Restore {
MG_Config::TransportMode T;
Uint32 A;
~Restore() {
MG_Config::Transport = T;
MG_Config::Ipc.AdoptTier = A;
Transport::ForgetAdoptTierSettlementForTest();
}
} restore{savedTransport, savedTier};
MG_Config::Transport = MG_Config::TransportMode::InProcess;
MG_Config::Ipc.AdoptTier = tier;
Transport::ForgetAdoptTierSettlementForTest();
const std::string before = ReadLog();
ASSERT_EQ(Transport::SettleAdoptTierAtHandshake(true, Transport::AdoptTierSide::Server), 2u);
Wire2 wire;
const MGPHandleOnly handle = HandleOnly(5, MGPipeKind::Buffer);
for (int record = 0; record < 2; ++record) {
ASSERT_NE(wire.Encoder().EncodeRecord(MGPWireOp::MapPersistent, &handle, sizeof(handle)), kInvalidSeq);
bool applied = false;
ASSERT_TRUE(wire.PumpOne(&applied));
EXPECT_TRUE(applied);
}
ASSERT_EQ(wire.Answers().All.size(), 2u);
for (const auto& answer : wire.Answers().All) {
EXPECT_EQ(answer.Status, ReplySink::kStatusDeclined);
EXPECT_TRUE(answer.Bytes.empty());
}
const std::string delta = ReadLog().substr(before.size());
const std::string line = "Refuse{AdoptTierOnStream, \"T" + std::to_string(tier) + "\"}";
std::size_t count = 0;
for (auto at = delta.find(line); at != std::string::npos; at = delta.find(line, at + 1)) ++count;
EXPECT_EQ(count, 1u) << "one refusal at the handshake and none per map_persistent:\n" << delta;
EXPECT_EQ(delta.find("Fatal{"), std::string::npos) << delta;
}
} // namespace
TEST_F(PipeWireCodecTest, AdoptTierZeroAfterAStreamHandshakeIsADeclineOnTheWirePath) {
ExpectStreamSettledTierDeclinesOnTheWire(0u);
}
TEST_F(PipeWireCodecTest, AdoptTierOneAfterAStreamHandshakeIsADeclineOnTheWirePath) {
ExpectStreamSettledTierDeclinesOnTheWire(1u);
}
TEST_F(PipeWireCodecTest, AnUnsettledAdoptTierStillDiesByNameOnTheWirePath) {
const ChildResult r = RunInChild([] {
// The child dies; nothing needs restoring. The transport half is the same conjunction
// MGPipeApplyMapPersistent uses - a monolith TRANSPORT mints like push (ID-42) and is
// not the arm this record can arrive on.
MG_Config::Transport = MG_Config::TransportMode::InProcess;
MG_Config::Ipc.AdoptTier = 0u;
Transport::ForgetAdoptTierSettlementForTest();
Wire2 wire;
const MGPHandleOnly handle = HandleOnly(5, MGPipeKind::Buffer);
(void)wire.Encoder().EncodeRecord(MGPWireOp::MapPersistent, &handle, sizeof(handle));
@@ -2980,24 +3026,7 @@ TEST_F(PipeWireCodecTest, AdoptTierZeroIsFatalOnTheWirePathAndNamesP11) {
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnimplementedAdoptTier, \"T0\"} - MOBILEGL_IPC_ADOPT_TIER=0 "
"names an adoption tier P11 implements"),
std::string::npos)
<< r.Log;
}
TEST_F(PipeWireCodecTest, AdoptTierOneIsFatalOnTheWirePathAndNamesP11) {
const ChildResult r = RunInChild([] {
MG_Config::Transport = MG_Config::TransportMode::InProcess;
MG_Config::Ipc.AdoptTier = 1u;
Wire2 wire;
const MGPHandleOnly handle = HandleOnly(5, MGPipeKind::Buffer);
(void)wire.Encoder().EncodeRecord(MGPWireOp::MapPersistent, &handle, sizeof(handle));
bool applied = false;
(void)wire.PumpOne(&applied);
});
ASSERT_TRUE(DiedOfAbort(r)) << DescribeStatus(r) << "\n" << r.Log;
EXPECT_NE(r.Log.find("Fatal{UnimplementedAdoptTier, \"T1\"} - MOBILEGL_IPC_ADOPT_TIER=1 "
"names an adoption tier P11 implements"),
"reached a map_persistent that no handshake settled"),
std::string::npos)
<< r.Log;
}
@@ -324,6 +324,55 @@ TEST(RemoteClientControls, MapPersistentErrorIsNotADecline) {
ExpectNamedAbort(child, "Fatal{ReplyError, \"map_persistent\"}");
}
// P11 A1 (CONTRACT-P11 §1): MOBILEGL_IPC_ADOPT_TIER=0/1 OVER SHARED SEGMENTS DIES AT THE
// HANDSHAKE, before any record. inproc is shared segments by construction, and this is the real
// Start (the same StartOverTransportPair the lanes run). The child writes 'S' once Start returns
// and 'M' once its map_persistent went out, so "died before the first map_persistent" is a fact
// the parent reads rather than infers from the log. The stream half is AdoptTierStreamTest.
//
// RED-ONCE: move the check back to use (drop the client's SessionFail in
// Transport::SettleAdoptTierAtHandshake and make Client::AdoptTierIsEmulate abort on 0/1 again)
// -> the session comes up ('S'), the map_persistent goes out, and the child dies only when the
// server's codec asks the tier.
namespace {
void ExpectDeathAtTheSharedSegmentHandshake(Uint32 tier) {
int marks[2] = {-1, -1};
ASSERT_EQ(::pipe(marks), 0);
const auto child = RunInChild([&marks, tier] {
::close(marks[0]);
MG_Config::Ipc.AdoptTier = tier;
StartControlSession();
const char started = 'S';
(void)!::write(marks[1], &started, 1);
MGPHandleOnly handle{};
handle.Kind = static_cast<Uint32>(MGPipeKind::Buffer);
(void)MGPipeRouteMapPersistent(handle, 64, nullptr);
const char sent = 'M';
(void)!::write(marks[1], &sent, 1);
});
::close(marks[1]);
std::string seen;
char c = 0;
while (::read(marks[0], &c, 1) == 1) seen.push_back(c);
::close(marks[0]);
const std::string word = "Fatal{UnimplementedAdoptTier, \"T" + std::to_string(tier) + "\"}";
ExpectNamedAbort(child, word.c_str());
EXPECT_EQ(seen, "") << "'S' = the session came up, 'M' = a map_persistent went out, both before "
"the death; T" << tier << " over shared segments must die at the handshake\n"
<< child.Log;
EXPECT_NE(child.Log.find("refused at the handshake over shared segments"), std::string::npos)
<< child.Log;
}
} // namespace
TEST(RemoteClientControls, AdoptTierZeroOverSharedSegmentsDiesAtTheHandshakeBeforeAnyMapPersistent) {
ExpectDeathAtTheSharedSegmentHandshake(0u);
}
TEST(RemoteClientControls, AdoptTierOneOverSharedSegmentsDiesAtTheHandshakeBeforeAnyMapPersistent) {
ExpectDeathAtTheSharedSegmentHandshake(1u);
}
TEST(RemoteClientControls, AnIdenticalRepeatedMakeCurrentRepublishesNothing) {
const auto child = RunInChild([] {
StartControlSession();