Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,217 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#import <XCTest/XCTest.h>
|
||||
#include "../../../tests/core/CoreChecks.h"
|
||||
#include <exception>
|
||||
#include "../../../src/core/PrinterCapture.h"
|
||||
#include "../../../src/core/MachineSession.h"
|
||||
#include "../../../src/core/CpuMemory.h"
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
@interface CoreTests : XCTestCase
|
||||
@end
|
||||
@implementation CoreTests
|
||||
- (void)testBASICProgramTokens {
|
||||
try { CheckBasicProgramTokens(); } catch (const std::exception& e) { XCTFail(@"%s", e.what()); }
|
||||
}
|
||||
- (void)testBASICProgramValidation {
|
||||
try { CheckBasicProgramValidation(); } catch (const std::exception& e) { XCTFail(@"%s", e.what()); }
|
||||
}
|
||||
- (void)testOptionalLocalBASICPrinterOutput {
|
||||
// Opt-in local integration only. The public test suite contains no ROM data
|
||||
// or machine-specific path; set VCC_PRINTER_ROM to a supplied CoCo 3 ROM.
|
||||
const char* path = std::getenv("VCC_PRINTER_ROM");
|
||||
XCTSkipIf(path == nullptr || *path == '\0', @"Set VCC_PRINTER_ROM to run the optional local BASIC printer check");
|
||||
NSData* source = [NSData dataWithContentsOfFile:[NSString stringWithUTF8String:path]];
|
||||
XCTAssertEqual(source.length, 32768u, "VCC_PRINTER_ROM must name a readable 32 KiB CoCo 3 ROM");
|
||||
if (source.length != 32768) return;
|
||||
const auto* begin = static_cast<const uint8_t*>(source.bytes);
|
||||
std::vector<uint8_t> rom(begin, begin + source.length);
|
||||
auto chord = [](char c) -> uint64_t {
|
||||
if (c >= 'A' && c <= 'Z') return uint64_t{1} << (c - '@');
|
||||
if (c >= '0' && c <= '9') return uint64_t{1} << (32 + c - '0');
|
||||
if (c == '"') return (uint64_t{1} << 34) | (uint64_t{1} << 55);
|
||||
if (c == '#') return (uint64_t{1} << 35) | (uint64_t{1} << 55);
|
||||
if (c == '-') return uint64_t{1} << 45;
|
||||
if (c == ',') return uint64_t{1} << 44;
|
||||
if (c == ' ') return uint64_t{1} << 31;
|
||||
if (c == '\r') return uint64_t{1} << 48;
|
||||
return 0;
|
||||
};
|
||||
using namespace VCC::Mac;
|
||||
for (auto cpu : {Processor::MC6809, Processor::HD6309}) {
|
||||
MachineSession machine; machine.load(rom, cpu); machine.resume();
|
||||
auto frames = [&](unsigned n) { while (n--) machine.advance(); };
|
||||
auto type = [&](const std::string& text) {
|
||||
for (char c : text) { machine.setKeyboard(chord(c)); frames(4); machine.setKeyboard(0); frames(4); }
|
||||
};
|
||||
frames(300);
|
||||
XCTAssertNotEqual(machine.copyScreenText().find("OK"), std::string::npos);
|
||||
machine.printer().setEnabled(true);
|
||||
type("PRINT #-2,\"HELLO FROM PRINTER\"\r"); frames(300);
|
||||
auto text7 = [&] {
|
||||
std::string result;
|
||||
for (uint8_t byte : machine.printer().bytes()) result += char(byte & 0x7f);
|
||||
return result;
|
||||
};
|
||||
XCTAssertEqual(text7(), std::string("HELLO FROM PRINTER\r"), "BASIC PRINT #-2 reaches the serial capture exactly");
|
||||
const auto printed = machine.printer().bytes();
|
||||
std::size_t high = 0;
|
||||
for (uint8_t byte : printed) if (byte & 0x80) ++high;
|
||||
std::printf("BASIC printer %s: PRINT captured %zu bytes, %zu high-bit bytes; raw hex:",
|
||||
cpu == Processor::MC6809 ? "6809" : "6309", printed.size(), high);
|
||||
for (uint8_t byte : printed) std::printf(" %02X", unsigned(byte));
|
||||
std::printf("\n");
|
||||
machine.printer().clear();
|
||||
type("10 PRINT \"HELLO FROM PRINTER\"\rLLIST\r"); frames(300);
|
||||
XCTAssertEqual(text7(), std::string("10 PRINT \"HELLO FROM PRINTER\"\r"), "BASIC LLIST reaches the same serial capture exactly");
|
||||
XCTAssertEqual(machine.printer().droppedBytes(), 0u);
|
||||
std::printf("BASIC printer %s: LLIST captured %zu bytes: %s\n",
|
||||
cpu == Processor::MC6809 ? "6809" : "6309", machine.printer().bytes().size(), text7().c_str());
|
||||
machine.printer().setEnabled(false);
|
||||
const auto stopped = machine.printer().bytes();
|
||||
type("PRINT #-2,\"HELLO FROM PRINTER\"\r"); frames(300);
|
||||
XCTAssertTrue(machine.printer().bytes() == stopped, "Stopping capture leaves the guest running without collecting more output");
|
||||
}
|
||||
}
|
||||
- (void)testPrinterFramingRawBytesAndBound {
|
||||
VCC::Mac::PrinterCapture capture;
|
||||
auto send = [&](uint8_t byte) {
|
||||
capture.sample(1); capture.sample(0);
|
||||
for (unsigned bit = 0; bit < 8; ++bit) capture.sample((byte >> bit) & 1);
|
||||
capture.sample(1); capture.sample(1);
|
||||
};
|
||||
send(0x41); XCTAssertTrue(capture.bytes().empty());
|
||||
capture.setEnabled(true);
|
||||
for (uint8_t value : {0x00, 0x41, 0x80, 0xff, 0x0d, 0x0a}) send(value);
|
||||
const std::vector<uint8_t> expected{0x00, 0x41, 0x80, 0xff, 0x0d, 0x0a};
|
||||
XCTAssertTrue(capture.bytes() == expected); // No 7-bit masking or newline conversion.
|
||||
const auto saved = capture.bytes();
|
||||
auto revision = capture.revision();
|
||||
capture.clear(); XCTAssertTrue(capture.bytes().empty()); XCTAssertGreaterThan(capture.revision(), revision);
|
||||
XCTAssertTrue(saved == expected); // Immutable copy survives Clear.
|
||||
for (std::size_t i = 0; i < capture.capacity + 7; ++i) send(uint8_t(i));
|
||||
XCTAssertEqual(capture.bytes().size(), capture.capacity); XCTAssertEqual(capture.droppedBytes(), 7u);
|
||||
XCTAssertEqual(capture.bytes().front(), 0u); XCTAssertEqual(capture.bytes().back(), 255u);
|
||||
revision = capture.revision();
|
||||
capture.setEnabled(false); send(0x55); XCTAssertEqual(capture.droppedBytes(), 7u);
|
||||
XCTAssertEqual(capture.revision(), revision, "Capture toggles do not change exported content");
|
||||
capture.clear(); XCTAssertEqual(capture.droppedBytes(), 0u); XCTAssertFalse(capture.enabled());
|
||||
}
|
||||
- (void)testPrinterPartialCharactersAndReset {
|
||||
VCC::Mac::PrinterCapture capture; capture.setEnabled(true);
|
||||
capture.sample(0); capture.sample(1); capture.sample(1); // Start and two bits of FF.
|
||||
capture.clear();
|
||||
for (int i = 0; i < 6; ++i) capture.sample(1);
|
||||
XCTAssertEqual(capture.bytes().size(), 1u); XCTAssertEqual(capture.bytes()[0], 0xffu);
|
||||
capture.sample(0); capture.sample(1); // Truncated next byte.
|
||||
capture.resetFraming();
|
||||
capture.sample(1); capture.sample(0);
|
||||
for (int i = 0; i < 8; ++i) capture.sample(0);
|
||||
XCTAssertEqual(capture.bytes().size(), 2u); XCTAssertEqual(capture.bytes()[1], 0u);
|
||||
capture.sample(0); capture.sample(1);
|
||||
capture.setEnabled(false); capture.setEnabled(true); // Resume starts at a new character.
|
||||
capture.sample(0);
|
||||
for (int i = 0; i < 8; ++i) capture.sample(0);
|
||||
XCTAssertEqual(capture.bytes().size(), 3u); XCTAssertEqual(capture.bytes()[2], 0u);
|
||||
}
|
||||
- (void)testGuestPrinterOutputBothProcessorsAndLifetime {
|
||||
using namespace VCC::Mac;
|
||||
for (auto processor : {Processor::MC6809, Processor::HD6309}) {
|
||||
MachineSession machine;
|
||||
std::vector<uint8_t> rom(0x8000, 0x12);
|
||||
std::vector<uint8_t> code{0x86,0x04,0xb7,0xff,0x21}; // Select PIA1 data register.
|
||||
auto sample = [&](unsigned value) { code.insert(code.end(), {0x86,uint8_t(value << 1),0xb7,0xff,0x20}); };
|
||||
const std::vector<uint8_t> message{'H','E','L','L','O',0x0d,0x80};
|
||||
for (uint8_t byte : message) {
|
||||
sample(1); sample(0);
|
||||
for (unsigned bit = 0; bit < 8; ++bit) sample((byte >> bit) & 1);
|
||||
sample(1);
|
||||
}
|
||||
code.insert(code.end(), {0x20,0xfe}); // Guest waits without writing again.
|
||||
std::copy(code.begin(), code.end(), rom.begin()); rom[0x7ffe] = 0x80; rom[0x7fff] = 0;
|
||||
machine.printer().setEnabled(true); machine.load(rom, processor);
|
||||
machine.resume(); machine.advance(); machine.pause();
|
||||
XCTAssertTrue(machine.printer().bytes() == message);
|
||||
const auto before = machine.snapshot();
|
||||
machine.printer().setEnabled(false); machine.printer().setEnabled(true);
|
||||
XCTAssertEqual(machine.snapshot().generation, before.generation);
|
||||
XCTAssertEqual(machine.snapshot().cycles, before.cycles);
|
||||
machine.softReset(); XCTAssertTrue(machine.printer().bytes() == message);
|
||||
machine.reset(); XCTAssertTrue(machine.printer().bytes() == message);
|
||||
auto configuration = machine.snapshot().configuration; configuration.ram = 2;
|
||||
machine.configure(configuration); XCTAssertTrue(machine.printer().bytes() == message);
|
||||
machine.loadDiagnostic(processor); XCTAssertTrue(machine.printer().bytes() == message);
|
||||
machine.shutdown(); XCTAssertTrue(machine.printer().bytes() == message); XCTAssertTrue(machine.printer().enabled());
|
||||
}
|
||||
}
|
||||
- (void)testMachineMemorySettings { [self check:CheckMachineMemorySettings]; }
|
||||
- (void)testMachinePresentationSettings { [self check:CheckMachinePresentationSettings]; }
|
||||
- (void)testConfiguredOverclock { [self check:CheckConfiguredOverclock]; }
|
||||
- (void)testGraphicsPreviewModes { [self check:CheckGraphicsPreviewModes]; }
|
||||
- (void)testGraphicsPreviewColorSets { [self check:CheckGraphicsPreviewColorSets]; }
|
||||
- (void)testSessionVideoOutput { [self check:CheckSessionVideoOutput]; }
|
||||
- (void)testFramePacing { [self check:CheckFramePacing]; }
|
||||
- (void)testAudioProgress { [self check:CheckAudioProgress]; }
|
||||
- (void)testAcceleratedTiming { [self check:CheckAcceleratedTiming]; }
|
||||
- (void)testJoystickComparator { [self check:CheckJoystickComparator]; }
|
||||
- (void)testJoystickRamps { [self check:CheckJoystickRamps]; }
|
||||
- (void)testJoystickSession { [self check:CheckJoystickSession]; }
|
||||
- (void)check:(void (*)())operation {
|
||||
try { operation(); }
|
||||
catch (const std::exception& error) { XCTFail(@"%s", error.what()); }
|
||||
}
|
||||
- (void)testSessionClipboard { [self check:CheckSessionClipboard]; }
|
||||
- (void)testDriveWireProtocol { [self check:CheckDriveWireProtocol]; }
|
||||
- (void)testRamDiskBanks { [self check:CheckRamDisk]; }
|
||||
- (void)testMicrocontrollerExecution { [self check:CheckMicrocontroller]; }
|
||||
- (void)testCartridgeBusIsolation { [self check:CheckCartridgeBus]; }
|
||||
- (void)testExistingCPU { XCTAssertEqual(smoke_cpu(), 0); }
|
||||
- (void)testExistingSpeech { XCTAssertEqual(smoke_sp0256(), 0); }
|
||||
- (void)testExistingPSG { XCTAssertEqual(smoke_ay8913(), 0); }
|
||||
- (void)testExistingCartridgeIntegration { XCTAssertEqual(smoke_ssc_core(), 0); }
|
||||
- (void)test6809Execution { [self check:Check6809Execution]; }
|
||||
- (void)test6309Execution { [self check:Check6309Execution]; }
|
||||
- (void)test6809Interrupts { [self check:Check6809Interrupts]; }
|
||||
- (void)test6309Interrupts { [self check:Check6309Interrupts]; }
|
||||
- (void)test6309Native { [self check:Check6309Native]; }
|
||||
- (void)testCpuDebugHooks { [self check:CheckCpuDebugHooks]; }
|
||||
- (void)testEventScheduler { [self check:CheckEventScheduler]; }
|
||||
- (void)testMmuMapping { [self check:CheckMmuMapping]; }
|
||||
- (void)testMmuRomAndVectors { [self check:CheckMmuRomAndVectors]; }
|
||||
- (void)testMmuLifecycle { [self check:CheckMmuLifecycle]; }
|
||||
- (void)testGimeRegisters { [self check:CheckGimeRegisters]; }
|
||||
- (void)testPiaRegisters { [self check:CheckPiaRegisters]; }
|
||||
- (void)testPiaInterrupts { [self check:CheckPiaInterrupts]; }
|
||||
- (void)testMappedCpuExecution { [self check:CheckMappedCpuExecution]; }
|
||||
- (void)testVideoPixels { [self check:CheckVideoPixels]; }
|
||||
- (void)testVideoModes { [self check:CheckVideoModes]; }
|
||||
- (void)testRasterTiming { [self check:CheckRasterTiming]; }
|
||||
- (void)testGimeTimers { [self check:CheckGimeTimers]; }
|
||||
- (void)testVideoLifecycle { [self check:CheckVideoLifecycle]; }
|
||||
- (void)testFrameStops { [self check:CheckFrameStops]; }
|
||||
- (void)testRasterPixels { [self check:CheckRasterPixels]; }
|
||||
- (void)testSessionLifecycle { [self check:CheckSessionLifecycle]; }
|
||||
- (void)testSessionReset { [self check:CheckSessionReset]; }
|
||||
- (void)testSessionFrameOwnership { [self check:CheckSessionFrameOwnership]; }
|
||||
- (void)testSessionExclusion { [self check:CheckSessionExclusion]; }
|
||||
- (void)testSessionRomValidation { [self check:CheckSessionRomValidation]; }
|
||||
- (void)testSessionAutomaticBoot { [self check:CheckSessionAutomaticBoot]; }
|
||||
- (void)testSessionKeyboard { [self check:CheckSessionKeyboard]; }
|
||||
- (void)testAudioBuffer { [self check:CheckAudioBuffer]; }
|
||||
- (void)testAudioScheduling { [self check:CheckAudioScheduling]; }
|
||||
- (void)testAudioRouting { [self check:CheckAudioRouting]; }
|
||||
- (void)testCassetteImages { [self check:CheckCassetteImages]; }
|
||||
- (void)testCassetteMachine { [self check:CheckCassetteMachine]; }
|
||||
- (void)testSessionSoftReset { [self check:CheckSessionSoftReset]; }
|
||||
- (void)testDiskImages { [self check:CheckDiskImages]; }
|
||||
- (void)testFloppyCommands { [self check:CheckFloppyCommands]; }
|
||||
- (void)testFloppyTransfers { [self check:CheckFloppyTransfers]; }
|
||||
- (void)testFloppyProtection { [self check:CheckFloppyProtection]; }
|
||||
- (void)testBuiltinDeviceBus { [self check:CheckBuiltinDeviceBus]; }
|
||||
- (void)testFloppySession { [self check:CheckFloppySession]; }
|
||||
- (void)testBinaryParsing { [self check:CheckBinaryParsing]; }
|
||||
- (void)testBinaryValidation { [self check:CheckBinaryValidation]; }
|
||||
- (void)testBinarySession { [self check:CheckBinarySession]; }
|
||||
- (void)testBinaryMappedWrites { [self check:CheckBinaryMappedWrites]; }
|
||||
@end
|
||||
Reference in new issue
Block a user