Starting to add tests

This commit is contained in:
Sergio Martin 2024-01-11 20:23:32 +01:00
parent 16143afe0d
commit 03e512dc12
6 changed files with 48 additions and 26 deletions

View File

@ -40,12 +40,11 @@ quickerNESCoreSrc = [
# quickerNES Core Configuration
quickerNESCoreCPPFlags = [ '-Wfatal-errors','-Wall' ]
quickerNESCoreIncludeDirs = include_directories(['source/core', 'extern'])
quickerNESCoreDependencies = [ ]
quickerNESCoreCPPFlags = [ ]
quickerNESCoreCFlags = [ ]
quickerNESCoreLinkArgs = [ ]
quickerNESCoreDependency = declare_dependency(
compile_args : [ '-Wfatal-errors','-Wall' ],
include_directories : include_directories(['source', 'source/core', 'extern']),
sources : quickerNESCoreSrc,
)
# Building playback/validation tool
@ -57,18 +56,20 @@ quickerNESPlayerSrc = [
'extern/hqn/options.cpp'
]
quickerNESPlayerIncludeDirs = include_directories([ 'source'])
quickerNESPlayerDependencies = [ dependency('sdl2'), dependency('SDL2_image') ]
quickerNESPlayerCPPFlags = [ '-DNCURSES' ]
quickerNESPlayerCFlags = [ ]
quickerNESPlayerLinkArgs = [ '-lncurses' ]
quickerNESPlayerDependency = declare_dependency(
compile_args : [ '-DNCURSES' ],
dependencies : [ quickerNESCoreDependency, dependency('sdl2'), dependency('SDL2_image') ],
include_directories : include_directories(['source']),
link_args : [ '-lncurses' ],
sources : quickerNESPlayerSrc
)
executable('player',
'source/player.cpp',
sources: [ quickerNESCoreSrc, quickerNESPlayerSrc ],
include_directories: [ quickerNESCoreIncludeDirs, quickerNESPlayerIncludeDirs ],
dependencies: [ quickerNESCoreDependencies, quickerNESPlayerDependencies ],
cpp_args: [ quickerNESCoreCPPFlags, quickerNESPlayerCPPFlags ],
c_args: [ quickerNESCoreCFlags, quickerNESPlayerCFlags ],
link_args: [ quickerNESCoreLinkArgs, quickerNESPlayerLinkArgs ]
dependencies: quickerNESPlayerDependency,
)
# Building tests
if get_option('buildTests') == true
subdir('tests')
endif

View File

@ -0,0 +1,6 @@
option('buildTests',
type : 'boolean',
value : false,
description : 'Build test suite',
yield: true
)

View File

@ -26,7 +26,7 @@ class PlaybackInstance
{
stepData_t step;
step.input = input;
step.stateData = (uint8_t*) calloc(_emu->getStateSize(), 1);
step.stateData = (uint8_t*) malloc(_emu->getStateSize());
_emu->serializeState(step.stateData);
saveBlit(_emu->getInternalEmulator(), step.curBlit, hqn::HQNState::NES_VIDEO_PALETTE, 0, 0, 0, 0);
@ -35,7 +35,7 @@ class PlaybackInstance
}
// Initializes the playback module instance
PlaybackInstance(EmuInstance* emu, const std::string sequenceString, const std::string& overlayPath = "") : _emu(emu)
PlaybackInstance(EmuInstance* emu, const std::vector<std::string>& sequence, const std::string& overlayPath = "") : _emu(emu)
{
// Loading Emulator instance HQN
_hqnState.m_emu = _emu->getInternalEmulator();
@ -43,10 +43,7 @@ class PlaybackInstance
_hqnState.m_emu->set_pixels(video_buffer, Nes_Emu::image_width+8);
// Building sequence information
const auto inputSequence = split(sequenceString, ' ');
// Building sequence information
for (const auto& input : inputSequence)
for (const auto& input : sequence)
{
// Adding new step
addStep(input);

View File

@ -55,6 +55,9 @@ int main(int argc, char *argv[])
auto status = loadStringFromFile(inputSequence, sequenceFilePath.c_str());
if (status == false) EXIT_WITH_ERROR("[ERROR] Could not find or read from sequence file: %s\n", sequenceFilePath.c_str());
// Building sequence information
const auto sequence = split(inputSequence, ' ');
// Initializing terminal
initializeTerminal();
@ -70,13 +73,13 @@ int main(int argc, char *argv[])
auto e = EmuInstance(romFilePath, stateFilePath);
// Creating playback instance
auto p = PlaybackInstance(&e, inputSequence);
auto p = PlaybackInstance(&e, sequence);
// Flag to continue running playback
bool continueRunning = true;
// Variable for current step in view
ssize_t sequenceLength = p.getSequenceLength();
ssize_t sequenceLength = sequence.size();
ssize_t currentStep = 0;
// Flag to display frame information
@ -89,7 +92,7 @@ int main(int argc, char *argv[])
if (disableRender == false) p.renderFrame(currentStep);
// Getting input
const auto& input = p.getInput(currentStep);
const auto& input = sequence[currentStep];
// Getting state data
//const auto stateData = p.getStateData(currentStep);

9
tests/endingChecker.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "argparse/argparse.hpp"
#include "utils.hpp"
#include "emuInstance.hpp"
int main(int argc, char *argv[])
{
return 0;
}

6
tests/meson.build Normal file
View File

@ -0,0 +1,6 @@
nomalloc = environment({'MALLOC_PERTURB_': '0'})
# Adding game ending checks
endingChecker = executable('endingChecker', files(['endingChecker.cpp']), dependencies: [ quickerNESCoreDependency ] )
testSuite = [ 'gameEndings' ]
test('castlevania1AnyPercent', endingChecker, args : ['castlevania1AnyPercent.test'], suite: testSuite)