Skip to content

mze: add exit code / assertion support for automated testing #13

Description

@oisee

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

  1. 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.

  2. Halt detection: If execution reaches HALT instruction, exit cleanly (code 0). If execution hits --timeout, exit with error (code 1).

  3. 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:

  1. Assemble each .a80 example with sjasmplus
  2. Run the binary through mze with a timeout
  3. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions