diff options
| author | Alasdair | 2018-06-09 02:42:19 +0100 |
|---|---|---|
| committer | Alasdair | 2018-06-09 02:42:19 +0100 |
| commit | b424d30a1b5de1b0a38482624b47ea610c10a12e (patch) | |
| tree | 4ca6a440ad6e19b9a87735e3d17eacc7455d248b /test/c/run_tests.sh | |
| parent | 32b1283ec5db28a8addaeed7abdbe55e8c8f80e4 (diff) | |
Fix issue with catch block return values not being compiled correctly
This should fix the issue raised in commit 45554f
Adds a test loop_exception that tests throwing exceptions in loops, various looping constructs, and returning values from try/catch blocks. Also modified the test-suite to test C compiled output both with and without optimisations
Diffstat (limited to 'test/c/run_tests.sh')
| -rwxr-xr-x | test/c/run_tests.sh | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/test/c/run_tests.sh b/test/c/run_tests.sh index e85881f5..e1a1a1ce 100755 --- a/test/c/run_tests.sh +++ b/test/c/run_tests.sh @@ -47,36 +47,47 @@ function finish_suite { printf "<testsuites>\n" >> $DIR/tests.xml shopt -s nullglob; -for file in $DIR/*.sail; -do - if $SAILDIR/sail -no_warn -c $file 1> ${file%.sail}.c 2> /dev/null; - then - green "compiling $(basename $file)" "ok"; - if gcc ${file%.sail}.c -lgmp; + +function run_c_tests { + for file in $DIR/*.sail; + do + if $SAILDIR/sail -no_warn -c $SAIL_OPTS $file 1> ${file%.sail}.c 2> /dev/null; then - green "compiling $(basename ${file%.sail}.c)" "ok"; - $DIR/a.out 1> ${file%.sail}.result 2> /dev/null; - if diff ${file%.sail}.result ${file%.sail}.expect; - then - green "executing $(basename ${file%.sail})" "ok" - else - red "executing $(basename ${file%.sail})" "fail" - fi; - if valgrind -q --leak-check=full --errors-for-leak-kinds=all --error-exitcode=1 $DIR/a.out 1> /dev/null 2> /dev/null; + green "compiling $(basename $file) ($SAIL_OPTS)" "ok"; + if gcc $CC_OPTS ${file%.sail}.c -lgmp -I $SAILDIR/lib; then - green "executing $(basename ${file%.sail}) with valgrind" "ok" + green "compiling $(basename ${file%.sail}.c) ($CC_OPTS)" "ok"; + $DIR/a.out 1> ${file%.sail}.result 2> /dev/null; + if diff ${file%.sail}.result ${file%.sail}.expect; + then + green "executing $(basename ${file%.sail})" "ok" + else + red "executing $(basename ${file%.sail})" "fail" + fi; + if valgrind -q --leak-check=full --errors-for-leak-kinds=all --error-exitcode=1 $DIR/a.out 1> /dev/null 2> /dev/null; + then + green "executing $(basename ${file%.sail}) with valgrind" "ok" + else + red "executing $(basename ${file%.sail}) with valgrind" "fail" + fi else - red "executing $(basename ${file%.sail}) with valgrind" "fail" + red "compiling generated C" "fail" fi else - red "compiling generated C" "fail" - fi - else - red "compiling $file" "fail" - fi; - rm -f ${file%.sail}.c - rm -f ${file%.sail}.result -done + red "compiling $file" "fail" + fi; + rm -f ${file%.sail}.c + rm -f ${file%.sail}.result + done +} + +SAIL_OPTS="" +CC_OPTS="-O0" +run_c_tests + +SAIL_OPTS="-O" +CC_OPTS="-O2" +run_c_tests finish_suite "C testing" |
