53 constexpr u32 TEST_HEADER_SIGNATURE = 0x54535448;
54 constexpr u32 TEST_FOOTER_SIGNATURE = 0x54535446;
55 constexpr u16 SUITE_MAJOR_VER = 1;
56 constexpr u16 SUITE_MAX_MINOR_VER = 0;
62 if (testMajorVer != SUITE_MAJOR_VER || testMinorVer > SUITE_MAX_MINOR_VER) {
63 PANIC(
"Version not supported! Provided file is %d.%d while Kinoko supports up to %d.%d",
64 testMajorVer, testMinorVer, SUITE_MAJOR_VER, SUITE_MAX_MINOR_VER);
67 for (
u16 i = 0; i < numTestCases; ++i) {
70 PANIC(
"Invalid binary data for test case!");
78 if (nameLen != testCase.
name.size() + 1) {
79 PANIC(
"Test case name length mismatch!");
84 if (rkgPathLen != testCase.
rkgPath.size() + 1) {
85 PANIC(
"Test case RKG Path length mismatch!");
90 if (krkgPathLen != testCase.
krkgPath.size() + 1) {
91 PANIC(
"Test case KRKG Path length mismatch!");
98 PANIC(
"Invalid binary data for test case!");
101 if (totalSize !=
sizeof(
u16) * 4 + nameLen + rkgPathLen + krkgPathLen) {
102 PANIC(
"Unexpected bytes in test case");
142 PANIC(
"Expected suite/ghost/krkg argument!");
145 std::optional<char *> rkgPath;
146 std::optional<char *> krkgPath;
147 std::optional<u16> target;
149 for (
int i = 0; i < argc; ++i) {
152 WARN(
"Expected a flag! Got: %s", argv[i]);
159 PANIC(
"Mode was already set!");
170 PANIC(
"Failed to load suite data!");
179 PANIC(
"Mode was already set!");
189 PANIC(
"Mode was already set!");
194 krkgPath = argv[++i];
200 if (strlen(argv[++i]) > 5) {
201 PANIC(
"Target has too many digits");
203 target = atoi(argv[i]);
204 if (target < 0 || target > std::numeric_limits<u16>::max()) {
205 PANIC(
"Target is out of bounds (expected 0-65535), got %d\n", *target);
212 PANIC(
"Invalid flag!");
218 PANIC(
"'--framecount' is only supported in a single ghost test");
223 PANIC(
"Missing ghost argument!");
227 PANIC(
"Missing KRKG argument!");
234 m_testCases.emplace(*rkgPath, *rkgPath, *krkgPath, *target);
256 WARN(
"KTestSystem instance not explicitly handled!");
262 constexpr u32 KRKG_SIGNATURE = 0x4b524b47;
271 u16 mark =
reinterpret_cast<TestHeader *
>(krkg)->byteOrderMark;
272 std::endian endian = parse<u16>(mark) == 0xfeff ? std::endian::big : std::endian::little;
288 if (front.targetFrame == 0) {
292 front.targetFrame = std::min(front.targetFrame,
m_frameCount);
333 f32 acceleration = 0.0f;
334 f32 softSpeedLimit = 0.0f;
337 f32 raceCompletion = 0.0f;
338 u16 checkpointId = 0;
390 const auto &pos =
object->
pos();
391 const auto &fullRot =
object->fullRot();
392 const auto &extVel =
object->extVel();
393 const auto &intVel =
object->intVel();
394 f32 speed =
object->speed();
395 f32 acceleration =
object->acceleration();
396 f32 softSpeedLimit =
object->softSpeedLimit();
397 const auto &mainRot =
object->mainRot();
398 const auto &angVel2 =
object->angVel2();
401 f32 raceCompletion = player.raceCompletion();
402 u16 checkpointId = player.checkpointId();
403 u8 jugemId = player.jugemId();
451 outStr +=
"\n" + std::string(
m_sync ?
"1" :
"0") +
"\n";
A stream of data stored in memory.
const char * read_string()
Scene * currentScene() const
void changeScene(int nextSceneId)
void createScene(int nextSceneId, Scene *parent)
void destroyScene(Scene *scene)
void setEndian(std::endian endian)
static KSystem * s_instance
void checkDesync(const T &t0, const T &t1, const char *name)
Host::EOption m_testMode
Differentiates between test suite and ghost+krkg.
static KTestSystem * CreateInstance()
bool run() override
Executes a run.
void parseOptions(int argc, char **argv) override
Parses non-generic command line options.
static void OnInit(System::RaceConfig *config, void *arg)
Initializes the race configuration as needed for test cases.
const TestCase & getCurrentTestCase() const
Gets the current test case.
EGG::SceneManager * m_sceneMgr
void startNextTestCase()
Starts the next test case.
void writeTestOutput() const
Writes details about the current test to file.
static void DestroyInstance()
void testFrame(const TestData &data)
Tests the frame against the provided test data.
void calc() override
Executes a frame.
TestData findCurrentFrameEntry()
Finds the test data of the current frame.
std::queue< TestCase, std::deque< TestCase, EGG::Allocator< TestCase > > > m_testCases
bool runTest()
Runs a single test case, and ends when the test is finished or when a desync is found.
void init() override
Initializes the system.
bool popTestCase()
Pops the current test case and frees the KRKG buffer.
static KTestSystem * Instance()
bool calcTest()
Checks one frame in the test.
KartObject * object(size_t i) const
static KartObjectManager * Instance()
const EGG::Vector3f & pos() const
Initializes the player with parameters specified in the provided ghost file.
const Scenario & raceScenario() const
void setGhost(const u8 *rkg)
static void RegisterInitCallback(const InitCallback &callback, void *arg)
static RaceManager * Instance()
const Player & player() const
int Remove(const char *path)
void Append(const char *path, const char *data, size_t size)
u8 * LoadHost(const char *path, size_t &size)
Loads files from host system.
void egg_delete(const T *ptr)
T * egg_new(Args &&...args)
std::optional< EOption > CheckFlag(const char *arg)
Represents the host application.
A quaternion, used to represent 3D rotation.
void read(Stream &stream)
void read(Stream &stream)
Initializes a Vector3f by reading 12 bytes from the stream.
std::array< Player, 12 > players