2019-12-10 01:36:38 +11:00
|
|
|
#!/bin/sh
|
2019-05-28 01:04:31 +10:00
|
|
|
|
|
|
|
# no "set -e" because we test errors
|
|
|
|
|
2020-01-01 07:07:39 +11:00
|
|
|
ZASM=../../emul/zasm/zasm
|
2019-05-28 01:04:31 +10:00
|
|
|
|
|
|
|
chkerr() {
|
|
|
|
echo "Check that '$1' results in error $2"
|
2019-12-10 01:36:38 +11:00
|
|
|
${ZASM} > /dev/null <<XXX
|
|
|
|
$1
|
|
|
|
XXX
|
2019-05-28 01:04:31 +10:00
|
|
|
local res=$?
|
2019-12-10 01:36:38 +11:00
|
|
|
if [ $res = $2 ]; then
|
2019-05-28 01:04:31 +10:00
|
|
|
echo "Good!"
|
|
|
|
else
|
|
|
|
echo "$res != $2"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-05-28 07:45:05 +10:00
|
|
|
chkoom() {
|
|
|
|
echo "Trying OOM error..."
|
2019-12-10 01:36:38 +11:00
|
|
|
local tmp=$(mktemp)
|
2019-05-28 07:45:05 +10:00
|
|
|
# 300 x 27-29 bytes > 8192 bytes. Large enough to smash the pool.
|
2019-12-10 01:36:38 +11:00
|
|
|
local i=0
|
|
|
|
while [ "$i" -lt "300" ]; do
|
|
|
|
echo ".equ abcdefghijklmnopqrstuvwxyz$i 42" >> ${tmp}
|
|
|
|
i=$(($i+1))
|
2019-05-28 07:45:05 +10:00
|
|
|
done
|
2019-12-10 01:36:38 +11:00
|
|
|
${ZASM} < ${tmp} > /dev/null
|
2019-05-28 07:45:05 +10:00
|
|
|
local res=$?
|
2019-12-10 01:36:38 +11:00
|
|
|
rm ${tmp}
|
|
|
|
if [ $res = 23 ]; then
|
2019-05-28 07:45:05 +10:00
|
|
|
echo "Good!"
|
|
|
|
else
|
2019-06-05 01:53:02 +10:00
|
|
|
echo "$res != 23"
|
2019-05-28 07:45:05 +10:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-06-05 01:53:02 +10:00
|
|
|
chkerr "foo" 17
|
|
|
|
chkerr "ld a, foo" 18
|
|
|
|
chkerr "ld a, hl" 18
|
|
|
|
chkerr ".db foo" 18
|
|
|
|
chkerr ".dw foo" 18
|
|
|
|
chkerr ".equ foo bar" 18
|
|
|
|
chkerr ".org foo" 18
|
|
|
|
chkerr ".fill foo" 18
|
|
|
|
chkerr "ld a," 19
|
|
|
|
chkerr "ld a, 'A" 19
|
|
|
|
chkerr ".db 0x42," 19
|
|
|
|
chkerr ".dw 0x4242," 19
|
|
|
|
chkerr ".equ" 19
|
|
|
|
chkerr ".equ foo" 19
|
|
|
|
chkerr ".org" 19
|
|
|
|
chkerr ".fill" 19
|
2019-10-07 05:32:23 +11:00
|
|
|
chkerr ".inc" 19
|
|
|
|
chkerr ".inc foo" 19
|
2019-06-05 01:53:02 +10:00
|
|
|
chkerr "ld a, 0x100" 20
|
|
|
|
chkerr ".db 0x100" 20
|
2019-11-14 14:37:00 +11:00
|
|
|
# TODO: find out why this tests fails on Travis but not on my machine...
|
|
|
|
# chkerr $'nop \ nop \ nop\n.fill 2-$' 20
|
2019-10-07 05:32:23 +11:00
|
|
|
chkerr ".inc \"doesnotexist\"" 21
|
2019-12-10 01:36:38 +11:00
|
|
|
chkerr 'foo:\\foo:' 22
|
2019-05-28 07:45:05 +10:00
|
|
|
chkoom
|