#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Compare two boundary traces with the reference's own reader and comparison. compare_traces.py REFERENCE.jsonl OURS.jsonl Prints "traces are identical" and exits 0, or the first divergence (its position and every differing field) and exits 1. Run it with the reference's interpreter. ``lockstep.py`` calls it only when the two files are not equal byte for byte, so a pass costs no parsing; this script then says where. """ from __future__ import annotations import json import sys from w65c816.trace import first_trace_divergence, read_trace def main() -> int: if len(sys.argv) != 3: print(__doc__, file=sys.stderr) return 2 with open(sys.argv[1]) as left, open(sys.argv[2]) as right: divergence = first_trace_divergence(read_trace(left), read_trace(right)) if divergence is None: print("traces are identical (as records; the files differ in form)") return 0 print(json.dumps(divergence.as_dict(), indent=1)) return 1 if __name__ == "__main__": sys.exit(main())