The probe ran every image for a fixed 512 slices of 4096 ARM cycles (2097152). StarOS's EXP-003 images hash MEM2 and time series of operations, which need more (StarOS experiments/proposals/mmu-console.md, P-7 and P-8). --cycles <n> sets the budget: a decimal number of cycles, a whole number of slices, from one slice to 2^30, given once; anything else is a usage error (exit 2), never rounded. Without it the probe runs 2097152 cycles, as before, and the timeout messages name the budget. The parser is in ProbeBudget.h, tested by StarletProbeBudgetTest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
// Copyright 2026 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include <string_view>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include "ProbeBudget.h"
|
|
|
|
namespace StarletBootstrapProbe
|
|
{
|
|
namespace
|
|
{
|
|
// The parsed budget, or 0 when refused.
|
|
u64 Parsed(std::string_view text)
|
|
{
|
|
return ParseCycles(text).value_or(0);
|
|
}
|
|
|
|
TEST(StarletProbeBudget, DefaultIsTheFormerFixedBudget)
|
|
{
|
|
EXPECT_EQ(DEFAULT_CYCLES, u64{2097152});
|
|
EXPECT_EQ(DEFAULT_CYCLES % SLICE_CYCLES, u64{0});
|
|
EXPECT_EQ(Parsed("2097152"), DEFAULT_CYCLES);
|
|
}
|
|
|
|
TEST(StarletProbeBudget, AcceptsWholeSlicesUpToTheMaximum)
|
|
{
|
|
EXPECT_EQ(Parsed("4096"), u64{4096});
|
|
EXPECT_EQ(Parsed("16777216"), u64{16777216});
|
|
EXPECT_EQ(Parsed("1073741824"), MAX_CYCLES);
|
|
// Leading zeros are still a decimal number.
|
|
EXPECT_EQ(Parsed("0008192"), u64{8192});
|
|
}
|
|
|
|
TEST(StarletProbeBudget, RefusesEverythingElse)
|
|
{
|
|
for (const std::string_view text :
|
|
{"", "0", "4095", "4097", "6144", "1073745920", "999999999999", "1234567890123",
|
|
"99999999999999999999", "-4096", "+4096", "0x1000", "4096 ", " 4096", "4k", "4096.0"})
|
|
{
|
|
EXPECT_FALSE(ParseCycles(text).has_value()) << '"' << text << '"';
|
|
}
|
|
}
|
|
} // namespace
|
|
} // namespace StarletBootstrapProbe
|