1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-21 02:28:05 +11:00
collapseos/tools/tests/zasm/errtests.sh
Virgil Dupras ae028e3a86 blockdev: make implementors "random access"
This huge refactoring remove the Seek and Tell routine from blockdev
implementation requirements and change GetC and PutC's API so that they
take an address to read and write (through HL/DE) at each call.

The "PTR" approach in blockdev implementation was very redundant from
device to device and it made more sense to generalize. It's possible
that future device aren't "random access", but we'll be able to add more
device types later.

Another important change in this commit is that the "blockdev handle" is
now opaque. Previously, consumers of the API would happily call routines
directly from one of the 4 offsets. We can't do that any more. This
makes the API more solid for future improvements.

This change forced me to change a lot of things in fs, but overall,
things are now simpler. No more `FS_PTR`: the "device handle" now holds
the active pointer.

Lots, lots of changes, but it also feels a lot cleaner and solid.
2019-06-04 15:36:20 -04:00

60 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# no "set -e" because we test errors
ZASM=../../zasm.sh
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
}
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 == 23 ]]; then
echo "Good!"
else
echo "$res != 23"
exit 1
fi
}
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
chkerr "#inc" 19
chkerr "#inc foo" 19
chkerr "ld a, 0x100" 20
chkerr ".db 0x100" 20
chkerr "#inc \"doesnotexist\"" 21
chkerr ".equ foo 42 \\ .equ foo 42" 22
chkoom