diff options
Diffstat (limited to 'src/glsl/glcpp/tests')
6 files changed, 82 insertions, 16 deletions
diff --git a/src/glsl/glcpp/tests/084-unbalanced-parentheses.c.expected b/src/glsl/glcpp/tests/084-unbalanced-parentheses.c.expected new file mode 100644 index 0000000..af49a37 --- /dev/null +++ b/src/glsl/glcpp/tests/084-unbalanced-parentheses.c.expected @@ -0,0 +1,2 @@ +0:2(8): preprocessor error: syntax error, unexpected $end + diff --git a/src/glsl/glcpp/tests/093-divide-by-zero.c.expected b/src/glsl/glcpp/tests/093-divide-by-zero.c.expected new file mode 100644 index 0000000..08f183f --- /dev/null +++ b/src/glsl/glcpp/tests/093-divide-by-zero.c.expected @@ -0,0 +1,4 @@ +0:1(13): preprocessor error: division by 0 in preprocessor directive + + + diff --git a/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c b/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c index a9c6f36..04497b1 100644 --- a/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c +++ b/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c @@ -1,2 +1,13 @@ +/* glcpp is generating a division-by-zero error for this case. It's + * easy to argue that it should be short-circuiting the evaluation and + * not generating the diagnostic (which happens to be what gcc does). + * But it doesn't seem like we should force this behavior on our + * pre-processor, (and, as always, the GLSL specification of the + * pre-processor is too vague on this point). + * + * If a short-circuit evaluation optimization does get added to the + * pre-processor then it would legitimate to update the expected file + * for this test. +*/ #if 1 || (1 / 0) #endif diff --git a/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c.expected b/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c.expected new file mode 100644 index 0000000..84fdc50 --- /dev/null +++ b/src/glsl/glcpp/tests/094-divide-by-zero-short-circuit.c.expected @@ -0,0 +1,15 @@ +0:12(17): preprocessor error: division by 0 in preprocessor directive + + + + + + + + + + + + + + diff --git a/src/glsl/glcpp/tests/095-recursive-define.c.expected b/src/glsl/glcpp/tests/095-recursive-define.c.expected new file mode 100644 index 0000000..c7aa18f --- /dev/null +++ b/src/glsl/glcpp/tests/095-recursive-define.c.expected @@ -0,0 +1,4 @@ + + +B(0, C) + diff --git a/src/glsl/glcpp/tests/glcpp-test b/src/glsl/glcpp/tests/glcpp-test index 5dc08ea..e8f3b54 100755 --- a/src/glsl/glcpp/tests/glcpp-test +++ b/src/glsl/glcpp/tests/glcpp-test @@ -2,6 +2,34 @@ trap 'rm $test.valgrind-errors; exit 1' INT QUIT +usage () +{ + cat <<EOF +Usage: glcpp [options...] + +Run the test suite for mesa's GLSL pre-processor. + +Valid options include: + + --valgrind Run the test suite a second time under valgrind +EOF +} + +# Parse command-line options +for option; do + if [ "${option}" = '--help' ] ; then + usage + exit 0 + elif [ "${option}" = '--valgrind' ] ; then + do_valgrind=yes + else + echo "Unrecognized option: $option" >&2 + echo >&2 + usage + exit 1 + fi +done + total=0 pass=0 clean=0 @@ -24,23 +52,25 @@ echo "" echo "$pass/$total tests returned correct results" echo "" -echo "====== Testing for valgrind cleanliness ======" -for test in *.c; do - echo -n "Testing $test with valgrind..." - valgrind --error-exitcode=31 --log-file=$test.valgrind-errors ../glcpp < $test >/dev/null 2>&1 - if [ "$?" = "31" ]; then - echo "ERRORS" - cat $test.valgrind-errors - else - echo "CLEAN" - clean=$((clean+1)) - rm $test.valgrind-errors - fi -done +if [ "$do_valgrind" = "yes" ]; then + echo "====== Testing for valgrind cleanliness ======" + for test in *.c; do + echo -n "Testing $test with valgrind..." + valgrind --error-exitcode=31 --log-file=$test.valgrind-errors ../glcpp < $test >/dev/null 2>&1 + if [ "$?" = "31" ]; then + echo "ERRORS" + cat $test.valgrind-errors + else + echo "CLEAN" + clean=$((clean+1)) + rm $test.valgrind-errors + fi + done -echo "" -echo "$pass/$total tests returned correct results" -echo "$clean/$total tests are valgrind-clean" + echo "" + echo "$pass/$total tests returned correct results" + echo "$clean/$total tests are valgrind-clean" +fi if [ "$pass" = "$total" ] && [ "$clean" = "$total" ]; then exit 0 |