#!/bin/sh # Assemble hello.as34.g with as34, link it with ld34, extract .text, then # compare against the TI-GSPA-built payload and (optionally) run MAME. # # tools/as34/test.sh # REPO=$PWD MAME=/path/to/vt1200 tools/as34/test.sh # # Without REPO/MAME only the byte comparison runs. set -eu here=$(cd "$(dirname "$0")" && pwd) builddir=${AS34_BUILD_DIR:-"$here/build"} as34="$builddir/src/gsp/binutils/as34/as34" ld34="$builddir/src/gsp/binutils/ld34/ld34" if [ ! -x "$as34" ] || [ ! -x "$ld34" ]; then echo "tools not built; run tools/as34/build.sh first" >&2 exit 1 fi work="$builddir/work" mkdir -p "$work" "$work/evidence" cp "$here/hello.as34.g" "$work/hello.as34.g" cd "$work" "$as34" hello.as34.g "$ld34" -c -T 1800000 -e_start hello.as34.go -o hello.out -m hello.map python3 "$here/extract.py" hello.out hello.bin echo if [ -n "${REPO:-}" ] && [ -f "$REPO/harness/hello-world/payload.bin" ]; then expected="$REPO/harness/hello-world/payload.bin" else expected="$here/expected-payload.bin" fi if cmp hello.bin "$expected"; then echo "PASS: hello.bin is byte-identical to $expected" else echo "FAIL: hello.bin differs from $expected" >&2 exit 1 fi if [ -n "${MAME:-}" ] && [ -n "${REPO:-}" ]; then echo echo "running MAME acceptance test" out=$(cd "$REPO" && HELLO_END=150 HELLO_PAYLOAD="$work/hello.bin" \ VT1200_DUMP_FRAME=145 VT1200_DUMP_RAM=145 \ VT1200_DUMP_DIR="$work/evidence" \ "$MAME" vt1200 -rompath harness/mame/roms -video none -sound none \ -nothrottle -debug -debugger none \ -autoboot_script harness/mame/hello.lua -autoboot_delay 0 2>&1) echo "$out" | grep -E "MAGIC|COUNT|VRAM block|PC at|lit =" if echo "$out" | grep -q "WRONG"; then echo "FAIL: MAME reported WRONG" >&2 exit 1 fi if ! echo "$out" | grep -q "1024 stores ok"; then echo "FAIL: counter did not reach 0x400" >&2 exit 1 fi if ! echo "$out" | grep -q "VRAM block 1024/1024 words are FFFF, 0 holes"; then echo "FAIL: VRAM block not complete" >&2 exit 1 fi echo "PASS: MAME markers and VRAM block" fi