Files
catarrh d3715c9385 v1.5.0: invalid-INS one-byte re-frame + explicit discard logging
Residual CONCAT mis-frames (4gmodem/A55_sim2/S21p_sim2) traced to a silent
5-byte drop at an invalid-INS T=0 header (0x0f 00 a4 08 04). Drop only the
stray leading byte and re-frame the remaining four via _replay so the real
command (00 a4 08 04 02 2f 00 -> 61 1c) is recovered.

- _note_discard()/_consume_first(): every consumed-but-unemitted byte is
  now logged; idle 0x00/0xFF discards are rate-limited, real data always
  gets an ANN_WARN annotation.
- All read-until-SW loops log skipped non-SW bytes.
- All traces: CONCAT 0; BAD_FCS/GARBAGE 0; test_8/test_7 RESULT OK;
  47/47 unit tests; baseline byte-identical.

History rewritten to a single root commit so no example trace is stored
in the repo (fixtures are local-only, gitignored). README keeps only
generic <trace>.sr placeholders; AGENTS.md retains the fixture names.
2026-09-09 15:51:09 +03:00

52 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Compare current decoder output against saved baseline.
# Usage: ./tools/compare_baseline.sh
# Prerequisites: tests/baseline.txt exists (run capture_baseline.sh first)
set -e
cd "$(dirname "$0")/.."
BASELINE="tests/baseline.txt"
if [ ! -f "$BASELINE" ]; then
echo "ERROR: No baseline found at $BASELINE"
echo "Run ./tools/capture_baseline.sh > tests/baseline.txt first"
exit 1
fi
# Capture current output
CURRENT=$(mktemp)
trap "rm -f $CURRENT" EXIT
./tools/capture_baseline.sh > "$CURRENT" 2>&1
# Compare
echo "=== Comparing against baseline ==="
echo ""
# Strip timestamps and test execution times before comparing
BASELINE_CLEAN=$(mktemp)
CURRENT_CLEAN=$(mktemp)
trap "rm -f $BASELINE_CLEAN $CURRENT_CLEAN" EXIT
grep -v "^=== Baseline captured" "$BASELINE" | grep -v "^Ran [0-9]* tests in" > "$BASELINE_CLEAN"
grep -v "^=== Baseline captured" "$CURRENT" | grep -v "^Ran [0-9]* tests in" > "$CURRENT_CLEAN"
if diff -u "$BASELINE_CLEAN" "$CURRENT_CLEAN"; then
echo "IDENTICAL - no changes detected"
exit 0
else
echo ""
echo "DIFFERENCES FOUND - review above"
echo ""
echo "Key metrics to check:"
echo " - GARBAGE count must be 0 for test_8"
echo " - RESULT must be OK for test_8"
echo " - ETU values must match for all traces"
echo " - No new INVALID Procedure Byte errors"
echo " - CHKSUM ERROR count must not increase"
echo " - BAD_FCS / payload mismatches / suspicious CLA must not increase"
echo " - CONCAT count must be 0 for test_8 / test_7 / 4gmodem"
echo " - Capture APDU count must be >0 when reader log is present"
exit 1
fi