Publish VCC Plus OSS source distribution for 3.6.2 build 60

This commit is contained in:
Brian Holman committed 2026-11-13 00:14:03 -07:00
commit c652a5276d
1192 files changed
+272368

No files matched your search

+102
View File
@@ -0,0 +1,102 @@
# SPDX-License-Identifier: GPL-3.0-or-later
"""Exercise read-only guest streams through three real DOS ROMs on both CPUs."""
import argparse
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
def qualification_disk(folder, disk_tool):
folder.mkdir()
disk = folder / "QUAL.DSK"
disk.write_bytes(bytes([255]) * (35 * 18 * 256))
files = {
"LARGE.DAT": b"".join(bytes((i + j) & 255 for j in range(256)) for i in range(257)),
"MIXED.TXT": b"A" * 255 + b"\r\nBETA\rRED\nLAST",
"SHORT.DAT": bytes([0, 255, 1, 2, 3, 4, 5, 6, 7]),
# Allocate distinct real directory entries before preparing boundary cases.
"EMPTY0.DAT": b".", "EMPTY1.DAT": b".", "CYCLE.DAT": b".", "INVALID.DAT": b".",
}
for name, data in files.items():
(folder / name).write_bytes(data)
subprocess.run([disk_tool, "--binary", disk, name], cwd=folder, check=True)
raw = bytearray(disk.read_bytes())
fat = (17 * 18 + 1) * 256
directory = fat + 256
for row in range(directory, directory + 256, 32):
name = raw[row:row + 8].rstrip()
granule = raw[row + 13]
if name in (b"EMPTY0", b"EMPTY1"):
raw[fat + granule] = 0xc0 if name == b"EMPTY0" else 0xc1
raw[row + 14:row + 16] = bytes(2)
elif name == b"INVALID":
raw[row + 14:row + 16] = (257).to_bytes(2, "big")
elif name == b"CYCLE":
raw[fat + granule] = granule
disk.write_bytes(raw)
second = folder / "SECOND.DSK"
second.write_bytes(bytes([255]) * (35 * 18 * 256))
(folder / "SIDE.TXT").write_bytes(b"1")
subprocess.run([disk_tool, second, "SIDE.TXT"], cwd=folder, check=True)
(folder / "startup.cfg").write_text("0=QUAL.DSK\n1=SECOND.DSK\n")
return disk
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("runtime", type=Path, help="staged Toolchain directory")
parser.add_argument("core", type=Path, help="current libVCCCore.a")
parser.add_argument("roms", type=Path, help="directory containing the privately supplied ROMs")
parser.add_argument("--profile", action="append", choices=("disk", "rgb-hd", "rgb-fd", "sdc"),
help="limit a diagnostic run to this route (repeatable)")
parser.add_argument("--capture", type=Path, help="save the Disk BASIC Mars report as a PNG")
args = parser.parse_args()
runtime, core, roms = (p.resolve(strict=True) for p in (args.runtime, args.core, args.roms))
fixture = Path(__file__).resolve().parent
root = fixture.parents[2]
with tempfile.TemporaryDirectory(prefix="vcc-streams-") as tmp:
work = Path(tmp)
env = dict(os.environ, VCC_CMOC_COMPAT="1", PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"])
subprocess.run([runtime / "bin/cmoc", "--coco", "-O2", "-Werror", "--org=2800",
"-o", "QUAL.BIN", fixture / "qualification.c", "-lvcccompat", "-ldecbfile"],
env=env, cwd=work, check=True)
disk = qualification_disk(work / "qualification", runtime / "bin/writecocofile")
subprocess.run(["xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
"-I", root / "src", fixture / "run.cpp", core, "-o", work / "run"],
cwd=work, check=True)
for config in ("Debug", "Release"):
example = work / config
shutil.copytree(root / "examples/cmoc/PlanetSurvey", example)
make = [runtime / "bin/make", "disk", "VCC_CONFIGURATION=" + config]
subprocess.run(make, cwd=example, env=env, check=True)
data = (example / "generated/PLANETS.TXT").read_bytes()
if data[254:258] != b"MARS":
raise AssertionError("The published Mars record must straddle the sector boundary")
(example / "startup.cfg").write_text("0=SURVEY.dsk\n")
# Rebuild after editing just the data, as a reader would.
edited = work / (config + "-edited")
shutil.copytree(example, edited)
source = edited / "assets/planets.txt"
lines = source.read_text().splitlines()
lines[lines.index("MARS|RED,COLD|4")] = "MARS ORBIT|DUSTY,COLD|4"
source.write_text("\n".join(lines) + "\n")
subprocess.run(make, cwd=edited, env=env, check=True)
bad = example / "malformed"
bad.mkdir()
(bad / "BAD.DSK").write_bytes(bytes([255]) * (35 * 18 * 256))
(bad / "PLANETS.TXT").write_bytes(b"EARTH|BLUE|3\rMARS|RED,COLD|4X\r")
subprocess.run([runtime / "bin/writecocofile", "BAD.DSK", "PLANETS.TXT"], cwd=bad, check=True)
for mode in args.profile or ("disk", "rgb-hd", "rgb-fd", "sdc"):
capture = args.capture and mode == "disk" and config == "Debug"
subprocess.run([work / "run", roms, disk, work / "QUAL.BIN", mode, example, edited, config,
"capture" if capture else "check"],
cwd=work, check=True)
if capture:
subprocess.run(["sips", "-s", "format", "png", "survey.ppm", "--out", args.capture.resolve()],
cwd=work, check=True)
if __name__ == "__main__":
main()
+105
View File
@@ -0,0 +1,105 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// This executable runs under a real disk ROM. The host supplies two malformed
// directory entries, then ejects the disk only after the program asks for it.
#include <stdio.h>
#include <cmoc.h>
#include <coco.h>
#include <decbfile.h>
#define CHECK(test) do { if (!(test)) { printf("FAIL LINE %u ERR %u\n", (unsigned)__LINE__, (unsigned)vcc_file_error()); return 1; } } while (0)
static unsigned char sector[256];
static DECBDrive callerDrive;
int main(void)
{
FILE *a, *b;
unsigned i;
char text[12];
byte freeBefore, freeAfter;
cls(1);
CHECK(!fopen("ABSENT.TXT", "r") && vcc_file_error() == DECB_ERR_NOT_FOUND);
CHECK(!fopen("SHORT.DAT", "w++") && vcc_file_error() == DECB_ERR_INVALID_ARGUMENT);
CHECK(!fopen("SHORT.DAT:4", "rb") && vcc_file_error() == DECB_ERR_INVALID_ARGUMENT);
CHECK(!fopen("sub/SHORT.DAT", "r") && vcc_file_error() == DECB_ERR_INVALID_ARGUMENT);
CHECK(!fopen("CYCLE.DAT", "r") && vcc_file_error() == DECB_ERR_CORRUPT_FAT);
// Even an unrelated truncate must leave a volume with a cyclic FAT alone.
CHECK(!fopen("SHORT.DAT", "r+b") && vcc_file_error() == DECB_ERR_CORRUPT_FAT);
CHECK(!fopen("SHORT.DAT", "wb") && vcc_file_error() == DECB_ERR_CORRUPT_FAT);
CHECK(!fopen("INVALID.DAT", "r") && vcc_file_error() == DECB_ERR_CORRUPT_DIR);
CHECK(!fopen("SIDE.TXT", "r") && vcc_file_error() == DECB_ERR_NOT_FOUND);
a = fopen("SIDE.TXT:1", "r");
CHECK(a && fgetc(a) == '1' && fclose(a) == 0);
// An application may already be using the sector API on this drive.
CHECK(decb_init(&callerDrive, 1) == DECB_OK);
CHECK(decb_registerDrive(0) == DECB_OK);
CHECK(decb_getNumFreeGranules(0, &freeBefore) == DECB_OK);
// Mark the caller's cached FAT dirty without changing the byte itself.
// A stream must neither overwrite nor discard the caller's pending FAT.
CHECK(decb_setFATEntry(0, 0, callerDrive.fatBuffer[0]) == DECB_OK);
CHECK(!fopen("FENCE.DAT", "w") && vcc_file_error() == DECB_ERR_ALREADY_EXISTS);
CHECK(callerDrive.fatNeedsSave);
callerDrive.fatNeedsSave = FALSE; // fixture wrote the identical value above
a = fopen("mixed.txt:0", "r");
b = fopen("SHORT.DAT", "rb");
CHECK(a && b);
CHECK(!fopen("SHORT.DAT", "rb") && vcc_file_error() == DECB_ERR_OUT_OF_SPACE);
CHECK(fgets(text, 1, a) == text && !text[0]);
for (i = 0; i < 255; ++i) CHECK(fgetc(a) == 'A');
// The CR and LF forming this one line ending came from different sectors.
CHECK(fgetc(a) == '\n');
CHECK(fgets(text, 3, a) == text && strcmp(text, "BE") == 0);
CHECK(fgets(text, sizeof(text), a) == text && strcmp(text, "TA\n") == 0);
CHECK(fgets(text, sizeof(text), a) == text && strcmp(text, "RED\n") == 0);
CHECK(fgets(text, sizeof(text), a) == text && strcmp(text, "LAST") == 0);
CHECK(!fgets(text, sizeof(text), a) && feof(a) && !ferror(a));
CHECK(fclose(a) == 0);
// Zero count and zero size must leave both the file position and flags alone.
CHECK(!fread(sector, 3, 0, b) && !fread(sector, 0, 3, b) && !feof(b));
CHECK(fgetc(b) == 0);
CHECK(fgetc(b) == 255);
// A 16-bit size*count would wrap to zero. Only seven input bytes remain.
memset(sector, 0xee, 8);
CHECK(fread(sector, 2, 32768U, b) == 3);
for (i = 0; i < 7; ++i) CHECK(sector[i] == i + 1);
CHECK(sector[7] == 0xee && feof(b) && !ferror(b));
CHECK(fclose(b) == 0);
// Both empty-file encodings occur on DECB disks.
for (i = 0; i < 2; ++i) {
a = fopen(i ? "EMPTY1.DAT" : "EMPTY0.DAT", "rb");
CHECK(a && !feof(a));
CHECK(fgetc(a) == EOF && feof(a) && !ferror(a));
CHECK(fclose(a) == 0);
}
a = fopen("LARGE.DAT:0", "rb");
CHECK(a);
// 65,792 bytes cross both a granule boundary and the guest's 16-bit limit.
for (i = 0; i < 257; ++i) {
CHECK(fread(sector, 16, 16, a) == 16);
CHECK(sector[0] == (byte)i && sector[255] == (byte)(i + 255));
}
CHECK(!feof(a) && !ferror(a));
CHECK(fgetc(a) == EOF && feof(a) && !ferror(a));
CHECK(fclose(a) == 0);
CHECK(decb_getNumFreeGranules(0, &freeAfter) == DECB_OK && freeBefore == freeAfter);
decb_shutdown();
a = fopen("LARGE.DAT", "rb");
CHECK(a && fread(sector, 1, 256, a) == 256);
printf("EJECT DISK\n");
while (waitkey(0) != 'X') {}
CHECK(fgetc(a) == EOF && ferror(a) == DECB_ERR_IO && !feof(a));
CHECK(fgetc(a) == EOF && ferror(a) == DECB_ERR_IO && !feof(a));
CHECK(fclose(a) == 0);
printf("STREAMS PASSED\n");
return 0;
}
+89
View File
@@ -0,0 +1,89 @@
// 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;
}
}