Browse Source

tests: the nonvacuity trap also restores the mod=11 probe sources

The commit before this one moved Compiler.mod into the EXIT trap; the modrm11
pair was the last file group left out.  The mod=11 table section mutates
tests/probe/modrm11.{py,s} and puts them back after each case, so a run that
died between the two left the probe sources edited.

SAVED_PY / SAVED_S now sit at the top with the other six copies, and
restore_all restores them too.  restore_all copies them directly rather than
calling restore_probe: that function is defined halfway down this file, and a
trap firing before its definition would abort the rest of the restore with
"command not found" -- the copies before it would have landed and the ones
after it would not have.

Verified by SIGTERM-ing a live run the moment modrm11.py went dirty: both
sources come back byte-identical to the pre-run copies.  non-vacuity 78 ok 0
failed; run_all OVERALL: ALL PASS.
Eric Streit 10 giờ trước cách đây
mục cha
commit
5e0312eeb5
1 tập tin đã thay đổi với 16 bổ sung và 5 xóa
  1. 16 5
      shell/tests/nonvacuity.sh

+ 16 - 5
shell/tests/nonvacuity.sh

@@ -133,12 +133,21 @@ DUMP=../tmp/nonvacuity.dump
 # therefore left Compiler.mod half-mutated, with `git status` showing a source
 # that no case had finished with.  It joins the copies above, taken before the
 # first mutation and covered by the same trap.
+#
+# tests/probe/modrm11.{py,s} are the last two: the mod=11 table section mutates
+# them and puts them back after each case, so a run that died between the two
+# left them edited.  They move here for the same reason.  restore_all copies
+# them directly instead of calling restore_probe, which is defined halfway down
+# this file: a trap firing before that definition would abort the rest of the
+# restore with "command not found".
 mkdir -p ../tmp
 SAVED_E=../tmp/nonvacuity.Exec86.mod
 SAVED_SH=../tmp/nonvacuity.Shell.mod
 SAVED_CI=../tmp/nonvacuity.comimage.py
 SAVED_T=../tmp/nonvacuity.comtest.py
 SAVED_C=../tmp/nonvacuity.Compiler.mod
+SAVED_PY=../tmp/nonvacuity.modrm11.py
+SAVED_S=../tmp/nonvacuity.modrm11.s
 
 cp Runtime.mod "$SAVED" || exit 1
 cp Exec86.mod "$SAVED_E" || exit 1
@@ -146,6 +155,8 @@ cp Shell.mod "$SAVED_SH" || exit 1
 cp tests/comimage.py "$SAVED_CI" || exit 1
 cp tests/comtest.py "$SAVED_T" || exit 1
 cp Compiler.mod "$SAVED_C" || exit 1
+cp tests/probe/modrm11.py "$SAVED_PY" || exit 1
+cp tests/probe/modrm11.s "$SAVED_S" || exit 1
 
 restore_all () {
     cp "$SAVED" Runtime.mod
@@ -154,6 +165,8 @@ restore_all () {
     cp "$SAVED_CI" tests/comimage.py
     cp "$SAVED_T" tests/comtest.py
     cp "$SAVED_C" Compiler.mod
+    cp "$SAVED_PY" tests/probe/modrm11.py
+    cp "$SAVED_S" tests/probe/modrm11.s
     "$GM2" -fiso -c Runtime.mod >/dev/null 2>&1
     "$GM2" -fiso -c Exec86.mod >/dev/null 2>&1
     # The shell is rebuilt as well: a test that runs against a binary built
@@ -324,11 +337,9 @@ fi
 echo
 echo "== the mod=11 table (probe/modrm11.py)"
 # These mutate the probe's own sources, not the runtime, so there is no
-# rebuild in the loop.  SAVED_PY / SAVED_S are restored after each case.
-SAVED_PY=../tmp/nonvacuity.modrm11.py
-SAVED_S=../tmp/nonvacuity.modrm11.s
-cp tests/probe/modrm11.py "$SAVED_PY" || exit 1
-cp tests/probe/modrm11.s "$SAVED_S" || exit 1
+# rebuild in the loop.  SAVED_PY / SAVED_S are taken at the top of this file,
+# beside the EXIT trap, so an interrupted run restores them too; each case
+# still puts them back here so the next one starts from the real table.
 
 M11="python3 tests/probe/modrm11.py"
 restore_probe () {