| 50 | } |
| 51 | |
| 52 | int main(int argc, char* argv[]) |
| 53 | { |
| 54 | // Used if the coreThread has been started (need to exit properly ; uses gotos) |
| 55 | int retVal = 0; |
| 56 | |
| 57 | if (argc < 2) |
| 58 | { |
| 59 | std::cerr << "[Error] Needs a path argument, the test config JSON file" << std::endl; |
| 60 | return -1; |
| 61 | } |
| 62 | |
| 63 | if (strcmp(argv[1], "-d") == 0) |
| 64 | { |
| 65 | autotester::debugMode = true; |
| 66 | argv++; |
| 67 | } else { |
| 68 | autotester::debugMode = false; |
| 69 | } |
| 70 | |
| 71 | const std::string jsonPath(argv[1]); |
| 72 | std::string jsonContents; |
| 73 | std::ifstream ifs(jsonPath); |
| 74 | if (ifs.good()) |
| 75 | { |
| 76 | std::getline(ifs, jsonContents, '\0'); |
| 77 | if (!ifs.eof()) { |
| 78 | std::cerr << "[Error] Couldn't read JSON file" << std::endl; |
| 79 | return -1; |
| 80 | } |
| 81 | } else { |
| 82 | std::cerr << "[Error] Couldn't open JSON file at provided path" << std::endl; |
| 83 | return -1; |
| 84 | } |
| 85 | |
| 86 | // Go to the json file's dir to allow relative paths from there |
| 87 | if (chdir(jsonPath.substr(0, jsonPath.find_last_of("/\\")).c_str())) { |
| 88 | std::cerr << "[Error] Couldn't change directory path" << std::endl; |
| 89 | return -1; |
| 90 | } |
| 91 | |
| 92 | if (autotester::loadJSONConfig(jsonContents)) |
| 93 | { |
| 94 | std::cout << jsonPath << " loaded and verified. " << autotester::config.hashes.size() << " unique tests found." << std::endl; |
| 95 | } else { |
| 96 | std::cerr << "[Error] See the test config file format and make sure values are correct" << std::endl; |
| 97 | return -1; |
| 98 | } |
| 99 | |
| 100 | if (cemucore::EMU_STATE_VALID != cemucore::emu_load(cemucore::EMU_DATA_ROM, autotester::config.rom.c_str())) |
| 101 | { |
| 102 | std::cerr << "[Error] Couldn't start emulation!" << std::endl; |
| 103 | return -1; |
| 104 | } |
| 105 | |
| 106 | cemucore::emu_set_run_rate(1000); |
| 107 | cemucore::emu_run(10000); |
| 108 | |
| 109 | // Clear home screen |
nothing calls this directly
no test coverage detected