#! /bin/sh
#rem **********************
#rem * rr functional test *
#rem **********************
#VERBOSE=--verbose
VERBOSE=--silent

#############################
# c64
#############################

function testc64
{

echo testing transfer...
$RRPATH/rr $VERBOSE load $RRPATH/files/test1.prg
$RRPATH/rr $VERBOSE save $RRPATH/files/temp/testsave 0x2000 0x2200
#compare the files
if diff -q files/test1.prg files/temp/testsave; then \
echo "files identical, test passed. (xfer ok)"; \
else \
echo "files different, test failed."; \
fi;
#rem * view koala pic
echo testing koala...
$RRPATH/rrkoa $RRPATH/files/sentinel.koa
#rem * play sid tune
echo testing sid...
$RRPATH/rrsid $RRPATH/files/aceshigh.sid
#rem * run rr.exe in debug mode
echo "entering debugger..."
$RRPATH/rr

}

#############################
# vic20
#############################

function testvic20
{
	echo
}

#############################
# main...
#############################

# find out which target the toolchain is configured for
TARGET=` ./rr --show-config 2>&1 | grep machine: | sed -e "s/machine: \[ *//" -e "s/\].*$//" `

# run test
if `test $TARGET = c64`;then
	echo testing $TARGET ...
	testc64
else
	if `test $TARGET = vic20`;then
		echo testing $TARGET ...
		testvic20
	else
		echo "sorry, no tests available for current config."
	fi
fi
