2021-10-10 20:26:30 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
2021-10-11 13:59:23 +00:00
|
|
|
#include <chrono>
|
2021-10-10 20:26:30 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <filesystem>
|
|
|
|
|
|
|
|
#include "TestRunner.h"
|
2021-10-31 09:49:10 +00:00
|
|
|
#include "checker_t.h"
|
2021-10-10 20:26:30 +00:00
|
|
|
#include "test_t.h"
|
|
|
|
#include "opcode_test_suite_t.h"
|
2021-10-27 08:53:58 +00:00
|
|
|
#include "processor_test_suite_t.h"
|
|
|
|
|
2021-10-10 20:26:30 +00:00
|
|
|
int main() {
|
2021-10-11 09:20:18 +00:00
|
|
|
|
2021-10-27 08:53:58 +00:00
|
|
|
auto directory = std::string("C:\\github\\spectrum\\libraries\\EightBit\\modules\\ProcessorTests\\6502\\v1");
|
2021-10-10 20:26:30 +00:00
|
|
|
|
2021-10-11 13:59:23 +00:00
|
|
|
const auto start_time = std::chrono::steady_clock::now();
|
|
|
|
|
2021-10-21 12:38:44 +00:00
|
|
|
int unimplemented_opcode_count = 0;
|
|
|
|
int invalid_opcode_count = 0;
|
|
|
|
|
2021-10-25 17:40:21 +00:00
|
|
|
TestRunner runner;
|
|
|
|
runner.initialise();
|
|
|
|
|
2021-10-31 09:49:10 +00:00
|
|
|
checker_t checker(runner);
|
|
|
|
checker.initialise();
|
|
|
|
|
2021-10-27 08:53:58 +00:00
|
|
|
processor_test_suite_t m6502_tests(directory);
|
|
|
|
auto opcode_generator = m6502_tests.generator();
|
|
|
|
while (opcode_generator) {
|
|
|
|
|
|
|
|
auto opcode = opcode_generator();
|
|
|
|
|
|
|
|
const auto path = std::filesystem::path(opcode.path());
|
|
|
|
std::cout << "Processing: " << path.filename() << "\n";
|
|
|
|
opcode.load();
|
|
|
|
|
|
|
|
auto test_generator = opcode.generator();
|
2024-03-15 13:16:25 +00:00
|
|
|
std::vector<std::string_view> test_names;
|
2021-10-27 08:53:58 +00:00
|
|
|
while (test_generator) {
|
|
|
|
|
|
|
|
const auto test = test_generator();
|
2021-10-31 09:49:10 +00:00
|
|
|
checker.check(test);
|
|
|
|
if (checker.invalid()) {
|
2024-01-06 12:17:45 +00:00
|
|
|
|
|
|
|
std::cout << "** Failed: " << test.name() << "\n";
|
|
|
|
|
2021-10-27 08:53:58 +00:00
|
|
|
++invalid_opcode_count;
|
2024-01-06 12:17:45 +00:00
|
|
|
|
|
|
|
// Was it just unimplemented?
|
2021-10-31 09:49:10 +00:00
|
|
|
if (checker.unimplemented())
|
2021-10-27 08:53:58 +00:00
|
|
|
++unimplemented_opcode_count;
|
2024-01-06 12:17:45 +00:00
|
|
|
|
|
|
|
// Let's see if we had any successes!
|
|
|
|
if (!test_names.empty()) {
|
|
|
|
std::cout << "**** The follow test variations succeeeded\n";
|
|
|
|
for (const auto& test_name : test_names)
|
|
|
|
std::cout << "****** " << test_name << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// OK, we've attempted an implementation, how did it fail?
|
2021-10-31 09:49:10 +00:00
|
|
|
for (const auto& message : checker.messages())
|
2021-10-27 08:53:58 +00:00
|
|
|
std::cout << "**** " << message << "\n";
|
2024-01-06 12:17:45 +00:00
|
|
|
|
|
|
|
// I'm not really interested in the remaining tests for this opcode
|
2021-10-27 08:53:58 +00:00
|
|
|
break;
|
|
|
|
}
|
2024-01-06 12:17:45 +00:00
|
|
|
|
2024-03-15 13:16:25 +00:00
|
|
|
test_names.push_back(test.name().get_string().value());
|
2021-10-27 08:53:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto finish_time = std::chrono::steady_clock::now();
|
|
|
|
const auto elapsed_time = finish_time - start_time;
|
|
|
|
const auto seconds = std::chrono::duration_cast<std::chrono::duration<double>>(elapsed_time).count();
|
|
|
|
std::cout
|
|
|
|
<< "Elapsed time: " << seconds << " seconds"
|
|
|
|
<< ", unimplemented opcode count: " << unimplemented_opcode_count
|
|
|
|
<< ", invalid opcode count: " << (invalid_opcode_count - unimplemented_opcode_count)
|
|
|
|
<< std::endl;
|
2021-10-20 20:44:43 +00:00
|
|
|
}
|