Skip to content
Phosphoricwiki
Contents

The tests

Each of Phosphoric’s claims is backed by a test that would make it fall. Here is what runs, from a chip’s registers up to the browser, and how a skipped test is kept from going unnoticed.

On this page

The suite

make tests runs 70 suites, 1,362 checks, all green. They cover every component, from the processor to the F1 menu:

AreaTargets
Processortest-cpu (including the 105 illegal opcodes), test-cycle (65x02 oracle), the 6502 functional test
Memory and I/Otest-memory, test-io (VIA timing vectors), test-via-lazy
Picturetest-video, test-renderer, test-raster-split, test-ula-ng, test-avi
Soundtest-audio (signal measurement), test-sp0256, test-mea8000, test-midi, test-smf
Storagetest-storage, test-jasmin, test-tape-signal, test-sedoric-tools, test-dsk2hfe
Clock and statestest-clock, test-savestate, test-savestate-determinism
Serial and networktest-serial, test-serial-backends, test-dtl2000, test-picowifi, test-acia6850, test-pia6821
LOCItest-loci (163 tests), test-loci-sdimg, test-loci-hw, test-loci-e2e (12 end-to-end scenarios)
Debugging and controltest-debugger, test-gdbstub, test-control, test-httpapi, test-http-parse
Menu and configurationtest-iomenu, test-iomenu-glue, test-iomenu-cli, test-cards, test-card-template
Browsertest-web-loci, test-web-iomenu, test-web-picowifi (headless Chrome)

External oracles

A test written by the project can be wrong along with it. So Phosphoric also relies on references that do not come from it:

  • SingleStepTests/65x02: 10,000 cases per opcode, with the expected bus trace cycle by cycle. Four properties scored separately, and both cores judged in the same run, so that neither can progress by breaking the other.
  • 6502_functional_test: the 6502’s reference functional test, which passes in full.
  • The vectors are not in the repository (about 1 GB, third-party): make fetch-vectors downloads them, and the CI has a separate step for them.

Measuring instead of comparing

Several tests measure a behaviour instead of comparing frozen bytes:

  • test-audio measures a voice’s frequency (within 0.1%), an envelope’s duration (within 2%), the balance of the noise;
  • test-clock checks that a clock call moves exactly one cycle forward, that peripherals receive one cycle at a time, and that the processor counter equals the scan position over a frame;
  • test-raster-split runs a real 6502 program and looks for lines cut in their middle.

Safety nets

NetWhat it prevents
make test-bencha frame costing more than 1,000 µs (5% of the 20 ms budget) on the reference machine
make test-corpusa picture that would change: local programs replayed at fixed cycles, compared with a manifest of screen fingerprints
make test-cli-goldena change of behaviour during refactoring: about 116 command lines replayed on the old and the new binary; exit code, outputs and produced files must be identical
make test-docs-claimsan unqualified accuracy wording in the showcase documents
make test-comment-diffan English branch that would differ from the French one other than by comments
make tests-stricta test that would go silent: any skip not justified in tests/allowed_skips.txt fails
make coverage-checka line coverage of src/ that would drop below its floor

Robustness

  • Fuzzing (make fuzz, libFuzzer and clang) of the file readers: configuration, floppies, HFE images, HTTP requests, save states, replay movies, MIDI files, symbols, tapes. make test-fuzz-replay replays the seeds and the regressions found.
  • Sanitisers: make SANITIZE=1 tests runs the whole suite under ASan and UBSan.
  • Leaks: make valgrind; the project reports zero leaks.
  • Static analysis: compiler warnings, cppcheck, flawfinder.

The CI

Four workflows run on the English branch, whose code is identical to the French one (decision 0005):

WorkflowWhat it does
linux-citwo builds, full suite in strict mode, oracle and functional test, performance budget, Valgrind; then the suite under ASan and UBSan, 30 s of fuzzing per target, and the coverage floor
windows-buildan .exe cross-built on Linux, with SDL2.dll, and its tests
macos-buildnative build and full suite, on real Apple Silicon
releasea version’s packages: Linux x86_64 and Windows x86_64 (without the ROMs)

Replay movies

--record records a session’s keyboard inputs, frame by frame; --replay replays them. The only non-deterministic input of the emulation is the keyboard matrix (8 bytes): by replaying it bit for bit, a session reproduces exactly. Two replays give screenshots identical to the byte.

It is a regression tool: record once, replay with no display, compare a reference screenshot. The format is readable text, which can be compared line by line.

Sources in the repository : README.md, docs/ACCURACY.md, docs/adr/0001-makefile-seul-build.md, docs/adr/0005-miroirs-fr-en.md, docs/movie_replay.md.