diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-07 16:15:51 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-07 16:15:51 +0000 |
commit | fed691abddc2b242a6bcb81d87e18797b95bbe80 (patch) | |
tree | 28cb4c0ea9facfa7cc8642c778708f4e038c2aef /test_compiler.sh | |
parent | 15789d04e85806745c4c2e1cb3fdc891c34ab21f (diff) | |
download | Compiler-fed691abddc2b242a6bcb81d87e18797b95bbe80.tar.gz Compiler-fed691abddc2b242a6bcb81d87e18797b95bbe80.zip |
Can compile simplest program
Diffstat (limited to 'test_compiler.sh')
-rwxr-xr-x | test_compiler.sh | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/test_compiler.sh b/test_compiler.sh index 3f64457..700afe5 100755 --- a/test_compiler.sh +++ b/test_compiler.sh @@ -20,22 +20,36 @@ echo " Testing compiler" PASSED=0 CHECKED=0 +mkdir -p c_compiler/test/out +mkdir -p c_compiler/test/ref + for i in c_compiler/test/in/*.c; do echo "===========================" echo "" echo "Input file : ${i}" BASENAME=$(basename $i .c); - cat $i | ./bin/c_compiler > c_compiler/test/out/$BASENAME.stdout.s 2> c_compiler/test/out/$BASENAME.stderr.txt + cat $i | ./bin/c_compiler > c_compiler/test/out/$BASENAME.s 2> c_compiler/test/out/$BASENAME.stderr.txt - diff <(cat c_compiler/test/ref/$BASENAME.stdout.s) <(cat c_compiler/test/out/$BASENAME.stdout.s) > c_compiler/test/out/$BASENAME.diff.txt + mips-linux-gnu-gcc -S -c c_compiler/test/in/$BASENAME.c -o c_compiler/test/ref/$BASENAME.s + mips-linux-gnu-gcc -static c_compiler/test/ref/$BASENAME.s -o c_compiler/test/ref/$BASENAME - if [[ "$?" -ne "0" ]]; then - echo -e "\nERROR" - else - PASSED=$(( ${PASSED}+1 )); - fi + mips-linux-gnu-gcc -static c_compiler/test/out/$BASENAME.s -o c_compiler/test/out/$BASENAME + + qemu-mips c_compiler/test/ref/$BASENAME + REFOUTPUT=$? - CHECKED=$(( ${CHECKED}+1 )); + qemu-mips c_compiler/test/out/$BASENAME + TESTOUTPUT=$? + + if [ "$TESTOUTPUT" = "$REFOUTPUT" ]; then + PASSED=$(( PASSED+1 )) + else + echo -e "\nERROR" + fi + + echo -e "output: $TESTOUTPUT\n" + + CHECKED=$(( CHECKED+1 )) done echo "########################################" |