Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.3KB

  1. #!/bin/sh
  2. # no "set -e" because we test errors
  3. ZASM=../../emul/zasm.sh
  4. chkerr() {
  5. echo "Check that '$1' results in error $2"
  6. ${ZASM} > /dev/null <<XXX
  7. $1
  8. XXX
  9. local res=$?
  10. if [ $res = $2 ]; then
  11. echo "Good!"
  12. else
  13. echo "$res != $2"
  14. exit 1
  15. fi
  16. }
  17. chkoom() {
  18. echo "Trying OOM error..."
  19. local tmp=$(mktemp)
  20. # 300 x 27-29 bytes > 8192 bytes. Large enough to smash the pool.
  21. local i=0
  22. while [ "$i" -lt "300" ]; do
  23. echo ".equ abcdefghijklmnopqrstuvwxyz$i 42" >> ${tmp}
  24. i=$(($i+1))
  25. done
  26. ${ZASM} < ${tmp} > /dev/null
  27. local res=$?
  28. rm ${tmp}
  29. if [ $res = 23 ]; then
  30. echo "Good!"
  31. else
  32. echo "$res != 23"
  33. exit 1
  34. fi
  35. }
  36. chkerr "foo" 17
  37. chkerr "ld a, foo" 18
  38. chkerr "ld a, hl" 18
  39. chkerr ".db foo" 18
  40. chkerr ".dw foo" 18
  41. chkerr ".equ foo bar" 18
  42. chkerr ".org foo" 18
  43. chkerr ".fill foo" 18
  44. chkerr "ld a," 19
  45. chkerr "ld a, 'A" 19
  46. chkerr ".db 0x42," 19
  47. chkerr ".dw 0x4242," 19
  48. chkerr ".equ" 19
  49. chkerr ".equ foo" 19
  50. chkerr ".org" 19
  51. chkerr ".fill" 19
  52. chkerr ".inc" 19
  53. chkerr ".inc foo" 19
  54. chkerr "ld a, 0x100" 20
  55. chkerr ".db 0x100" 20
  56. # TODO: find out why this tests fails on Travis but not on my machine...
  57. # chkerr $'nop \ nop \ nop\n.fill 2-$' 20
  58. chkerr ".inc \"doesnotexist\"" 21
  59. chkerr 'foo:\\foo:' 22
  60. chkoom