Description
For automated testing of Z80 binaries (e.g., book examples), mze needs a way to signal pass/fail from within the Z80 program. Currently there's no mechanism for a Z80 program to communicate a test result back to the host.
Proposed mechanisms
-
Exit code via port write: Write to a special I/O port (e.g., OUT ($FF),A) to set the process exit code. A=0 = pass, A≠0 = fail.
-
Halt detection: If execution reaches HALT instruction, exit cleanly (code 0). If execution hits --timeout, exit with error (code 1).
-
Memory assertion: After execution, check specific memory locations for expected values. Could be a flag like --assert 0x9000=0x42 that checks memory after the program terminates.
Context
We want make test-run in the book repo to:
- Assemble each .a80 example with sjasmplus
- Run the binary through
mze with a timeout
- Report pass/fail based on exit code
Currently mze always exits with code 0, even if the program crashes or loops forever (timeout just prints a message).
Current behavior
mze test.bin --timeout 1000; echo $?
# Always prints 0, even on timeout
Desired behavior
mze test.bin --timeout 1000; echo $?
# 0 if program terminated normally (RET/HALT)
# 1 if timeout reached
# N if program wrote N to exit port
Description
For automated testing of Z80 binaries (e.g., book examples),
mzeneeds a way to signal pass/fail from within the Z80 program. Currently there's no mechanism for a Z80 program to communicate a test result back to the host.Proposed mechanisms
Exit code via port write: Write to a special I/O port (e.g.,
OUT ($FF),A) to set the process exit code.A=0= pass,A≠0= fail.Halt detection: If execution reaches
HALTinstruction, exit cleanly (code 0). If execution hits--timeout, exit with error (code 1).Memory assertion: After execution, check specific memory locations for expected values. Could be a flag like
--assert 0x9000=0x42that checks memory after the program terminates.Context
We want
make test-runin the book repo to:mzewith a timeoutCurrently
mzealways exits with code 0, even if the program crashes or loops forever (timeout just prints a message).Current behavior
Desired behavior