From 5af0b68e06e7a3716ddb98eae5e443b7bf182ce8 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 27 Oct 2023 20:43:46 +0200 Subject: [PATCH] Add the corpus tests. --- README.md | 78 ++++++++++++++++++++-------------------- build.py | 86 +++++++++++++++++++++++++++++++++++++++++--- build/c.py | 6 ++-- build/utils.py | 37 ++++++++++++++----- dep/emu/build.py | 8 +---- dep/libusbp/build.py | 2 +- 6 files changed, 155 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 8f2f3320..dd2cc632 100644 --- a/README.md +++ b/README.md @@ -103,45 +103,45 @@ particular filesystem and can read (and sometimes write, support varies) files directly from disks, flux files or disk images. Some formats have multiple choices because they can store multiple types of file system. - - - -| Profile | Format | Read? | Write? | Filesystem? | -|:--------|:-------|:-----:|:------:|:------------| -| [`acornadfs`](doc/disk-acornadfs.md) | Acorn ADFS: BBC Micro, Archimedes | 🦖 | | | -| [`acorndfs`](doc/disk-acorndfs.md) | Acorn DFS: Acorn Atom, BBC Micro series | 🦄 | | ACORNDFS | -| [`aeslanier`](doc/disk-aeslanier.md) | AES Lanier "No Problem": 616kB 5.25" 77-track SSDD hard sectored | 🦖 | | | -| [`agat`](doc/disk-agat.md) | Agat: 840kB 5.25" 80-track DS | 🦖 | 🦖 | | -| [`amiga`](doc/disk-amiga.md) | Amiga: 880kB 3.5" DSDD | 🦄 | 🦄 | AMIGAFFS | -| [`ampro`](doc/disk-ampro.md) | Ampro Little Board: CP/M | 🦖 | | CPMFS | -| [`apple2`](doc/disk-apple2.md) | Apple II: Prodos, Appledos, and CP/M | 🦄 | 🦄 | APPLEDOS CPMFS PRODOS | -| [`atarist`](doc/disk-atarist.md) | Atari ST: Almost PC compatible | 🦄 | 🦄 | | -| [`bk`](doc/disk-bk.md) | BK: 800kB 5.25"/3.5" 80-track 10-sector DSDD | 🦖 | 🦖 | | -| [`brother`](doc/disk-brother.md) | Brother word processors: GCR family | 🦄 | 🦄 | BROTHER120 FATFS | -| [`commodore`](doc/disk-commodore.md) | Commodore: 1541, 1581, 8050 and variations | 🦄 | 🦄 | CBMFS | -| [`eco1`](doc/disk-eco1.md) | VDS Eco1: CP/M; 1210kB 77-track mixed format DSHD | 🦖 | | CPMFS | -| [`epsonpf10`](doc/disk-epsonpf10.md) | Epson PF-10: CP/M; 3.5" 40-track DSDD | 🦖 | | CPMFS | -| [`f85`](doc/disk-f85.md) | Durango F85: 461kB 5.25" 77-track SS | 🦖 | | | -| [`fb100`](doc/disk-fb100.md) | Brother FB-100: 100kB 3.5" 40-track SSSD | 🦖 | | | -| [`hplif`](doc/disk-hplif.md) | Hewlett-Packard LIF: a variety of disk formats used by HP | 🦄 | 🦄 | LIF | -| [`ibm`](doc/disk-ibm.md) | IBM PC: Generic PC 3.5"/5.25" disks | 🦄 | 🦄 | FATFS | -| [`icl30`](doc/disk-icl30.md) | ICL Model 30: CP/M; 263kB 35-track DSSD | 🦖 | | CPMFS | -| [`mac`](doc/disk-mac.md) | Macintosh: 400kB/800kB 3.5" GCR | 🦄 | 🦄 | MACHFS | -| [`micropolis`](doc/disk-micropolis.md) | Micropolis: 100tpi MetaFloppy disks | 🦄 | 🦄 | | -| [`ms2000`](doc/disk-ms2000.md) | : MS2000 Microdisk Development System | | | MICRODOS | -| [`mx`](doc/disk-mx.md) | DVK MX: Soviet-era PDP-11 clone | 🦖 | | | -| [`n88basic`](doc/disk-n88basic.md) | N88-BASIC: PC8800/PC98 5.25" 77-track 26-sector DSHD | 🦄 | 🦄 | | -| [`northstar`](doc/disk-northstar.md) | Northstar: 5.25" hard sectored | 🦄 | 🦄 | | -| [`psos`](doc/disk-psos.md) | pSOS: 800kB DSDD with PHILE | 🦄 | 🦄 | PHILE | -| [`rolandd20`](doc/disk-rolandd20.md) | Roland D20: 3.5" electronic synthesiser disks | 🦄 | 🦖 | ROLAND | -| [`rx50`](doc/disk-rx50.md) | Digital RX50: 400kB 5.25" 80-track 10-sector SSDD | 🦖 | 🦖 | | -| [`smaky6`](doc/disk-smaky6.md) | Smaky 6: 308kB 5.25" 77-track 16-sector SSDD, hard sectored | 🦖 | | SMAKY6 | -| [`tids990`](doc/disk-tids990.md) | Texas Instruments DS990: 1126kB 8" DSSD | 🦖 | 🦖 | | -| [`tiki`](doc/disk-tiki.md) | Tiki 100: CP/M | | | CPMFS | -| [`victor9k`](doc/disk-victor9k.md) | Victor 9000 / Sirius One: 1224kB 5.25" DSDD GCR | 🦖 | 🦖 | | -| [`zilogmcz`](doc/disk-zilogmcz.md) | Zilog MCZ: 320kB 8" 77-track SSSD hard-sectored | 🦖 | | ZDOS | -{: .datatable } - + + + +| Profile | Format | Read? | Write? | Filesystem? | +|:--------|:-------|:-----:|:------:|:------------| +| [`acornadfs`](doc/disk-acornadfs.md) | Acorn ADFS: BBC Micro, Archimedes | 🦖 | | | +| [`acorndfs`](doc/disk-acorndfs.md) | Acorn DFS: Acorn Atom, BBC Micro series | 🦄 | | ACORNDFS | +| [`aeslanier`](doc/disk-aeslanier.md) | AES Lanier "No Problem": 616kB 5.25" 77-track SSDD hard sectored | 🦖 | | | +| [`agat`](doc/disk-agat.md) | Agat: 840kB 5.25" 80-track DS | 🦖 | 🦖 | | +| [`amiga`](doc/disk-amiga.md) | Amiga: 880kB 3.5" DSDD | 🦄 | 🦄 | AMIGAFFS | +| [`ampro`](doc/disk-ampro.md) | Ampro Little Board: CP/M | 🦖 | | CPMFS | +| [`apple2`](doc/disk-apple2.md) | Apple II: Prodos, Appledos, and CP/M | 🦄 | 🦄 | APPLEDOS CPMFS PRODOS | +| [`atarist`](doc/disk-atarist.md) | Atari ST: Almost PC compatible | 🦄 | 🦄 | | +| [`bk`](doc/disk-bk.md) | BK: 800kB 5.25"/3.5" 80-track 10-sector DSDD | 🦖 | 🦖 | | +| [`brother`](doc/disk-brother.md) | Brother word processors: GCR family | 🦄 | 🦄 | BROTHER120 FATFS | +| [`commodore`](doc/disk-commodore.md) | Commodore: 1541, 1581, 8050 and variations | 🦄 | 🦄 | CBMFS | +| [`eco1`](doc/disk-eco1.md) | VDS Eco1: CP/M; 1210kB 77-track mixed format DSHD | 🦖 | | CPMFS | +| [`epsonpf10`](doc/disk-epsonpf10.md) | Epson PF-10: CP/M; 3.5" 40-track DSDD | 🦖 | | CPMFS | +| [`f85`](doc/disk-f85.md) | Durango F85: 461kB 5.25" 77-track SS | 🦖 | | | +| [`fb100`](doc/disk-fb100.md) | Brother FB-100: 100kB 3.5" 40-track SSSD | 🦖 | | | +| [`hplif`](doc/disk-hplif.md) | Hewlett-Packard LIF: a variety of disk formats used by HP | 🦄 | 🦄 | LIF | +| [`ibm`](doc/disk-ibm.md) | IBM PC: Generic PC 3.5"/5.25" disks | 🦄 | 🦄 | FATFS | +| [`icl30`](doc/disk-icl30.md) | ICL Model 30: CP/M; 263kB 35-track DSSD | 🦖 | | CPMFS | +| [`mac`](doc/disk-mac.md) | Macintosh: 400kB/800kB 3.5" GCR | 🦄 | 🦄 | MACHFS | +| [`micropolis`](doc/disk-micropolis.md) | Micropolis: 100tpi MetaFloppy disks | 🦄 | 🦄 | | +| [`ms2000`](doc/disk-ms2000.md) | : MS2000 Microdisk Development System | | | MICRODOS | +| [`mx`](doc/disk-mx.md) | DVK MX: Soviet-era PDP-11 clone | 🦖 | | | +| [`n88basic`](doc/disk-n88basic.md) | N88-BASIC: PC8800/PC98 5.25" 77-track 26-sector DSHD | 🦄 | 🦄 | | +| [`northstar`](doc/disk-northstar.md) | Northstar: 5.25" hard sectored | 🦄 | 🦄 | | +| [`psos`](doc/disk-psos.md) | pSOS: 800kB DSDD with PHILE | 🦄 | 🦄 | PHILE | +| [`rolandd20`](doc/disk-rolandd20.md) | Roland D20: 3.5" electronic synthesiser disks | 🦄 | 🦖 | ROLAND | +| [`rx50`](doc/disk-rx50.md) | Digital RX50: 400kB 5.25" 80-track 10-sector SSDD | 🦖 | 🦖 | | +| [`smaky6`](doc/disk-smaky6.md) | Smaky 6: 308kB 5.25" 77-track 16-sector SSDD, hard sectored | 🦖 | | SMAKY6 | +| [`tids990`](doc/disk-tids990.md) | Texas Instruments DS990: 1126kB 8" DSSD | 🦖 | 🦖 | | +| [`tiki`](doc/disk-tiki.md) | Tiki 100: CP/M | | | CPMFS | +| [`victor9k`](doc/disk-victor9k.md) | Victor 9000 / Sirius One: 1224kB 5.25" DSDD GCR | 🦖 | 🦖 | | +| [`zilogmcz`](doc/disk-zilogmcz.md) | Zilog MCZ: 320kB 8" 77-track SSSD hard-sectored | 🦖 | | ZDOS | +{: .datatable } + ### Notes diff --git a/build.py b/build.py index dfbdb107..c26718d8 100644 --- a/build.py +++ b/build.py @@ -2,7 +2,10 @@ from build.c import clibrary, cxxlibrary from build.protobuf import proto, protocc from build.pkg import package +from build.utils import test +from glob import glob import config +import re package(name="protobuf_lib", package="protobuf") package(name="z_lib", package="zlib") @@ -216,6 +219,83 @@ ], ) +corpustests = [] +if not glob("../fluxengine-testdata/data"): + print("fluxengine-testdata not found; skipping corpus tests") +else: + corpus = [ + ("agat", "", "--drive.tpi=96"), + ("amiga", "", "--drive.tpi=135"), + ("apple2", "", "--140 --drive.tpi=96"), + ("atarist", "", "--360 --drive.tpi=135"), + ("atarist", "", "--370 --drive.tpi=135"), + ("atarist", "", "--400 --drive.tpi=135"), + ("atarist", "", "--410 --drive.tpi=135"), + ("atarist", "", "--720 --drive.tpi=135"), + ("atarist", "", "--740 --drive.tpi=135"), + ("atarist", "", "--800 --drive.tpi=135"), + ("atarist", "", "--820 --drive.tpi=135"), + ("bk", "", ""), + ("brother", "", "--120 --drive.tpi=135"), + ("brother", "", "--240 --drive.tpi=135"), + ( + "commodore", + "scripts/commodore1541_test.textpb", + "--171 --drive.tpi=96", + ), + ( + "commodore", + "scripts/commodore1541_test.textpb", + "--192 --drive.tpi=96", + ), + ("commodore", "", "--800 --drive.tpi=135"), + ("commodore", "", "--1620 --drive.tpi=135"), + ("hplif", "", "--264 --drive.tpi=135"), + ("hplif", "", "--608 --drive.tpi=135"), + ("hplif", "", "--616 --drive.tpi=135"), + ("hplif", "", "--770 --drive.tpi=135"), + ("ibm", "", "--1200 --drive.tpi=96"), + ("ibm", "", "--1232 --drive.tpi=96"), + ("ibm", "", "--1440 --drive.tpi=135"), + ("ibm", "", "--1680 --drive.tpi=135"), + ("ibm", "", "--180 --drive.tpi=96"), + ("ibm", "", "--160 --drive.tpi=96"), + ("ibm", "", "--320 --drive.tpi=96"), + ("ibm", "", "--360 --drive.tpi=96"), + ("ibm", "", "--720_96 --drive.tpi=96"), + ("ibm", "", "--720_135 --drive.tpi=135"), + ("mac", "scripts/mac400_test.textpb", "--400 --drive.tpi=135"), + ("mac", "scripts/mac800_test.textpb", "--800 --drive.tpi=135"), + ("n88basic", "", "--drive.tpi=96"), + ("rx50", "", "--drive.tpi=96"), + ("tids990", "", "--drive.tpi=48"), + ("victor9k", "", "--612 --drive.tpi=96"), + ("victor9k", "", "--1224 --drive.tpi=96"), + ] + + for c in corpus: + name = re.sub(r"[^a-zA-Z0-9]", "_", "".join(c), 0) + corpustests += [ + test( + name=f"corpustest_{name}_{format}", + ins=["src+fluxengine"], + deps=["scripts/encodedecodetest.sh"], + commands=[ + "{deps[0]} " + + c[0] + + " " + + format + + " {ins[0]} " + + c[1] + + " " + + c[2] + + ">/dev/null" + ], + label="CORPUSTEST", + ) + for format in ["scp", "flux"] + ] + export( name="all", items={ @@ -225,8 +305,6 @@ "brother240tool$(EXT)": "tools+brother240tool", "upgrade-flux-file$(EXT)": "tools+upgrade-flux-file", } - | ({"FluxEngine.pkg": "src/gui+fluxengine_pkg"} - if config.osx - else {}), - deps=["tests", "src/formats+docs", "scripts+mkdocindex"], + | ({"FluxEngine.pkg": "src/gui+fluxengine_pkg"} if config.osx else {}), + deps=["tests", "src/formats+docs", "scripts+mkdocindex"] + corpustests, ) diff --git a/build/c.py b/build/c.py index b94e73c6..2400fc0a 100644 --- a/build/c.py +++ b/build/c.py @@ -75,7 +75,9 @@ def findsources(name, srcs, deps, cflags, filerule): return objs -def libraryimpl(self, name, srcs, deps, hdrs, cflags, ldflags, commands, label, kind): +def libraryimpl( + self, name, srcs, deps, hdrs, cflags, ldflags, commands, label, kind +): if not srcs and not hdrs: raise ABException( "clibrary contains no sources and no exported headers" @@ -203,7 +205,7 @@ def programimpl( normalrule( replaces=self, ins=(findsources(name, srcs, deps, cflags, filerule) + ars + ars), - outs=[basename(name)+"$(EXT)"], + outs=[basename(name) + "$(EXT)"], deps=deps, label=label, commands=commands, diff --git a/build/utils.py b/build/utils.py index cd51676b..e1a227aa 100644 --- a/build/utils.py +++ b/build/utils.py @@ -1,4 +1,4 @@ -from build.ab import Rule, normalrule, Target, filenameof +from build.ab import Rule, normalrule, Target, filenameof, Targets from os.path import basename @@ -14,11 +14,30 @@ def objectify(self, name, src: Target, symbol): @Rule -def test(self, name, command: Target): - normalrule( - replaces=self, - ins=[command], - outs=["sentinel"], - commands=["{ins[0]}", "touch {outs}"], - label="TEST", - ) +def test( + self, + name, + command: Target = None, + commands=None, + ins: Targets = [], + deps: Targets = [], + label="TEST", +): + if command: + normalrule( + replaces=self, + ins=[command], + outs=["sentinel"], + commands=["{ins[0]}", "touch {outs}"], + deps=deps, + label=label, + ) + else: + normalrule( + replaces=self, + ins=ins, + outs=["sentinel"], + commands=commands + ["touch {outs}"], + deps=deps, + label=label, + ) diff --git a/dep/emu/build.py b/dep/emu/build.py index 9531b053..a18f4db6 100644 --- a/dep/emu/build.py +++ b/dep/emu/build.py @@ -1,9 +1,3 @@ from build.c import clibrary -clibrary( - name="emu", - srcs=["./fnmatch.c"], - hdrs={ - "fnmatch.h": "./fnmatch.h" - } -) \ No newline at end of file +clibrary(name="emu", srcs=["./fnmatch.c"], hdrs={"fnmatch.h": "./fnmatch.h"}) diff --git a/dep/libusbp/build.py b/dep/libusbp/build.py index b6cb4910..2fe67486 100644 --- a/dep/libusbp/build.py +++ b/dep/libusbp/build.py @@ -60,7 +60,7 @@ clibrary( name="libusbp", srcs=srcs, - cflags =["-Idep/libusbp/include", "-Idep/libusbp/src"], + cflags=["-Idep/libusbp/include", "-Idep/libusbp/src"], ldflags=ldflags, deps=deps, hdrs={