run_all.sh 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/bin/bash
  2. # Run every check. Non-zero exit if anything fails.
  3. #
  4. # Four suites, in increasing order of "how much could be lying to me":
  5. #
  6. # 1. compile matrix 27 fixtures, verdict + code size + data size ASSERTED
  7. # from expected.tsv. Fast, no pty.
  8. # 2. .COM linker links every fixture, then re-verifies the bytes with an
  9. # independent checker that restates the layout constants
  10. # instead of asking the compiler.
  11. # 3. UI error path pty: W, C on a bad file, editor opens on the error,
  12. # Ctrl-K D, Q. Covers the shell behaviour that only
  13. # exists interactively.
  14. # 4. UI success path pty: Options -> Destination=COM, C, then the .COM is
  15. # checked ON DISK. This is the end-to-end path from
  16. # keystroke to artifact.
  17. #
  18. # RtProbe dumps the runtime size and its 14 entry offsets, so a
  19. # runtime change that moves an entry is visible here.
  20. #
  21. # Three runtime suites run before all of those, because everything else
  22. # trusts the runtime's bytes:
  23. #
  24. # audit_helpers disassembles every one-line emitter in Runtime.mod
  25. # and compares the DECODE against the procedure's NAME.
  26. # This is the only check that can see a wrong ModRM
  27. # that still decodes cleanly, which is the mistake this
  28. # file actually makes: MovSiBx and CmpSiBx were both
  29. # `DC` (= MOV SP,BX / CMP SP,BX) for a long time.
  30. # check_runtime sweeps the built runtime's code region with FCML: no
  31. # desync, every entry and every branch target on an
  32. # instruction boundary, and the whole disassembly equal
  33. # to tests/runtime.golden.
  34. # nonvacuity breaks the runtime six ways and asserts each named
  35. # check goes red for the stated reason. Slower, so it
  36. # is not in the default run: run it when a check's
  37. # sensitivity is in question, or after editing a check.
  38. #
  39. # nonvacuity.sh is NOT run by default: it rebuilds the runtime six times and
  40. # it is a meta-check, so it belongs to "is the harness honest" reviews rather
  41. # than to every change. Run tests/nonvacuity.sh directly after touching any
  42. # of the checks above.
  43. #
  44. # Two more checks guard the ModR/M table itself, which is the input every hand
  45. # written emitter in Runtime.mod depends on:
  46. #
  47. # probe/modrm11.py asks GNU `as` (.code16) to encode the register moves
  48. # and FCML to decode them, and requires the result to
  49. # agree with the hard-coded bytes, the four
  50. # hand-checking anchors, and the table in Runtime.mod.
  51. # This is the only check that can catch the TABLE being
  52. # wrong rather than one emitter: the table shipped once
  53. # with AX dropped off the front of the mod=11 column
  54. # and a duplicate BX invented at the end, which shifts
  55. # every code down by one and makes `89 DC` (MOV SP,BX)
  56. # look like the SI move the name asks for.
  57. # probe/modrm19.s the execution probe for mod=00/01/10, kept as the
  58. # record of how the memory forms were measured. It is
  59. # not run by default: it needs qemu and a hand-built
  60. # floppy image, and its result is already written into
  61. # the table in Runtime.mod, which modrm11.py checks.
  62. # See probe/README.md to re-run it.
  63. #
  64. # rt_exec.py is NOT run: it needs Unicorn, whose 16-bit ModRM decoding is
  65. # wrong on this machine (see SUMMARY.md), so its failures would be the
  66. # emulator's, not the runtime's. Running it by default would be noise.
  67. set -u
  68. D=/home/eric/Projets/Projets-Modula2/MyWork/TP3-comp/shell
  69. GM2=/home/eric/bin/Modula2/Gm2/bin/gm2
  70. cd "$D" || exit 9
  71. fail=0
  72. run () {
  73. name=$1
  74. shift
  75. echo
  76. echo "=============================================================="
  77. echo "== $name"
  78. echo "=============================================================="
  79. if "$@" ; then
  80. echo "-- $name: PASS"
  81. else
  82. echo "-- $name: FAIL (rc=$?)"
  83. fail=1
  84. fi
  85. }
  86. echo "== build =="
  87. make clean >/dev/null 2>&1
  88. if ! make >/tmp/tp_all_mk 2>&1 ; then
  89. echo "BUILD FAIL"
  90. grep -m10 "error:" /tmp/tp_all_mk
  91. exit 1
  92. fi
  93. echo "make rc=0, tpshell $(stat -c%s tpshell) bytes"
  94. # gm2 reports a pass-3 rollup on the compiler during phase 1 of the two-phase
  95. # link; that is expected and is not a build failure (make rc=0 is the check).
  96. run "runtime probe" bash -c '
  97. GM2=/home/eric/bin/Modula2/Gm2/bin/gm2
  98. $GM2 -fiso -o /tmp/tp_rtprobe tests/RtProbe.mod Runtime.o Posix.o \
  99. >/tmp/tp_rt 2>&1 || { grep -m5 error: /tmp/tp_rt; exit 1; }
  100. /tmp/tp_rtprobe'
  101. run "helper audit" python3 tests/audit_helpers.py
  102. run "mod=11 table" python3 tests/probe/modrm11.py
  103. run "runtime image" python3 tests/check_runtime.py
  104. run "compile matrix" tests/run_compile_tests.sh
  105. run "COM linker" tests/run_com_tests.sh
  106. run "UI error path" python3 tests/uitest.py
  107. run "UI success path" python3 tests/comtest.py
  108. echo
  109. echo "=============================================================="
  110. if [ "$fail" -eq 0 ]; then
  111. echo "OVERALL: ALL PASS"
  112. else
  113. echo "OVERALL: FAILURES PRESENT"
  114. fi
  115. echo "=============================================================="
  116. exit $fail