Slightly improved automated tests

This commit is contained in:
Souryo 2014-06-26 20:55:22 -04:00
parent 81c18e17d1
commit 060eb67421
3 changed files with 60 additions and 16 deletions

View file

@ -164,7 +164,8 @@ void Console::LoadState()
bool Console::RunTest(uint8_t *expectedResult)
{
Timer timer;
uint8_t maxWait = 30;
uint8_t maxWait = 60;
uint8_t* lastFrameBuffer = new uint8_t[256 * 240 * 4];
while(true) {
_apu->Exec(_cpu->Exec());
_ppu->Exec();
@ -173,15 +174,22 @@ bool Console::RunTest(uint8_t *expectedResult)
if(memcmp(_ppu->GetFrameBuffer(), expectedResult, 256 * 240 * 4) == 0) {
return true;
}
timer.Reset();
maxWait--;
timer.Reset();
if(memcmp(lastFrameBuffer, _ppu->GetFrameBuffer(), 256 * 240 * 4) != 0) {
memcpy(lastFrameBuffer, _ppu->GetFrameBuffer(), 256 * 240 * 4);
maxWait = 60;
}
maxWait--;
if(maxWait == 0) {
return false;
}
}
}
delete[] lastFrameBuffer;
return false;
}

View file

@ -291,21 +291,56 @@ namespace NES {
}
}
vector<wstring> MainWindow::GetFilesInFolder(wstring folderMask)
vector<wstring> MainWindow::GetFolders(wstring rootFolder)
{
HANDLE hFind;
WIN32_FIND_DATA data;
vector<wstring> files;
vector<wstring> folders;
hFind = FindFirstFile(folderMask.c_str(), &data);
hFind = FindFirstFile((rootFolder + L"*").c_str(), &data);
if(hFind != INVALID_HANDLE_VALUE) {
do {
files.push_back(data.cFileName);
} while(FindNextFile(hFind, &data));
if(data.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY && wcscmp(data.cFileName, L".") != 0 && wcscmp(data.cFileName, L"..") != 0) {
wstring subfolder = rootFolder + data.cFileName + L"\\";
folders.push_back(subfolder);
for(wstring folderName : GetFolders(subfolder.c_str())) {
folders.push_back(folderName);
}
}
}
while(FindNextFile(hFind, &data));
FindClose(hFind);
}
return folders;
}
vector<wstring> MainWindow::GetFilesInFolder(wstring rootFolder, wstring mask, bool recursive)
{
HANDLE hFind;
WIN32_FIND_DATA data;
vector<wstring> folders;
vector<wstring> files;
folders.push_back(rootFolder);
if(recursive) {
for(wstring subFolder : GetFolders(rootFolder)) {
folders.push_back(subFolder);
}
}
for(wstring folder : folders) {
hFind = FindFirstFile((folder + mask).c_str(), &data);
if(hFind != INVALID_HANDLE_VALUE) {
do {
files.push_back(folder + data.cFileName);
} while(FindNextFile(hFind, &data));
FindClose(hFind);
}
}
return files;
}
@ -315,15 +350,15 @@ namespace NES {
int passCount = 0;
int failCount = 0;
int totalCount = 0;
for(wstring testROM : GetFilesInFolder(L"../TestSuite/*.nes")) {
ifstream testResult(L"../TestSuite/" + testROM + L".trt", ios::in | ios::binary);
for(wstring testROM : GetFilesInFolder(L"..\\TestSuite\\", L"*.nes", true)) {
ifstream testResult(testROM + L".trt", ios::in | ios::binary);
if(testResult) {
std::wcout << testROM.substr(13) << ": ";
uint8_t* expectedResult = new uint8_t[256 * 240 * 4];
testResult.read((char*)expectedResult, 256 * 240 * 4);
Console *console = new Console(L"../TestSuite/" + testROM);
std::wcout << testROM << ": ";
Console *console = new Console(testROM);
if(console->RunTest(expectedResult)) {
std::cout << "Passed";
passCount++;
@ -337,7 +372,7 @@ namespace NES {
delete[] expectedResult;
} else {
std::wcout << testROM << ": [No result]" << std::endl;
//std::wcout << "[No result]" << std::endl;
}
totalCount++;
}

View file

@ -27,8 +27,9 @@ namespace NES {
void SaveTestResult();
void RunTests();
vector<wstring> GetFilesInFolder(wstring folderMask);
vector<wstring> GetFolders(wstring rootFolder);
vector<wstring> GetFilesInFolder(wstring folder, wstring mask, bool recursive);
void LimitFPS_Click();
void ShowFPS_Click();