The probe printed the ring's length only. StarOS's EXP-003 images put lines in the ring that REV_TRACE has no room for (the MEM2 monitor, the measurements), so under Dolphin nothing showed them. After the record's summary, --sbr1-record now prints the ring's text between "SBR1 RING BEGIN" and "SBR1 RING END" on stderr, as StarOS's Broadway loader prints it over the Gecko on the console: at most the ring's 4032 bytes, a byte outside printable ASCII and newline, and the backslash, written \xHH. The formatting is in ProbeRing.h, tested by StarletProbeRingTest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
// Copyright 2026 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include <map>
|
|
#include <string>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "ProbeRing.h"
|
|
|
|
namespace StarletBootstrapProbe
|
|
{
|
|
namespace
|
|
{
|
|
// Record bytes by offset; absent bytes read as zero.
|
|
class FakeRecord
|
|
{
|
|
public:
|
|
std::map<u32, u8> bytes;
|
|
void Put(const std::string& text)
|
|
{
|
|
for (size_t index = 0; index < text.size(); ++index)
|
|
bytes[SBR1_RING + static_cast<u32>(index)] = static_cast<u8>(text[index]);
|
|
}
|
|
u8 operator()(u32 offset) const
|
|
{
|
|
const auto it = bytes.find(offset);
|
|
return it == bytes.end() ? 0 : it->second;
|
|
}
|
|
};
|
|
|
|
TEST(StarletProbeRing, PrintsTheTextUpToItsLength)
|
|
{
|
|
FakeRecord record;
|
|
record.Put("REV:BOOT:ENTRY\nEXP3 OWN 23 PAGES 0 CHANGED\nleft over");
|
|
EXPECT_EQ(RingText(record, 0), "");
|
|
EXPECT_EQ(RingText(record, 15), "REV:BOOT:ENTRY\n");
|
|
EXPECT_EQ(RingText(record, 43), "REV:BOOT:ENTRY\nEXP3 OWN 23 PAGES 0 CHANGED\n");
|
|
}
|
|
|
|
TEST(StarletProbeRing, LengthIsClampedToTheRing)
|
|
{
|
|
EXPECT_EQ(SBR1_RING_BYTES, 4032u);
|
|
FakeRecord record;
|
|
record.Put(std::string(SBR1_RING_BYTES, 'x'));
|
|
record.bytes[SBR1_SIZE] = 'y';
|
|
EXPECT_EQ(RingText(record, 0xffffffff), std::string(SBR1_RING_BYTES, 'x'));
|
|
}
|
|
|
|
TEST(StarletProbeRing, EscapesWhatIsNotText)
|
|
{
|
|
FakeRecord record;
|
|
// a, NUL, b, CR, tab, backslash, c, DEL, 0xff, newline: ten bytes.
|
|
record.Put(std::string("a\0b\r\t\\c\x7f\xff\n", 10));
|
|
EXPECT_EQ(RingText(record, 10), "a\\x00b\\x0d\\x09\\x5cc\\x7f\\xff\n");
|
|
}
|
|
} // namespace
|
|
} // namespace StarletBootstrapProbe
|