summaryrefslogtreecommitdiff
path: root/test/arm/run_tests.sh
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-01-17 16:17:19 +0000
committerAlasdair Armstrong2018-01-17 16:17:19 +0000
commit254b72f60388271058c6d259d5a98424e94cafc7 (patch)
treeb3fc71b47ddefe267336d4c0b460f4535b42cd7a /test/arm/run_tests.sh
parent53af9ce7a683ee4542b8facc44edfd1e3ef64cf6 (diff)
Add generated ARM spec and test cases for it
We add the generated ARM no_vector spec from the public v8.3 XML release, mostly so that we can add end-to-end test cases for sail using it. This kind of large example is very useful for thoroughly testing the sail compiler and interpreter.
Diffstat (limited to 'test/arm/run_tests.sh')
-rwxr-xr-xtest/arm/run_tests.sh84
1 files changed, 84 insertions, 0 deletions
diff --git a/test/arm/run_tests.sh b/test/arm/run_tests.sh
new file mode 100755
index 00000000..21c1ce3d
--- /dev/null
+++ b/test/arm/run_tests.sh
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+set -e
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+cd $DIR
+SAILDIR="$DIR/../.."
+
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[0;33m'
+NC='\033[0m'
+
+rm -f $DIR/tests.xml
+
+pass=0
+fail=0
+XML=""
+
+function green {
+ (( pass += 1 ))
+ printf "$1: ${GREEN}$2${NC}\n"
+ XML+=" <testcase name=\"$1\"/>\n"
+}
+
+function yellow {
+ (( fail += 1 ))
+ printf "$1: ${YELLOW}$2${NC}\n"
+ XML+=" <testcase name=\"$1\">\n <error message=\"$2\">$2</error>\n </testcase>\n"
+}
+
+function red {
+ (( fail += 1 ))
+ printf "$1: ${RED}$2${NC}\n"
+ XML+=" <testcase name=\"$1\">\n <error message=\"$2\">$2</error>\n </testcase>\n"
+}
+
+function finish_suite {
+ printf "$1: Passed ${pass} out of $(( pass + fail ))\n\n"
+ XML=" <testsuite name=\"$1\" tests=\"$(( pass + fail ))\" failures=\"${fail}\" timestamp=\"$(date)\">\n$XML </testsuite>\n"
+ printf "$XML" >> $DIR/tests.xml
+ XML=""
+ pass=0
+ fail=0
+}
+
+SAILLIBDIR="$DIR/../../lib/"
+
+printf "<testsuites>\n" >> $DIR/tests.xml
+
+cd $SAILDIR/aarch64
+
+printf "Compiling specification...\n"
+
+if $SAILDIR/sail -o aarch64_test -ocaml prelude.sail no_vector/spec.sail decode_start.sail no_vector/decode.sail decode_end.sail main.sail 1> /dev/null;
+then
+ green "compiled no_vector specification" "ok";
+ mv aarch64_test $DIR/;
+ cd $DIR;
+
+ for i in `ls *.elf`;
+ do
+ $DIR/aarch64_test $i 2> /dev/null 1> ${i%.elf}.result
+ if diff ${i%.elf}.result ${i%.elf}.expect;
+ then
+ green "ran $i" "ok"
+ else
+ red "failed $i" "fail"
+ fi;
+ rm -f *.result
+ done;
+
+ rm -f aarch64_test
+else
+ red "compiling no_vector specification" "fail";
+
+ for $i in `ls *.elf`;
+ do
+ red "failed $i" "fail"
+ done
+fi
+
+finish_suite "ARM generated spec tests"
+
+printf "</testsuites>\n" >> $DIR/tests.xml