53 lines
1.5 KiB
Bash
53 lines
1.5 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
X64="x64 -minimized +sound -warp -silent +saveres"
|
||
|
PRG="chipty5-64.prg"
|
||
|
|
||
|
LBL=$(basename "$PRG" .prg).l
|
||
|
|
||
|
MONSCRIPT="load \"${PRG}\" 0\n
|
||
|
load_labels \"${LBL}\"\n
|
||
|
bload \"/tmp/c8test.ch8\" 0 .C8ENTRY\n
|
||
|
break exec .oINV\n
|
||
|
goto .MainEntry\n
|
||
|
bsave \"/tmp/c8registers.bin\" 0 .reg:v .reg:st\n
|
||
|
bsave \"/tmp/c8display.bin\" 0 .c8screen .c8screenend\n
|
||
|
bsave \"/tmp/c8ram.bin\" 0 .C8RAM .c8ramend\n
|
||
|
quit"
|
||
|
|
||
|
success () {
|
||
|
echo "$(tput setaf 2)Ok$(tput sgr0)"
|
||
|
}
|
||
|
|
||
|
failure () {
|
||
|
echo "$(tput setaf 1)Failed $1$(tput sgr0)"
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
if [ $# -gt 0 ] ; then
|
||
|
TESTS="$@"
|
||
|
else
|
||
|
TESTS=$(find tests -mindepth 1 -maxdepth 1 -type f \
|
||
|
-name "*.ch8asm" -printf "%f\\n" | sed 's/\.ch8asm$//g')
|
||
|
fi
|
||
|
|
||
|
make $PRG
|
||
|
|
||
|
for testcase in $TESTS ; do
|
||
|
echo -n "Running test case $testcase ... "
|
||
|
cp tests/$testcase.ch8asm /tmp/c8test.ch8asm
|
||
|
./ch8asm.py /tmp/c8test.ch8asm
|
||
|
$X64 -initbreak ready -moncommand <(echo -e $MONSCRIPT) >/tmp/c8test.vice.log 2>&1
|
||
|
if [ -f tests/$testcase.display.pbm ] ; then
|
||
|
convert -size 64x32 -depth 1 gray:/tmp/c8display.bin -compress none -negate /tmp/c8display.pbm
|
||
|
cmp -s /tmp/c8display.pbm tests/$testcase.display.pbm || failure "(display)"
|
||
|
fi
|
||
|
if [ -f tests/$testcase.registers.regex ] ; then
|
||
|
grep -f tests/$testcase.registers.regex <(xxd -ps /tmp/c8registers.bin) >/dev/null || failure "(registers)"
|
||
|
fi
|
||
|
if [ -f tests/$testcase.ram.regex ] ; then
|
||
|
grep -f tests/$testcase.ram.regex <(xxd -g1 /tmp/c8ram.bin) >/dev/null || failure "(ram)"
|
||
|
fi
|
||
|
success
|
||
|
done
|