mips/tools/test.sh

45 lines
660 B
Bash
Raw Normal View History

2024-09-30 22:50:22 +00:00
#!/bin/sh
#
# tests a binary
# against a output and an exit code
#
dir="$(dirname "$0")"
msim="$dir/../bin/msim/msim"
bin="$dir/../test/msim/$1"
out=$(cat "$dir/../test/out/$1")
status=$(cat "$dir/../test/out/$1.status")
temp=$(mktemp)
$msim $bin &> $temp
rstatus="$?"
rout=$(cat $temp)
rm $temp
res=0
if [ "$out" != "$rout" ]; then
res=1
fi
if [ "$status" != "$rstatus" ]; then
res=1
fi
if [ $res = 0 ]; then
printf "\033[32mPASSED\033[0m\n"
else
printf "\033[31mFAILED\033[0m\n"
2024-10-01 22:21:10 +00:00
if [ "$status" != "$rstatus" ]; then
printf "exit: $rstatus (should be $status)\n"
fi
diff -Nau <(printf "%s\n" "$out") <(printf "%s\n" "$rout")
2024-09-30 22:50:22 +00:00
fi
exit $res