diff --git a/Makefile b/Makefile
index dfce116..57cd87a 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ windows: c2t.exe c2t-96h.exe
dist: all windows
-clean:
+clean: testclean
rm -f c2t.h c2t c2t-96h c2t.exe c2t-96h.exe
cd asm; make clean
@@ -27,4 +27,7 @@ c2t.h: mon/dos33.boot1.mon mon/dos33.boot2.mon asm/autoload.s asm/diskload2.s as
./makeheader
test: c2t-96h c2t-96h.exe
- ./test.sh
+ cd tests; ./test.sh
+
+testclean:
+ cd tests; rm -f passed test.log
diff --git a/README.md b/README.md
index 9ce0ee1..cceee07 100644
--- a/README.md
+++ b/README.md
@@ -75,15 +75,14 @@ Automated testing is only supported on OS/X and requires the following:
* Virtual ][ ()
-* `disks/zork.dsk` (May be found as `zork_i.dsk`, in any case save as `zork.dsk`)
-* `disks/dangerous_dave.po` (You can find this on Asimov as `dangerous_dave.dsk`, but it's really a PO ordered file, just rename to `.po`.)
* Windows cross-compiling tools
* Wine () installed in `~/wine` (extract the tarball in `~/wine` and move the contents of `~/wine/usr` to `~/wine`, or change the path to `wine` in `test.sh`).
-> You can hack `test.sh` if you do not want to test Windows binaries or want to use different disk images for test.
+> You can hack `test.md` if you do not want to test Windows binaries or want to use different disk images for test.
To test, type:
```
+make testclean # only once, unless you want to start over
make test
```
diff --git a/test.sh b/test.sh
deleted file mode 100755
index 6e1216e..0000000
--- a/test.sh
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/bin/bash
-
-# Path to wine binary for testing Windows binary
-PATH=~/wine/bin:$PATH
-
-# list of commands to test, must be space delimited
-CMD=("./c2t-96h" "wine c2t-96h.exe")
-
-# list of disks to test, must be space delimited.
-# Disks (and paths to disks) cannot have spaces in names.
-IMAGES="disks/zork.dsk disks/dangerous_dave.po"
-
-_test()
-{
- IMAGE=$1
- DONE=$2
- BASENAME=$(basename $1)
- FILETYPE=$(echo $BASENAME | awk -F. '{print $NF}')
-
- dd if=/dev/zero of=test.$FILETYPE bs=1k count=140 >/dev/null 2>&1
-
- if ! OUTPUT=$(osascript test.scrp test.${FILETYPE} $DONE)
- then
- echo
- return 1
- fi
-
- if echo $OUTPUT | grep ERROR >/dev/null 2>&1
- then
- echo $OUTPUT
- echo
- return 1
- fi
-
- S1=$(md5sum ${IMAGE} | awk '{print $1}')
- S2=$(md5sum test.$FILETYPE | awk '{print $1}')
-
- echo "$IMAGE $S1 $S2"
-
- if [ "$S1" = "$S2" ]
- then
- rm -f test.$FILETYPE test.aif
- return 0
- fi
- return 1
-}
-
-for i in $IMAGES
-do
- for j in $(seq 0 $(( ${#CMD[@]} - 1 )) )
- do
- echo ${CMD[$j]} $i test.aif
- eval ${CMD[$j]} $i test.aif
- if _test $i dskappleiie.tiff
- then
- echo "$i passed"
- echo
- else
- echo "$i failed"
- exit 1
- fi
- done
-done
-
-exit 0
-
diff --git a/tests/gentiff.scrp b/tests/gentiff.scrp
new file mode 100644
index 0000000..2b16c13
--- /dev/null
+++ b/tests/gentiff.scrp
@@ -0,0 +1,60 @@
+on run argv
+
+ set my_path to (system attribute "PWD") & "/"
+ set my_test to item 1 of argv
+ set my_machine to item 2 of argv
+ set my_done to item 3 of argv
+ set dsk to item 4 of argv
+ set loadcmd to item 5 of argv
+
+ tell application "Virtual ]["
+ activate
+ -- delay 0.5
+ delay 1
+ -- Close all open machines
+ close every machine saving no
+ -- Create a new (AppleIIe, AppleIIPlus, AppleII)
+ if my_machine = "iie" then
+ set theMachine to (make new AppleIIe)
+ end if
+ if my_machine = "iip" then
+ set theMachine to (make new AppleIIPlus)
+ end if
+ if my_machine = "ii" then
+ set theMachine to (make new AppleII)
+ end if
+ tell theMachine
+ -- Change to a color screen
+ -- set monochrome screen to false
+ set speaker volume to 0.25
+
+ if dsk = "1" then
+ insert my_path & my_test into device "S6D1"
+ end if
+ -- Now wait for the startup screen
+ delay 0.5
+ reset
+
+ set my_prompt to "*"
+ if loadcmd = "LOAD" then
+ set my_prompt to "]"
+ end if
+
+ repeat until the last line of the compact screen text = my_prompt
+ delay 0.5
+ end repeat
+
+ -- type line "LOAD"
+ type line loadcmd
+
+ play my_path & "test.aif" on device "cassette recorder"
+ set speed to maximum
+ delay 15
+ snap screen picture to POSIX path of (my_path & my_done) format tiff
+ end tell
+ delay 1
+ close every machine saving no
+ quit
+ end tell
+
+end run
diff --git a/tests/gentiff.sh b/tests/gentiff.sh
new file mode 100755
index 0000000..40f9a8e
--- /dev/null
+++ b/tests/gentiff.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+TIFFDIR=tiffs
+C2T=../c2t-96h
+
+_gentiff()
+{
+ MACHINE=$1
+ TIFF=$2
+ DSK=$3
+ LOAD="$4"
+
+ if [ "$DSK" = "1" ]
+ then
+ dd if=/dev/zero of=test.dsk bs=1k count=140 >/dev/null 2>&1
+ fi
+
+ if ! OUTPUT=$(osascript gentiff.scrp test.dsk $MACHINE $TIFF $DSK "$LOAD")
+ then
+ echo
+ return 1
+ fi
+
+ #if echo $OUTPUT | grep ERROR >/dev/null 2>&1
+ #then
+ # echo $OUTPUT
+ # echo
+ # return 1
+ #fi
+
+ if test -s $TIFF
+ then
+ return 0
+ fi
+ return 1
+}
+
+mkdir -p ${TIFFDIR}
+
+TIFF=${TIFFDIR}/dskiie.tiff
+if [ ! -s "$TIFF" ]
+then
+ eval $C2T images/zork.dsk test.aif
+ if ! _gentiff iie $TIFF 1 "LOAD"
+ then
+ echo "$TIFF failed"
+ exit 1
+ fi
+fi
+
+TIFF=${TIFFDIR}/dskiip.tiff
+if [ ! -s "$TIFF" ]
+then
+ eval $C2T images/zork.dsk test.aif
+ if ! _gentiff iip $TIFF 1 "LOAD"
+ then
+ echo "$TIFF failed"
+ exit 1
+ fi
+fi
+
+TIFF=${TIFFDIR}/mpiie.tiff
+if [ ! -s "$TIFF" ]
+then
+ eval $C2T -2bf images/moon.patrol,801 test.aif
+ if ! _gentiff iie $TIFF 0 "LOAD"
+ then
+ echo "$TIFF failed"
+ exit 1
+ fi
+fi
+
+TIFF=${TIFFDIR}/mpii.tiff
+if [ ! -s "$TIFF" ]
+then
+ eval $C2T -2af images/moon.patrol,801 test.aif
+ if ! _gentiff ii $TIFF 0 "800.A00R 800G"
+ then
+ echo "$TIFF failed"
+ exit 1
+ fi
+fi
+
+rm -f test.aif test.dsk
+
diff --git a/tests/images/moon.patrol b/tests/images/moon.patrol
new file mode 100644
index 0000000..7da589d
Binary files /dev/null and b/tests/images/moon.patrol differ
diff --git a/tests/test.md b/tests/test.md
new file mode 100644
index 0000000..9cc69c3
--- /dev/null
+++ b/tests/test.md
@@ -0,0 +1,17 @@
+## Automated Tests
+
+
+| Test | Command | Input | Machine | Load | Compare | Offset | Timeout |
+|:----:|--------------------------|-----------------|---------|---------------|-------------|:------:|:-------:|
+| 1 | ../c2t-96h | zork.dsk | iie | LOAD | dskiie.tiff | 0 | 25 |
+| 2 | wine ../c2t-96h.exe | zork.dsk | iie | LOAD | dskiie.tiff | 0 | 25 |
+| 3 | ../c2t-96h | dd.po | iie | LOAD | dskiie.tiff | 0 | 25 |
+| 4 | wine ../c2t-96h.exe | dd.po | iie | LOAD | dskiie.tiff | 0 | 25 |
+| 5 | ../c2t-96h | zork.dsk | iip | LOAD | dskiip.tiff | 0 | 25 |
+| 6 | wine ../c2t-96h.exe | zork.dsk | iip | LOAD | dskiip.tiff | 0 | 25 |
+| 7 | ../c2t-96h | dd.po | iip | LOAD | dskiip.tiff | 0 | 25 |
+| 8 | wine ../c2t-96h.exe | dd.po | iip | LOAD | dskiip.tiff | 0 | 25 |
+| 9 | ../c2t-96h -2bf | moon.patrol,801 | iie | LOAD | mpiie.tiff | 0 | 25 |
+| 10 | wine ../c2t-96h.exe -2bf | moon.patrol,801 | iie | LOAD | mpiie.tiff | 0 | 25 |
+| 11 | ../c2t-96h -2af | moon.patrol,801 | ii | 800.A00R 800G | mpii.tiff | 0 | 25 |
+| 12 | wine ../c2t-96h.exe -2af | moon.patrol,801 | ii | 800.A00R 800G | mpii.tiff | 0 | 25 |
diff --git a/test.scrp b/tests/test.scrp
similarity index 57%
rename from test.scrp
rename to tests/test.scrp
index 3c46545..0a39002 100644
--- a/test.scrp
+++ b/tests/test.scrp
@@ -3,37 +3,53 @@ on run argv
set my_path to (system attribute "PWD") & "/"
set my_test to item 1 of argv
set my_done to item 2 of argv
+ set my_machine to item 3 of argv
+ set dsk to item 4 of argv
+ set loadcmd to item 5 of argv
+ set my_timeout to item 6 of argv
tell application "Virtual ]["
activate
- delay 0.5
+ delay 1
-- Close all open machines
close every machine saving no
-- Create a new (AppleIIe, AppleIIPlus, AppleII)
- -- set theMachine to (make new AppleIIPlus)
- set theMachine to (make new AppleIIe)
+ if my_machine = "iie" then
+ set theMachine to (make new AppleIIe)
+ end if
+ if my_machine = "iip" then
+ set theMachine to (make new AppleIIPlus)
+ end if
+ if my_machine = "ii" then
+ set theMachine to (make new AppleII)
+ end if
tell theMachine
-- Change to a color screen
-- set monochrome screen to false
set speaker volume to 0.25
- insert my_path & my_test into device "S6D1"
+ if dsk = "1" then
+ insert my_path & my_test into device "S6D1"
+ end if
-- Now wait for the startup screen
delay 0.5
reset
+
+ set my_prompt to "*"
+ if loadcmd = "LOAD" then
+ set my_prompt to "]"
+ end if
- repeat until the last line of the compact screen text = "]"
+ repeat until the last line of the compact screen text = my_prompt
delay 0.5
end repeat
- type line "LOAD"
+ type line loadcmd
+
play my_path & "test.aif" on device "cassette recorder"
set speed to maximum
try
- with timeout of 25 seconds
- -- repeat until the last line of the compact screen text = "DONE. PRESS [RETURN] TO REBOOT."
- -- delay 0.5
- -- end repeat
+ with timeout of my_timeout seconds
waiting until screen equals imagefile POSIX path of (my_path & my_done)
end timeout
on error
@@ -46,8 +62,9 @@ on run argv
-- delay 3
end tell
- delay 0.5
+ delay 1
close every machine saving no
quit
end tell
end run
+
diff --git a/tests/test.sh b/tests/test.sh
new file mode 100755
index 0000000..5b37474
--- /dev/null
+++ b/tests/test.sh
@@ -0,0 +1,111 @@
+#!/bin/bash
+
+# Path to wine binary for testing Windows binary
+PATH=~/wine/bin:$PATH
+
+TESTS=test.md
+IMAGES=images
+TIFFS=tiffs
+
+_test()
+{
+ IMAGE=$1
+ DONE=$2
+ MACHINE=$3
+ LOAD="$4"
+ TIMEOT=$5
+ FILETYPE=$(echo $IMAGE | tr '[:upper:]' '[:lower:]' | awk -F. '{print $NF}')
+
+ DSK=0
+ if [ "$FILETYPE" = "po" -o "$FILETYPE" = "do" -o "$FILETYPE" = "dsk" ]
+ then
+ DSK=1
+ fi
+
+ if [ "$DSK" = "1" ]
+ then
+ dd if=/dev/zero of=test.$FILETYPE bs=1k count=140 >/dev/null 2>&1
+ fi
+
+ if ! OUTPUT=$(osascript test.scrp test.${FILETYPE} $DONE $MACHINE $DSK "$LOAD" $TIMEOT)
+ then
+ echo
+ return 1
+ fi
+
+ if echo $OUTPUT | grep ERROR >/dev/null 2>&1
+ then
+ echo $OUTPUT
+ echo
+ return 1
+ fi
+
+ if [ "$DSK" = "0" ]
+ then
+ rm -f test.aif
+ return 0
+ fi
+
+ S1=$(md5sum ${IMAGE} | awk '{print $1}')
+ S2=$(md5sum test.$FILETYPE | awk '{print $1}')
+
+ echo "$IMAGE $S1 $S2" >>test.log
+
+ if [ "$S1" = "$S2" ]
+ then
+ rm -f test.$FILETYPE test.aif
+ return 0
+ fi
+ return 1
+}
+
+>test.log
+
+echo "Tests:"
+echo
+grep '^|' $TESTS
+echo
+
+IFS=$'\n'
+for i in $(grep '^| [0-9]' $TESTS | perl -p -e 's/\| +/|/g' | perl -p -e 's/ +\|/|/g' | sed 's/\|/:/g')
+do
+ IFS=:
+ set -- $i
+
+ N=$2
+ CMD="$3"
+ INPUT=$4
+ MACHINE=$5
+ LOAD="$6"
+ DONE=$7
+ OFFSET=$8
+ TIMEOT=$9
+
+ #echo $N : $CMD : $INPUT : $MACHINE : $LOAD : $DONE : $OFFSET : $TIMEOT
+
+ if grep "^$N:" passed >/dev/null 2>&1
+ then
+ echo "Test $N already passed"
+ continue
+ fi
+
+ EC=0
+ echo "Running test $N..."
+ echo $* >>test.log
+ echo " $CMD $IMAGES/$INPUT test.aif"
+ eval "$CMD" $IMAGES/$INPUT test.aif >>test.log 2>&1
+ echo " _test ${IMAGES}/${INPUT} ${TIFFS}/${DONE} $MACHINE $LOAD $TIMEOT"
+ if _test ${IMAGES}/${INPUT} ${TIFFS}/${DONE} $MACHINE "$LOAD" $TIMEOT
+ then
+ echo " passed"
+ echo "$N:$(date)" >>passed
+ else
+ echo " FAILED"
+ EC=1
+ break
+ fi
+done
+
+unset IFS
+exit $EC
+
diff --git a/tests/tiffs/dskiie.tiff b/tests/tiffs/dskiie.tiff
new file mode 100644
index 0000000..4d30e02
Binary files /dev/null and b/tests/tiffs/dskiie.tiff differ
diff --git a/tests/tiffs/dskiip.tiff b/tests/tiffs/dskiip.tiff
new file mode 100644
index 0000000..0cbe040
Binary files /dev/null and b/tests/tiffs/dskiip.tiff differ
diff --git a/tests/tiffs/mpii.tiff b/tests/tiffs/mpii.tiff
new file mode 100644
index 0000000..11fc930
Binary files /dev/null and b/tests/tiffs/mpii.tiff differ
diff --git a/tests/tiffs/mpiie.tiff b/tests/tiffs/mpiie.tiff
new file mode 100644
index 0000000..11fc930
Binary files /dev/null and b/tests/tiffs/mpiie.tiff differ