qemu and build: review fixes across the rig driver, boot script, and fetch helpers
Bounded waits and validated arguments in run.sh and ui-drive.sh, a seeded settings directory and root-only staged rootfs permissions with their own tests, qmp.py and imgtools.py hardening, the fetch scripts checking what they download, and ASCII typography throughout. Each fix carries its test under qemu/tests or tests/. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N3G6m9Aw5RyVY4ZowtKzEj
This commit is contained in:
@@ -92,8 +92,12 @@ work="$SCRATCH/a"; build_rig "$work"
|
||||
FLARE_EDGE="$SCRATCH/flare-edge-a"
|
||||
mkdir -p "$FLARE_EDGE/tools/modbus-sim"
|
||||
printf '#!/usr/bin/env python3\nimport sys; sys.exit(1)\n' > "$FLARE_EDGE/tools/modbus-sim/mbsim.py"
|
||||
RIG_OUT="$(unset TEST_MAKE_RS_SOCK; export FLARE_EDGE; run_rig "$work"; echo "$RIG_OUT"; echo "RC=$RIG_RC")"
|
||||
rc_line="$(printf '%s\n' "$RIG_OUT" | grep '^RC=')"; RIG_RC="${rc_line#RC=}"
|
||||
# A VAR=val prefix on a function call exports VAR into that one call only
|
||||
# (and any children it spawns) and restores whatever VAR held before once the
|
||||
# call returns -- the same per-case scoping a wrapping subshell gave us, but
|
||||
# without a subshell: run_rig's RIG_OUT/RIG_RC writes land here directly, so
|
||||
# nothing needs to be re-serialized as text and re-parsed back out below.
|
||||
FLARE_EDGE="$FLARE_EDGE" TEST_MAKE_RS_SOCK='' run_rig "$work"
|
||||
[ "$RIG_RC" -ne 0 ] \
|
||||
&& pass "case A: never-appeared rs.sock fails the run (rc=$RIG_RC)" \
|
||||
|| fail "case A: never-appeared rs.sock fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
@@ -112,8 +116,7 @@ printf '#!/usr/bin/env python3\nimport sys; sys.exit(1)\n' > "$FLARE_EDGE/tools/
|
||||
FAKEBIN="$SCRATCH/fakebin-b"; mkdir -p "$FAKEBIN"
|
||||
printf '#!/usr/bin/env bash\necho "FAKE SOCAT: simulated failure" >&2\nexit 1\n' > "$FAKEBIN/socat"
|
||||
chmod +x "$FAKEBIN/socat"
|
||||
RIG_OUT="$(export TEST_MAKE_RS_SOCK=1 FLARE_EDGE; export PATH="$FAKEBIN:$PATH"; run_rig "$work"; echo "$RIG_OUT"; echo "RC=$RIG_RC")"
|
||||
rc_line="$(printf '%s\n' "$RIG_OUT" | grep '^RC=')"; RIG_RC="${rc_line#RC=}"
|
||||
FLARE_EDGE="$FLARE_EDGE" TEST_MAKE_RS_SOCK=1 PATH="$FAKEBIN:$PATH" run_rig "$work"
|
||||
[ "$RIG_RC" -ne 0 ] \
|
||||
&& pass "case B: socat never linking rs.pty fails the run (rc=$RIG_RC)" \
|
||||
|| fail "case B: socat never linking rs.pty fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
@@ -131,8 +134,7 @@ import sys
|
||||
sys.stderr.write("FAKE MBSIM: simulated crash before opening the control socket\n")
|
||||
sys.exit(1)
|
||||
EOS
|
||||
RIG_OUT="$(export TEST_MAKE_RS_SOCK=1 FLARE_EDGE; unset TEST_MBSIM_PID_FILE; run_rig "$work"; echo "$RIG_OUT"; echo "RC=$RIG_RC")"
|
||||
rc_line="$(printf '%s\n' "$RIG_OUT" | grep '^RC=')"; RIG_RC="${rc_line#RC=}"
|
||||
FLARE_EDGE="$FLARE_EDGE" TEST_MAKE_RS_SOCK=1 TEST_MBSIM_PID_FILE='' run_rig "$work"
|
||||
[ "$RIG_RC" -ne 0 ] \
|
||||
&& pass "case C: mbsim.py crashing before rs.ctl fails the run (rc=$RIG_RC)" \
|
||||
|| fail "case C: mbsim.py crashing before rs.ctl fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
@@ -174,8 +176,7 @@ while True:
|
||||
time.sleep(1)
|
||||
EOS
|
||||
PIDFILE="$SCRATCH/mbsim-d.pid"
|
||||
RIG_OUT="$(export TEST_MAKE_RS_SOCK=1 FLARE_EDGE TEST_MBSIM_PID_FILE="$PIDFILE"; run_rig "$work"; echo "$RIG_OUT"; echo "RC=$RIG_RC")"
|
||||
rc_line="$(printf '%s\n' "$RIG_OUT" | grep '^RC=')"; RIG_RC="${rc_line#RC=}"
|
||||
FLARE_EDGE="$FLARE_EDGE" TEST_MAKE_RS_SOCK=1 TEST_MBSIM_PID_FILE="$PIDFILE" run_rig "$work"
|
||||
if [ -s "$PIDFILE" ]; then
|
||||
mbsim_pid="$(cat "$PIDFILE")"
|
||||
if ! kill -0 "$mbsim_pid" 2>/dev/null; then
|
||||
|
||||
Reference in New Issue
Block a user