// SPDX-License-Identifier: GPL-3.0-or-later #include "../guest-captures.h" using namespace BasicDiskTests; enum class Scenario { qualification, direct, disk, edited }; static void run(const fs::path& roms, const fs::path& disk, const fs::path& binary, Processor cpu, Profile profile, Scenario scenario, bool capture = false) { const bool survey = scenario != Scenario::qualification; const bool diskLaunch = scenario == Scenario::disk || scenario == Scenario::edited; Session session(roms, disk, cpu, profile); const auto reads = session.reads(), otherReads = session.otherReads(); if (diskLaunch) session.type("LOADM\"SURVEY\":EXEC\r"); else session.launch(binary); if (survey) { session.until("2 MARS"); session.type(diskLaunch ? "2" : "1"); const char *report = "SURVEY: EARTH\nTRAITS: BLUE AND WET\nORBIT FROM SUN: 3"; if (scenario == Scenario::disk) report = "SURVEY: MARS\nTRAITS: RED AND COLD\nORBIT FROM SUN: 4"; if (scenario == Scenario::edited) report = "SURVEY: MARS ORBIT\nTRAITS: DUSTY AND COLD\nORBIT FROM SUN: 4"; session.until(std::string(report) + "\nSURVEY COMPLETE"); if (capture) { session.until("OK"); session.frames(3); saveActiveFrame(*session.machine.snapshot().frame, "survey.ppm"); } } else { session.until("EJECT DISK"); } require(session.reads() > reads && session.otherReads() == otherReads, "Wrong guest device serviced reads"); session.verifyMedia(); if (!survey) { session.eject(); session.type("X"); session.until("STREAMS PASSED"); } session.verifyReturn(); } static void checkMalformedRecords(const fs::path& roms, const fs::path& example, Processor cpu) { Session session(roms, example / "malformed/BAD.DSK", cpu, Profile::fd); for (const char* choice : {"1", "2"}) { session.launch(example / "SURVEY.bin"); session.until("2 MARS"); session.type(choice); session.until("INVALID SURVEY RECORD"); require(session.machine.copyScreenText().find("SURVEY COMPLETE") == std::string::npos, "A malformed record was reported as complete"); session.verifyReturn(); } session.verifyMedia(); } int main(int argc, char** argv) { try { require(argc == 9, "Usage: run ROMDIR QUAL_DISK QUAL_BIN PROFILE SURVEY_PROJECT EDITED_PROJECT CONFIG CAPTURE"); const fs::path example = argv[5], edited = argv[6]; const std::string name = argv[4]; Profile profile; if (name == "disk") profile = Profile::fd; else if (name == "rgb-hd") profile = Profile::rgbHD; else if (name == "rgb-fd") profile = Profile::rgbFD; else if (name == "sdc") profile = Profile::sdc; else throw std::invalid_argument("Unknown profile"); for (auto cpu : {Processor::MC6809, Processor::HD6309}) { auto label = name + (cpu == Processor::MC6809 ? " 6809" : " 6309"); if (std::string(argv[7]) == "Debug") { run(argv[1], argv[2], argv[3], cpu, profile, Scenario::qualification); std::cout << "PASS " << label << " stream qualification, unchanged medium, I/O error and BASIC return" << std::endl; } const auto binary = example / "SURVEY.bin"; run(argv[1], example / "SURVEY.dsk", binary, cpu, profile, Scenario::direct); run(argv[1], example / "SURVEY.dsk", binary, cpu, profile, Scenario::disk, cpu == Processor::MC6809 && std::string(argv[8]) == "capture"); run(argv[1], edited / "SURVEY.dsk", binary, cpu, profile, Scenario::edited); std::cout << "PASS " << label << " " << argv[7] << " Planet Survey direct Earth, disk Mars and edited Mars Orbit, traits and orbit" << std::endl; if (profile == Profile::fd) { checkMalformedRecords(argv[1], example, cpu); std::cout << "PASS " << label << " " << argv[7] << " missing trait and invalid orbit" << std::endl; } } } catch (const std::exception& error) { std::cerr << error.what() << std::endl; return 1; } }