2019-05-28 01:04:31 +10:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# no "set -e" because we test errors
|
|
|
|
|
|
|
|
ZASM=../../emul/zasm/zasm
|
|
|
|
|
|
|
|
chkerr() {
|
|
|
|
echo "Check that '$1' results in error $2"
|
|
|
|
${ZASM} <<< $1 > /dev/null
|
|
|
|
local res=$?
|
|
|
|
if [[ $res == $2 ]]; then
|
|
|
|
echo "Good!"
|
|
|
|
else
|
|
|
|
echo "$res != $2"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-05-28 07:45:05 +10:00
|
|
|
chkoom() {
|
|
|
|
echo "Trying OOM error..."
|
|
|
|
local s=""
|
|
|
|
# 300 x 27-29 bytes > 8192 bytes. Large enough to smash the pool.
|
|
|
|
for i in {1..300}; do
|
|
|
|
s+=".equ abcdefghijklmnopqrstuvwxyz$i 42"
|
|
|
|
s+=$'\n'
|
|
|
|
done
|
|
|
|
${ZASM} <<< "$s" > /dev/null
|
|
|
|
local res=$?
|
|
|
|
if [[ $res == 7 ]]; then
|
|
|
|
echo "Good!"
|
|
|
|
else
|
|
|
|
echo "$res != 7"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-05-28 01:04:31 +10:00
|
|
|
chkerr "foo" 1
|
2019-05-28 01:22:38 +10:00
|
|
|
chkerr "ld a, foo" 2
|
2019-05-28 02:05:42 +10:00
|
|
|
chkerr "ld a, hl" 2
|
2019-05-28 03:44:53 +10:00
|
|
|
chkerr ".db foo" 2
|
2019-05-28 03:52:58 +10:00
|
|
|
chkerr ".dw foo" 2
|
2019-05-28 04:07:07 +10:00
|
|
|
chkerr ".equ foo bar" 2
|
2019-05-28 04:16:40 +10:00
|
|
|
chkerr ".org foo" 2
|
|
|
|
chkerr ".fill foo" 2
|
2019-05-28 01:58:12 +10:00
|
|
|
chkerr "ld a," 3
|
|
|
|
chkerr "ld a, 'A" 3
|
2019-05-28 03:44:53 +10:00
|
|
|
chkerr ".db 0x42," 3
|
2019-05-28 03:52:58 +10:00
|
|
|
chkerr ".dw 0x4242," 3
|
2019-05-28 04:07:07 +10:00
|
|
|
chkerr ".equ" 3
|
|
|
|
chkerr ".equ foo" 3
|
2019-05-28 04:16:40 +10:00
|
|
|
chkerr ".org" 3
|
|
|
|
chkerr ".fill" 3
|
2019-05-28 04:21:46 +10:00
|
|
|
chkerr "#inc" 3
|
|
|
|
chkerr "#inc foo" 3
|
2019-05-28 02:12:21 +10:00
|
|
|
chkerr "ld a, 0x100" 4
|
2019-05-28 03:44:53 +10:00
|
|
|
chkerr ".db 0x100" 4
|
2019-05-28 04:21:46 +10:00
|
|
|
chkerr "#inc \"doesnotexist\"" 5
|
2019-05-28 07:45:05 +10:00
|
|
|
chkerr ".equ foo 42 \\ .equ foo 42" 6
|
|
|
|
chkoom
|