arm32probe.sh (1545B)
1 #!/usr/bin/env bash 2 # arm32probe.sh — fast single-case arm32 bring-up probe. 3 # arm32probe.sh <case.toy|case.c> [opt] compile+link+run under qemu, vs .expected 4 # arm32probe.sh --dis <case.toy> [opt] compile + objdump the .text 5 # KIT defaults to build/release/kit. Sets up the bare stub once under /tmp/arm32probe. 6 set -u 7 ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" 8 export KIT="${KIT:-$ROOT/build/release/kit}" 9 source "$ROOT/test/lib/exec_bare.sh" 10 WORK="${ARM32PROBE_WORK:-/tmp/arm32probe}"; mkdir -p "$WORK" 11 exec_bare_setup arm32 "$WORK" main >/"$WORK/setup.log" 2>&1 || { echo "setup failed"; cat "$WORK/setup.log"; exit 3; } 12 13 dis=0 14 if [ "${1:-}" = "--dis" ]; then dis=1; shift; fi 15 f="$1"; opt="${2:-0}" 16 name=$(basename "${f%.*}") 17 obj="$WORK/$name.O$opt.o" 18 if ! "$KIT" cc -O"$opt" -target arm-none-eabi -mcpu=cortex-m3 -mfloat-abi=soft \ 19 -ffreestanding -c "$f" -o "$obj" >"$WORK/cc.out" 2>"$WORK/cc.err"; then 20 echo "$name/O$opt: CC-FAIL"; sed 's/^/ | /' "$WORK/cc.err"; exit 1 21 fi 22 if [ -s "$WORK/cc.err" ]; then echo "$name/O$opt: CC-STDERR"; sed 's/^/ | /' "$WORK/cc.err"; fi 23 if [ "$dis" -eq 1 ]; then "$KIT" objdump -d "$obj"; exit 0; fi 24 reason="$(exec_bare_run arm32 "$obj" "$WORK" "$WORK/rc" 2>&1)" 25 if [ $? -eq 2 ]; then echo "$name/O$opt: LINK/RUN-FAIL: $reason"; exit 2; fi 26 rc=$(cat "$WORK/rc" 2>/dev/null || echo 99) 27 exp=$(( $(cat "${f%.*}.expected" 2>/dev/null || echo 0) & 255 )) 28 if [ "$rc" -eq "$exp" ]; then echo "$name/O$opt: PASS (rc=$rc)"; else echo "$name/O$opt: FAIL exp=$exp got=$rc"; fi