mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-17 06:53:22 +09:00
[Test] (MG_IntegrationTest/Harness, MG_IntegrationTest/Scenarios, MG_Test/Wire, scripts/data): add in-test controls for the map push and the wait probe
- PersistentCoherentMapScenario.ThePushIsTheOnlyRouteAWriteTakesToTheServer - RemoteWaitBoundaryControl.AnUnwaitedPublishIsSeenAsNoWait
This commit is contained in:
@@ -103,4 +103,28 @@ namespace MGITest {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ForgetLivePersistentMap(unsigned int bufferName) {
|
||||
#if defined(MGITEST_PERSISTENT_MAP_TRACKER_LIVE)
|
||||
MobileGL::MG_State::GLState::BufferObject* buffer = FrontendBuffer(bufferName);
|
||||
if (buffer == nullptr) return false;
|
||||
MobileGL::MG_Record::PersistentMapTracker::Instance().Forget(*buffer);
|
||||
return true;
|
||||
#else
|
||||
(void)bufferName;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ReannounceLivePersistentMap(unsigned int bufferName) {
|
||||
#if defined(MGITEST_PERSISTENT_MAP_TRACKER_LIVE)
|
||||
MobileGL::MG_State::GLState::BufferObject* buffer = FrontendBuffer(bufferName);
|
||||
if (buffer == nullptr) return false;
|
||||
buffer->NotePersistentMapStateChanged();
|
||||
return true;
|
||||
#else
|
||||
(void)bufferName;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace MGITest
|
||||
|
||||
@@ -58,6 +58,15 @@ namespace MGITest {
|
||||
// Same contract as above: false means "could not look".
|
||||
bool PeekBufferIsLivePersistentMap(unsigned int bufferName, bool* outLive);
|
||||
|
||||
// The two production calls that take a buffer out of the tracker's set and put it back:
|
||||
// PersistentMapTracker::Forget, which an unmap or a destroy reaches, and
|
||||
// BufferObject::NotePersistentMapStateChanged, which every map-state change makes. They let
|
||||
// a scenario show the push is the only route a coherent write takes to the server.
|
||||
//
|
||||
// Same contract: false means "could not reach the tracker", and nothing was changed.
|
||||
bool ForgetLivePersistentMap(unsigned int bufferName);
|
||||
bool ReannounceLivePersistentMap(unsigned int bufferName);
|
||||
|
||||
// Separate-process clients own these counters; the remote Present window
|
||||
// belongs to the server and cannot report client map acquisitions or bytes.
|
||||
bool PeekSeparateClientMapStats(unsigned long long* acquisitions, unsigned long long* pushedBytes);
|
||||
|
||||
@@ -25,6 +25,9 @@ foreach(listName IN ITEMS @MGL_SPLIT_ARM_TEST_LISTS@)
|
||||
elseif(entry MATCHES "PersistentCoherentMapScenario.TheMapLandsInTheArmItsLaneDeclares$")
|
||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||
"MGITEST_PMAP_LANE=1;MGITEST_PERSISTENT_MAP_ARM=emulated;MOBILEGL_PIPE_STATS=1;MOBILEGL_PIPE_STATS_PERIOD=1")
|
||||
elseif(entry MATCHES "PersistentCoherentMapScenario.ThePushIsTheOnlyRouteAWriteTakesToTheServer$")
|
||||
# The case takes the push away, which only the emulated arm has (R-6: every split arm).
|
||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT "MGITEST_PERSISTENT_MAP_ARM=emulated")
|
||||
elseif(entry MATCHES "LargeArenaAdoptionScenario.TheArenaLandsInTheTierItsLaneDeclares$")
|
||||
# P11 A2: every split arm runs T2, so the arena is declared emulated.
|
||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT "MGITEST_PERSISTENT_MAP_ARM=emulated")
|
||||
@@ -89,6 +92,8 @@ foreach(scenario @MGL_SPLIT_SMALL_RING_SCENARIOS@)
|
||||
elseif(entry MATCHES "PersistentCoherentMapScenario.TheMapLandsInTheArmItsLaneDeclares$")
|
||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||
"MGITEST_PMAP_LANE=1;MGITEST_PERSISTENT_MAP_ARM=emulated;MOBILEGL_PIPE_STATS=1;MOBILEGL_PIPE_STATS_PERIOD=1")
|
||||
elseif(entry MATCHES "PersistentCoherentMapScenario.ThePushIsTheOnlyRouteAWriteTakesToTheServer$")
|
||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT "MGITEST_PERSISTENT_MAP_ARM=emulated")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
@@ -445,6 +445,50 @@ void main() { oColor = vec4(vColor, 1.0); }
|
||||
Gl().EndFrame();
|
||||
}
|
||||
|
||||
// E3(a): the push is the ONLY route a coherent write takes to the server. The cases above go
|
||||
// green just as well if something else delivered the bytes - an unmap or flush record, a
|
||||
// whole-buffer re-sync, the live-host-writes state record, an inproc server reading client
|
||||
// memory - so this one takes the push away and requires the next draw to miss the write.
|
||||
// Forget is what an unmap or a destroy calls and leaves the mapping itself alone; the
|
||||
// re-announce is the call every map-state change makes, and the next draw must see the write.
|
||||
TEST_F(PersistentCoherentMapScenario, ThePushIsTheOnlyRouteAWriteTakesToTheServer) {
|
||||
if (!Ready() || IsSkipped()) return;
|
||||
if (!SplitLane::IsSplitLane() || SplitLane::DeclaredPersistentMapArm() != "emulated") {
|
||||
GTEST_SKIP() << "the push exists only on the emulated arm of a split transport, and this lane "
|
||||
"declares no such arm (MGITEST_PERSISTENT_MAP_ARM=emulated, set per entry by "
|
||||
"Harness/SplitLogPaths.cmake.in); monolith adopts the store and has no push";
|
||||
}
|
||||
if (!PersistentMapTrackerAvailable()) {
|
||||
GTEST_SKIP() << "Harness/PersistentMapPeek cannot reach the tracker in this build, so the push "
|
||||
"cannot be taken away";
|
||||
}
|
||||
ArmTheDrawState();
|
||||
|
||||
WriteThroughTheMapThenDraw(m_map, 0.0f, 1.0f, 0.0f);
|
||||
const Image pushed = ReadPixels(Gl().Width(), Gl().Height());
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
ASSERT_TRUE(WholeSurfaceIs(pushed, "green", "the write the push carries, before it is taken away"));
|
||||
|
||||
ASSERT_TRUE(ForgetLivePersistentMap(m_vbo)) << "no frontend BufferObject behind GL buffer " << m_vbo;
|
||||
WriteThroughTheMapThenDraw(m_map, 1.0f, 0.0f, 0.0f);
|
||||
const Image unpushed = ReadPixels(Gl().Width(), Gl().Height());
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_TRUE(WholeSurfaceIs(unpushed, "green",
|
||||
"a write through a mapping the tracker has forgotten: red here means "
|
||||
"something other than the persistent-map push delivered it, and the "
|
||||
"two cases above would stay green without the push"));
|
||||
|
||||
ASSERT_TRUE(ReannounceLivePersistentMap(m_vbo)) << "no frontend BufferObject behind GL buffer " << m_vbo;
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
const Image repushed = ReadPixels(Gl().Width(), Gl().Height());
|
||||
EXPECT_EQ(FirstGLError(), 0u);
|
||||
EXPECT_TRUE(WholeSurfaceIs(repushed, "red",
|
||||
"the same write after the map is announced again: the tracker must "
|
||||
"push the whole mapping once, or the green above proves nothing"));
|
||||
AssertOrRecordArm(m_vbo, "after the push was taken away and given back");
|
||||
Gl().EndFrame();
|
||||
}
|
||||
|
||||
// E3(c) and the black-box half of E3(d). ONE reading case, in a lane of its own, for the
|
||||
// reason PipeStatsWindow.h gives: the library truncates its log per process, so two readers
|
||||
// in one lane race under `ctest -j`.
|
||||
|
||||
@@ -35,7 +35,13 @@ struct E1BoundaryPeer : Codec::WireVerbSink {
|
||||
}
|
||||
};
|
||||
|
||||
void CheckE1Boundary(Bool serverCap, MGPWireOp op, Bool expectWait, const char* diagnostic) {
|
||||
// How the probe's record leaves the client. Rule is EmitAndWait, whose wait rule the cases
|
||||
// test. PublishOnly encodes through the session's own encoder and publishes with no wait at all,
|
||||
// so a case can show the probe reads a missing wait as one.
|
||||
enum class E1Emit { Rule, PublishOnly };
|
||||
|
||||
void CheckE1Boundary(Bool serverCap, MGPWireOp op, Bool expectWait, const char* diagnostic,
|
||||
E1Emit emit = E1Emit::Rule) {
|
||||
const auto child = RunInChild([=] {
|
||||
::alarm(15);
|
||||
const char* barrier = std::getenv("MOBILEGL_IPC_VERB_BARRIER");
|
||||
@@ -59,10 +65,17 @@ void CheckE1Boundary(Bool serverCap, MGPWireOp op, Bool expectWait, const char*
|
||||
producer.*PeerMember(ProducerBellTag{}) = &bell;
|
||||
const MGPApplierReset reset{};
|
||||
const MGPClear clear{};
|
||||
const void* payload = op == MGPWireOp::ApplierReset ? static_cast<const void*>(&reset) : &clear;
|
||||
const Uint64 payloadBytes = op == MGPWireOp::ApplierReset ? sizeof(reset) : sizeof(clear);
|
||||
// P15: applier_reset is the one kWaitApplied row left (generate_mipmap went async).
|
||||
const Uint64 seq = op == MGPWireOp::ApplierReset
|
||||
? session.EmitAndWait(op, &reset, sizeof(reset), nullptr, 0, nullptr, 0, nullptr)
|
||||
: session.EmitAndWait(op, &clear, sizeof(clear), nullptr, 0, nullptr, 0, nullptr);
|
||||
Uint64 seq = Codec::kInvalidSeq;
|
||||
if (emit == E1Emit::PublishOnly) {
|
||||
seq = session.Encoder().EncodeRecord(op, payload, payloadBytes);
|
||||
if (seq == Codec::kInvalidSeq) ::_exit(87);
|
||||
producer.PublishAndNotify(seq);
|
||||
} else {
|
||||
seq = session.EmitAndWait(op, payload, payloadBytes, nullptr, 0, nullptr, 0, nullptr);
|
||||
}
|
||||
// Observe BEFORE allowing the peer to complete a non-waiting emission.
|
||||
const Bool parked = bell.entered.load();
|
||||
const Bool appliedBeforeReturn = session.Control()->Progress.appliedSeq.load() >= seq;
|
||||
@@ -97,6 +110,19 @@ TEST(RemoteWaitBoundaryControl, AppliedClassWaitsWithRunAheadCap) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// The control for the case above: the same ApplierReset, published with no wait. The probe has
|
||||
// to read it as not parked, or a wait that never happened would pass the cases that must wait.
|
||||
TEST(RemoteWaitBoundaryControl, AnUnwaitedPublishIsSeenAsNoWait) {
|
||||
#if MGTEST_HAVE_FORK
|
||||
ASSERT_EQ(MGPipeWaitClassFor(MGPWireOp::ApplierReset), kWaitApplied);
|
||||
CheckE1Boundary(true, MGPWireOp::ApplierReset, false,
|
||||
"E1 control: an ApplierReset published without a wait was observed as a wait",
|
||||
E1Emit::PublishOnly);
|
||||
#else
|
||||
GTEST_SKIP() << "E1 requires POSIX child isolation";
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(RemoteWaitBoundaryControl, MissingServerCapKeepsClearLockstep) {
|
||||
#if MGTEST_HAVE_FORK
|
||||
ASSERT_EQ(MGPipeWaitClassFor(MGPWireOp::Clear), kWaitNone);
|
||||
|
||||
Reference in New Issue
Block a user