run-single-test.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. if [ $# = 0 ]
  3. then
  4. echo "Argument required: <test name>"
  5. exit 1
  6. fi
  7. echo "Running test: $1"
  8. rm -rf ut_drive # ut for unit test
  9. rm -f test.cld test.err
  10. mkdir -p ut_drive
  11. cp -f "$1".bas ut_drive/
  12. # National CF-3300 is chosen because it uses BASIC 1.0 and includes a floppy.
  13. openmsx -machine National_CF-3300 -control stdio -diska ut_drive/\
  14. -script output_capture.tcl > /dev/null <<EOF
  15. <openmsx-control>
  16. <command>set save_settings_on_exit false</command>
  17. <command>set renderer none</command>
  18. <command>set maxframeskip 100</command>
  19. <command>set throttle false</command>
  20. <command>after time 30 exit</command>
  21. <command>set power on</command>
  22. <command>type_via_keybuf "\r\rload\"$1.bas\"\rsave\"test.cld\"\r"</command>
  23. </openmsx-control>
  24. EOF
  25. python3-coverage run -a ../asc2cld.py "$1".bas test.cld 1 3>&2 2>&1 1>&3 |\
  26. sed -rn 's/.*BasicError: //p' > test.err
  27. if [ ! -e "$1".out ]
  28. then
  29. # Error expected.
  30. rm -rf ut_drive
  31. # Compare error message with actual error from machine.
  32. # Remove ESC Y sequences and CRs from input, as a normalization.
  33. sed -r -e $(printf 's/\eY..|\r//g') msx.out\
  34. | egrep -A9999 '^load"'\
  35. | egrep -q "$(printf "\n\a?" ; cat test.err)$(printf "\a?\n")" -\
  36. || { echo "Error message differs, test: $1"; exit 1; }
  37. rm -f test.err msx.out
  38. exit 0
  39. fi
  40. # Success expected. Normalize like above to make msx.out and $1.out comparable.
  41. sed -r -e "$(printf 's/\eY..|\r//g')" msx.out | egrep -A9999 '^load"'\
  42. | cmp "$1".out - || { echo "Expected output failed, test: $1"; exit 1; }
  43. # Compare tokenized code.
  44. cmp test.cld ut_drive/test.cld\
  45. || { echo "Mismatch in tokenized code, test: $1"; exit 1; }
  46. # Cleanup
  47. rm -rf ut_drive
  48. rm -f test.err msx.out test.cld