Skip to content

Commit

Permalink
Parse test failures. Add missing MBC5 test
Browse files Browse the repository at this point in the history
  • Loading branch information
veikkos committed Jan 6, 2020
1 parent afa0209 commit a718243
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
6 changes: 5 additions & 1 deletion tests/gekkios-tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ TEST(Gekkio, div_write) {
runTest(GEKKIO, "acceptance/timer/div_write.gb");
}

TEST(Gekkio, rom_4Mb) {
TEST(Gekkio, mbc1_rom_4Mb) {
runTest(GEKKIO, "emulator-only/mbc1/rom_4Mb.gb");
}

TEST(Gekkio, mbc5_rom_4Mb) {
runTest(GEKKIO, "emulator-only/mbc5/rom_4Mb.gb");
}

TEST(Gekkio, oam_dma_basic) {
runTest(GEKKIO, "acceptance/oam_dma/basic.gb");
}
Expand Down
32 changes: 23 additions & 9 deletions tests/test-runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,28 @@ static void serialListener(uint8_t b) {
*outputPtr += b;
}

std::function<bool()> getValidator(RomType romType, const std::string& testOutput) {
enum Result {
UNINITIALIZED,
ONGOING,
PASSED,
FAILED
};

std::function<Result()> getValidator(RomType romType, const std::string& testOutput) {
const auto validate = [](const std::string& output, const char* passCondition, const char* failCondition) {
return output.find(passCondition) != std::string::npos ? PASSED :
output.find(failCondition) != std::string::npos ? FAILED : ONGOING;
};

switch (romType) {
case BLARGG:
return [&testOutput]() {
return testOutput.find("Passed") != std::string::npos;
return [&]() {
return validate(testOutput, "Passed", "Failed");
};
case GEKKIO:
return [&testOutput]() {
// Magic number for success as can be found from
// "mooneye-gb/tests/common/lib/quit.s"
return testOutput.find("\x03\x05\x08\x0d\x15\x22") != std::string::npos;
return [&]() {
// Magic numbers as can be found in "mooneye-gb/tests/common/lib/quit.s"
return validate(testOutput, "\x03\x05\x08\x0d\x15\x22", "\x42\x42\x42\x42\x42\x42");
};
default:
return nullptr;
Expand Down Expand Up @@ -55,10 +66,13 @@ void runTest(RomType romType, const char* romPath) {
ASSERT_TRUE(validator);

int i = 4 * 60;
while (--i && !validator())
Result result = UNINITIALIZED;
do {
run(&chester);
result = validator();
} while(--i && result == ONGOING);

EXPECT_LT(0, i);
EXPECT_EQ(PASSED, result);

uninit(&chester);
}

0 comments on commit a718243

Please sign in to comment.