diff options
author | David Thomas <m8pple@github.com> | 2017-03-09 10:01:27 +0000 |
---|---|---|
committer | David Thomas <m8pple@github.com> | 2017-03-09 10:01:27 +0000 |
commit | 7922bd0454bc19cc974de7e2f5cf5ef614569782 (patch) | |
tree | 9eb38fa047a57a9c545e40ded9c51f4dae901367 /run_test_deliverable.sh | |
parent | 6baea6b1eeb184ca49f3d2e1961ffd2e43ba8ef4 (diff) | |
download | Compiler-7922bd0454bc19cc974de7e2f5cf5ef614569782.tar.gz Compiler-7922bd0454bc19cc974de7e2f5cf5ef614569782.zip |
Transfer in test and documentation parts.
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..f77e8b7 --- /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 1 ]]; then + >&2 echo "ERROR : Testcase returned $?, but expected 0." + fi + + +done |