A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
Kinoko::KTestSystem Class Referencefinal

#include <KTestSystem.hh>

Description

Kinoko system designed to execute tests.

Definition at line 17 of file KTestSystem.hh.

Inheritance diagram for Kinoko::KTestSystem:

Classes

struct  TestCase
struct  TestData

Public Member Functions

void init () override
 Initializes the system.
void calc () override
 Executes a frame.
bool run () override
 Executes a run.
void parseOptions (int argc, char **argv) override
 Parses non-generic command line options.

Static Public Member Functions

static KTestSystem * CreateInstance ()
static void DestroyInstance ()
static KTestSystem * Instance ()

Private Member Functions

 KTestSystem (const KTestSystem &)=delete
 KTestSystem (KTestSystem &&)=delete
template<IntegralType T>
void checkDesync (const T &t0, const T &t1, const char *name)
template<typename T>
void checkDesync (const T &t0, const T &t1, const char *name)
void checkDesync (const f32 &t0, const f32 &t1, const char *name)
void initSuite ()
void startNextTestCase ()
 Starts the next test case.
bool popTestCase ()
 Pops the current test case and frees the KRKG buffer.
bool calcTest ()
 Checks one frame in the test.
TestData findCurrentFrameEntry ()
 Finds the test data of the current frame.
void testFrame (const TestData &data)
 Tests the frame against the provided test data.
bool runTest ()
 Runs a single test case, and ends when the test is finished or when a desync is found.
void writeTestOutput () const
 Writes details about the current test to file.
const TestCasegetCurrentTestCase () const
 Gets the current test case.

Static Private Member Functions

static void OnInit (System::RaceConfig *config, void *arg)
 Initializes the race configuration as needed for test cases.

Private Attributes

EGG::SceneManagerm_sceneMgr
EGG::RamStream m_stream
std::queue< TestCase, std::deque< TestCase, EGG::Allocator< TestCase > > > m_testCases
Host::EOption m_testMode
 Differentiates between test suite and ghost+krkg.
u16 m_versionMajor
u16 m_versionMinor
u16 m_frameCount
u16 m_currentFrame
bool m_sync

Additional Inherited Members

Static Protected Attributes inherited from Kinoko::KSystem
static KSystems_instance = nullptr

Constructor & Destructor Documentation

◆ KTestSystem()

Kinoko::KTestSystem::KTestSystem ( )
private

Definition at line 251 of file KTestSystem.cc.

Member Function Documentation

◆ ~KTestSystem()

Kinoko::KTestSystem::~KTestSystem ( )
overrideprivate

Definition at line 253 of file KTestSystem.cc.

◆ calc()

void Kinoko::KTestSystem::calc ( )
overridevirtual

Executes a frame.

Implements Kinoko::KSystem.

Definition at line 110 of file KTestSystem.cc.

◆ calcTest()

bool Kinoko::KTestSystem::calcTest ( )
private

Checks one frame in the test.

Returns
Whether the test can continue.

Definition at line 308 of file KTestSystem.cc.

◆ checkDesync() [1/3]

void Kinoko::KTestSystem::checkDesync ( const f32 & t0,
const f32 & t1,
const char * name )
inlineprivate

Definition at line 109 of file KTestSystem.hh.

◆ checkDesync() [2/3]

template<typename T>
void Kinoko::KTestSystem::checkDesync ( const T & t0,
const T & t1,
const char * name )
inlineprivate

Definition at line 86 of file KTestSystem.hh.

◆ checkDesync() [3/3]

template<IntegralType T>
void Kinoko::KTestSystem::checkDesync ( const T & t0,
const T & t1,
const char * name )
inlineprivate

Definition at line 68 of file KTestSystem.hh.

◆ CreateInstance()

KTestSystem * Kinoko::KTestSystem::CreateInstance ( )
static

Definition at line 238 of file KTestSystem.cc.

◆ DestroyInstance()

void Kinoko::KTestSystem::DestroyInstance ( )
static

Definition at line 244 of file KTestSystem.cc.

◆ findCurrentFrameEntry()

KTestSystem::TestData Kinoko::KTestSystem::findCurrentFrameEntry ( )
private

Finds the test data of the current frame.

Returns
The test data of the current frame.

Definition at line 327 of file KTestSystem.cc.

◆ getCurrentTestCase()

