#! /bin/sh
|
#! /bin/sh
|
#
|
#
|
# Usage:
|
# Usage:
|
# test simulator_binary file_to_test
|
# test simulator_binary file_to_test
|
echo -n "Testing $2... "
|
echo -n "Testing $2... "
|
|
|
# clean . and / characters
|
# clean . and / characters
|
fn=`echo $2 | sed 's/[\/\.]//g'`
|
fn=`echo $2 | sed 's/[\/\.]//g'`
|
default_cfg_fn="default.cfg"
|
default_cfg_fn="default.cfg"
|
temp1="/tmp/${fn}_output_ok"
|
temp1="/tmp/${fn}_output_ok"
|
temp2="/tmp/${fn}_output"
|
temp2="/tmp/${fn}_output"
|
temp3="/tmp/${fn}_output_tail"
|
temp3="/tmp/${fn}_output_tail"
|
temp4="/tmp/${fn}_error"
|
temp4="/tmp/${fn}_error"
|
|
|
# prepare simulator parameters
|
# prepare simulator parameters
|
sim_param=
|
sim_param=
|
cfg_file="$2.cfg"
|
cfg_file="$2.cfg"
|
test -f $cfg_file
|
test -f $cfg_file
|
if test $? -eq 0; then
|
if test $? -eq 0; then
|
echo -n "(using $cfg_file) "
|
echo -n "(using $cfg_file) "
|
# load .cfg file
|
# load .cfg file
|
sim_param="-f $cfg_file";
|
sim_param="-f $cfg_file";
|
else
|
else
|
sim_param="-f $default_cfg_fn";
|
sim_param="-f $default_cfg_fn";
|
fi
|
fi
|
|
|
#if simulator not specified, no flags needed
|
#if simulator not specified, no flags needed
|
if test -z $1; then
|
if test -z $1; then
|
sim_param=;
|
sim_param=;
|
fi
|
fi
|
|
|
# Last two lines should look like:
|
# Last two lines should look like:
|
echo "MTSPR(0x1234, 0xdeaddead);" >$temp1
|
echo "report(0xdeaddead);" >$temp1
|
echo "syscall exit(0)" >>$temp1
|
echo "exit(0)" >>$temp1
|
|
|
# run the simulator
|
# run the simulator
|
$1 $2 $sim_param 2>$temp4 >$temp2
|
$1 $2 $sim_param 2>$temp4 >$temp2
|
simerr=$?
|
simerr=$?
|
if test $simerr -eq 0; then
|
if test $simerr -eq 0; then
|
tail $temp2 -n 2 >$temp3
|
tail $temp2 -n 2 >$temp3
|
if cmp -s $temp1 $temp3; then
|
if cmp -s $temp1 $temp3; then
|
echo "OK";
|
echo "OK";
|
rm $temp2
|
rm $temp2
|
rm $temp4
|
rm $temp4
|
else
|
else
|
simerr=$?
|
simerr=$?
|
echo -e "FAILED\nSee: '$temp2' and '$temp4'";
|
echo -e "FAILED\nSee: '$temp2' and '$temp4'";
|
fi;
|
fi;
|
else
|
else
|
echo "Cannot run: '$1 $2 $sim_param 2>$temp4 >$temp2'"
|
echo "Cannot run: '$1 $2 $sim_param 2>$temp4 >$temp2'"
|
cat $temp4;
|
cat $temp4;
|
fi
|
fi
|
|
|
# cleanup
|
# cleanup
|
rm $temp1
|
rm $temp1
|
rm $temp3
|
rm $temp3
|
|
|
# exit the test
|
# exit the test
|
exit $simerr
|
exit $simerr
|
|
|