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 16 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.
 
- Public Member Functions inherited from Kinoko::KSystem

Static Public Member Functions

static KTestSystemCreateInstance ()
 
static void DestroyInstance ()
 
static KTestSystemInstance ()
 

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< TestCasem_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 249 of file KTestSystem.cc.

Member Function Documentation

◆ ~KTestSystem()

Kinoko::KTestSystem::~KTestSystem ( )
overrideprivate

Definition at line 251 of file KTestSystem.cc.

◆ calc()

void Kinoko::KTestSystem::calc ( )
overridevirtual

Executes a frame.

Implements Kinoko::KSystem.

Definition at line 108 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 306 of file KTestSystem.cc.

◆ checkDesync() [1/3]

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

Definition at line 105 of file KTestSystem.hh.

◆ checkDesync() [2/3]

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

Definition at line 64 of file KTestSystem.hh.

◆ checkDesync() [3/3]

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

Definition at line 82 of file KTestSystem.hh.

◆ CreateInstance()

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

Definition at line 236 of file KTestSystem.cc.

◆ DestroyInstance()

void Kinoko::KTestSystem::DestroyInstance ( )
static

Definition at line 242 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 325 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 458 of file KTestSystem.cc.

◆ init()

void Kinoko::KTestSystem::init ( )
overridevirtual

Initializes the system.

Implements Kinoko::KSystem.

Definition at line 33 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 50 of file KTestSystem.cc.

◆ Instance()

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

Definition at line 26 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 466 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 138 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 296 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 115 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 433 of file KTestSystem.cc.

◆ startNextTestCase()

void Kinoko::KTestSystem::startNextTestCase ( )
private

Starts the next test case.

Definition at line 259 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 386 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 447 of file KTestSystem.cc.

Member Data Documentation

◆ m_currentFrame

u16 Kinoko::KTestSystem::m_currentFrame
private

Definition at line 152 of file KTestSystem.hh.

◆ m_frameCount

u16 Kinoko::KTestSystem::m_frameCount
private

Definition at line 151 of file KTestSystem.hh.

◆ m_sceneMgr

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

Definition at line 144 of file KTestSystem.hh.

◆ m_stream

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

Definition at line 145 of file KTestSystem.hh.

◆ m_sync

bool Kinoko::KTestSystem::m_sync
private

Definition at line 153 of file KTestSystem.hh.

◆ m_testCases

std::queue<TestCase> Kinoko::KTestSystem::m_testCases
private

Definition at line 146 of file KTestSystem.hh.

◆ m_testMode

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

Differentiates between test suite and ghost+krkg.

Definition at line 147 of file KTestSystem.hh.

◆ m_versionMajor

u16 Kinoko::KTestSystem::m_versionMajor
private

Definition at line 149 of file KTestSystem.hh.

◆ m_versionMinor

u16 Kinoko::KTestSystem::m_versionMinor
private

Definition at line 150 of file KTestSystem.hh.