const KTestSystem::TestCase & Kinoko::KTestSystem::getCurrentTestCase ( ) const
private

Gets the current test case.

In the event that there is no active test case, this gets the next test case.

Returns
The current test case.

Definition at line 460 of file KTestSystem.cc.

◆ init()

void Kinoko::KTestSystem::init ( )
overridevirtual

Initializes the system.

Implements Kinoko::KSystem.

Definition at line 35 of file KTestSystem.cc.

◆ initSuite()

void Kinoko::KTestSystem::initSuite ( )
private

This reads over the KRKG and generates the list of test cases, before starting the first test case and initializing the race scene.

Definition at line 52 of file KTestSystem.cc.

◆ Instance()

KTestSystem * Kinoko::KTestSystem::Instance ( )
inlinestatic

Definition at line 27 of file KTestSystem.hh.

◆ OnInit()

void Kinoko::KTestSystem::OnInit ( System::RaceConfig * config,
void * arg )
staticprivate

Initializes the race configuration as needed for test cases.

Parameters
configThe race configuration instance.
argUnused optional argument.

Definition at line 468 of file KTestSystem.cc.

◆ parseOptions()

void Kinoko::KTestSystem::parseOptions ( int argc,
char ** argv )
overridevirtual

Parses non-generic command line options.

Test mode currently accepts either a suite of tests or a RKG + KRKG.

Parameters
argcThe number of arguments.
argvThe arguments.

Implements Kinoko::KSystem.

Definition at line 140 of file KTestSystem.cc.

◆ popTestCase()

bool Kinoko::KTestSystem::popTestCase ( )
private

Pops the current test case and frees the KRKG buffer.

Returns
Whether the queue still has elements remaining.

Definition at line 298 of file KTestSystem.cc.

◆ run()

bool Kinoko::KTestSystem::run ( )
overridevirtual

Executes a run.

A run consists of iterating over all tests.

Returns
Whether the run was successful or not.

Implements Kinoko::KSystem.

Definition at line 117 of file KTestSystem.cc.

◆ runTest()

bool Kinoko::KTestSystem::runTest ( )
private

Runs a single test case, and ends when the test is finished or when a desync is found.

This will also accumulate results in results.txt.

Returns
Whether the run synchronized or desynchronized.

Definition at line 435 of file KTestSystem.cc.

◆ startNextTestCase()

void Kinoko::KTestSystem::startNextTestCase ( )
private

Starts the next test case.

Definition at line 261 of file KTestSystem.cc.

◆ testFrame()

void Kinoko::KTestSystem::testFrame ( const TestData & data)
private

Tests the frame against the provided test data.

Parameters
dataThe test data to compare against.

Definition at line 388 of file KTestSystem.cc.

◆ writeTestOutput()

void Kinoko::KTestSystem::writeTestOutput ( ) const
private

Writes details about the current test to file.

This is designed to be cumulative across multiple tests.

Definition at line 449 of file KTestSystem.cc.

Member Data Documentation

◆ m_currentFrame

u16 Kinoko::KTestSystem::m_currentFrame
private

Definition at line 156 of file KTestSystem.hh.

◆ m_frameCount

u16 Kinoko::KTestSystem::m_frameCount
private

Definition at line 155 of file KTestSystem.hh.

◆ m_sceneMgr

EGG::SceneManager* Kinoko::KTestSystem::m_sceneMgr
private

Definition at line 148 of file KTestSystem.hh.

◆ m_stream

EGG::RamStream Kinoko::KTestSystem::m_stream
private

Definition at line 149 of file KTestSystem.hh.

◆ m_sync

bool Kinoko::KTestSystem::m_sync
private

Definition at line 157 of file KTestSystem.hh.

◆ m_testCases

std::queue<TestCase, std::deque<TestCase, EGG::Allocator<TestCase> > > Kinoko::KTestSystem::m_testCases
private

Definition at line 150 of file KTestSystem.hh.

◆ m_testMode

Host::EOption Kinoko::KTestSystem::m_testMode
private

Differentiates between test suite and ghost+krkg.

Definition at line 151 of file KTestSystem.hh.

◆ m_versionMajor

u16 Kinoko::KTestSystem::m_versionMajor
private

Definition at line 153 of file KTestSystem.hh.

◆ m_versionMinor

u16 Kinoko::KTestSystem::m_versionMinor
private

Definition at line 154 of file KTestSystem.hh.