diff options
author | ymherklotz <ymherklotz@gmail.com> | 2017-03-10 12:50:26 +0000 |
---|---|---|
committer | ymherklotz <ymherklotz@gmail.com> | 2017-03-10 12:50:26 +0000 |
commit | f8f834c49ec51b6190d28d09e1028520195f7353 (patch) | |
tree | 4abd18b2fa4b66c90406222b28cf43eacffff2fb /run_test_deliverable.sh | |
parent | 28251a0c6f4e31c63c12746ffa77e05c669ef80d (diff) | |
parent | ddfb2e17f0fcc5ba9a4c944b4a9e3d4489426a71 (diff) | |
download | Compiler-f8f834c49ec51b6190d28d09e1028520195f7353.tar.gz Compiler-f8f834c49ec51b6190d28d09e1028520195f7353.zip |
Merge branch 'master' of github.com:LangProc/langproc-2016-cw
Diffstat (limited to 'run_test_deliverable.sh')
-rw-r--r-- | run_test_deliverable.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/run_test_deliverable.sh b/run_test_deliverable.sh new file mode 100644 index 0000000..35f6629 --- /dev/null +++ b/run_test_deliverable.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +if [[ -z "$1" ]]; then + COMPILER=bin/c_compiler +else + COMPILER=$1 +fi + +mkdir -p working + +for DRIVER in test_deliverable/testcases/*_driver.c ; do + NAME=$(basename $DRIVER _driver.c) + TESTCODE=test_deliverable/testcases/$NAME.c + + >&2 echo "Test case $NAME" + + # Compile driver with normal GCC + mips-linux-gnu-gcc -c $DRIVER -o working/${NAME}_driver.o 2> working/${NAME}_driver.compile.stderr + if [[ $? -ne 0 ]]; then + >&2 echo "ERROR : Couldn't compile driver program using GCC." + continue + fi + + # Compile test function with compiler under test to assembly + cat $TESTCODE | $COMPILER > working/$NAME.s 2> working/${NAME}.compile.stderr + if [[ $? -ne 0 ]]; then + >&2 echo "ERROR : Compiler returned error message." + continue + fi + + # Link driver object and assembly into executable + mips-linux-gnu-gcc -static working/${NAME}.s working/${NAME}_driver.o -o working/${NAME}.elf 2> working/${NAME}.link.stderr + if [[ $? -ne 0 ]]; then + >&2 echo "ERROR : Linker returned error message." + continue + fi + + # Run the actual executable + qemu-mips working/${NAME}.elf + if [[ $? -ne 0 ]]; then + >&2 echo "ERROR : Testcase returned $?, but expected 0." + fi + + echo "pass" +done |