summaryrefslogtreecommitdiff
path: root/tools/test.sh
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-09-30 18:50:22 -0400
committerFreya Murphy <freya@freyacat.org>2024-09-30 18:50:22 -0400
commitc250afa7a0a9fe003196aded1a0749ed440481a3 (patch)
tree25fde1682fbc50055d70869802a2822c404749a7 /tools/test.sh
parentupdate tests (diff)
downloadmips-c250afa7a0a9fe003196aded1a0749ed440481a3.tar.gz
mips-c250afa7a0a9fe003196aded1a0749ed440481a3.tar.bz2
mips-c250afa7a0a9fe003196aded1a0749ed440481a3.zip
update testing
Diffstat (limited to 'tools/test.sh')
-rwxr-xr-xtools/test.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/test.sh b/tools/test.sh
new file mode 100755
index 0000000..2dcbf6a
--- /dev/null
+++ b/tools/test.sh
@@ -0,0 +1,41 @@
+#!/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"
+ diff <(echo $out) <(echo $rout)
+fi
+
+exit $res