Mesa (master): glsl/glcpp: Integrate recent glcpp-test-cr-lf test into " make check"

Ian Romanick idr at kemper.freedesktop.org
Thu Aug 7 23:08:47 UTC 2014


Module: Mesa
Branch: master
Commit: 318369acebdf6e7c21c0a2b015c648e8e9acbc81
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=318369acebdf6e7c21c0a2b015c648e8e9acbc81

Author: Carl Worth <cworth at cworth.org>
Date:   Thu Jul  3 13:25:47 2014 -0700

glsl/glcpp: Integrate recent glcpp-test-cr-lf test into "make check"

Beyond just listing this in the TESTS variable in Makefile.am, only minor
changes were needed to make this work. The primary issue is that the build
system runs the test script from a different directory than the script
itself. So we have to use the $srcdir variable to find the test input files.

Using $srcdir in this way also ensures that this test works when using an
out-of-tree build.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/glsl/.gitignore                   |    4 +++
 src/glsl/Makefile.am                  |    1 +
 src/glsl/glcpp/tests/.gitignore       |    1 +
 src/glsl/glcpp/tests/glcpp-test-cr-lf |   49 ++++++++++++++++++++++++---------
 4 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/src/glsl/.gitignore b/src/glsl/.gitignore
index 43720f6..dda423f 100644
--- a/src/glsl/.gitignore
+++ b/src/glsl/.gitignore
@@ -4,3 +4,7 @@ glsl_parser.cpp
 glsl_parser.h
 glsl_parser.output
 glsl_test
+subtest-cr/
+subtest-lf/
+subtest-cr-lf/
+subtest-lf-cr/
diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
index 2a20d11..0ccc81d 100644
--- a/src/glsl/Makefile.am
+++ b/src/glsl/Makefile.am
@@ -33,6 +33,7 @@ AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
 include Makefile.sources
 
 TESTS = glcpp/tests/glcpp-test				\
+	glcpp/tests/glcpp-test-cr-lf			\
 	tests/general-ir-test				\
 	tests/optimization-test				\
 	tests/sampler-types-test                        \
diff --git a/src/glsl/glcpp/tests/.gitignore b/src/glsl/glcpp/tests/.gitignore
index f18a9bb..3802c85 100644
--- a/src/glsl/glcpp/tests/.gitignore
+++ b/src/glsl/glcpp/tests/.gitignore
@@ -1,3 +1,4 @@
 subtest-cr/
+subtest-lf/
 subtest-cr-lf/
 subtest-lf-cr/
diff --git a/src/glsl/glcpp/tests/glcpp-test-cr-lf b/src/glsl/glcpp/tests/glcpp-test-cr-lf
index 708fce5..edaa29d 100755
--- a/src/glsl/glcpp/tests/glcpp-test-cr-lf
+++ b/src/glsl/glcpp/tests/glcpp-test-cr-lf
@@ -1,5 +1,18 @@
 #!/bin/sh
 
+# The build system runs this test from a different working directory, and may
+# be in a build directory entirely separate from the source. So if the
+# "srcdir" variable is set, we must use it to locate the test files and the
+# glcpp-test script.
+
+if [ ! -z "$srcdir" ]; then
+   testdir="$srcdir/glcpp/tests"
+   glcpp_test="$srcdir/glcpp/tests/glcpp-test"
+else
+   testdir=.
+   glcpp_test=./glcpp-test
+fi
+
 total=0
 pass=0
 
@@ -69,43 +82,53 @@ done
 # All tests depend on the .out files being present. So first do a
 # normal run of the test suite, (silently) just to create the .out
 # files as a side effect.
-./glcpp-test >/dev/null 2>&1
+rm -rf ./subtest-lf
+mkdir subtest-lf
+for file in "$testdir"/*.c; do
+    base=$(basename "$file")
+    cp "$file" subtest-lf
+done
+
+${glcpp_test} --testdir=subtest-lf >/dev/null 2>&1
 
 echo "===== Testing with \\\\r line terminators (old Mac format) ====="
 
 # Prepare test files with '\r' instead of '\n'
 rm -rf ./subtest-cr
 mkdir subtest-cr
-for file in *.c; do
-    tr "\n" "\r" < "$file" > subtest-cr/"$file"
-    cp "$file".out subtest-cr/"$file".expected
+for file in "$testdir"/*.c; do
+    base=$(basename "$file")
+    tr "\n" "\r" < "$file" > subtest-cr/"$base"
+    cp subtest-lf/"$base".out subtest-cr/"$base".expected
 done
 
-run_test "./glcpp-test --testdir=subtest-cr"
+run_test "${glcpp_test} --testdir=subtest-cr"
 
 echo "===== Testing with \\\\r\\\\n line terminators (DOS format) ====="
 
 # Prepare test files with '\r\n' instead of '\n'
 rm -rf ./subtest-cr-lf
 mkdir subtest-cr-lf
-for file in *.c; do
-    sed -e 's/$/\r/' < "$file" > subtest-cr-lf/"$file"
-    cp "$file".out subtest-cr-lf/"$file".expected
+for file in "$testdir"/*.c; do
+    base=$(basename "$file")
+    sed -e 's/$/\r/' < "$file" > subtest-cr-lf/"$base"
+    cp subtest-lf/"$base".out subtest-cr-lf/"$base".expected
 done
 
-run_test "./glcpp-test --testdir=subtest-cr-lf"
+run_test "${glcpp_test} --testdir=subtest-cr-lf"
 
 echo "===== Testing with \\\\n\\\\r (bizarre, but allowed by GLSL spec.) ====="
 
 # Prepare test files with '\n\r' instead of '\n'
 rm -rf ./subtest-lf-cr
 mkdir subtest-lf-cr
-for file in *.c; do
-    tr "\n" "\r" < "$file" | sed -e 's/\r/\n\r/g' > subtest-lf-cr/"$file"
-    cp "$file".out subtest-lf-cr/"$file".expected
+for file in "$testdir"/*.c; do
+    base=$(basename "$file")
+    tr "\n" "\r" < "$file" | sed -e 's/\r/\n\r/g' > subtest-lf-cr/"$base"
+    cp subtest-lf/"$base".out subtest-lf-cr/"$base".expected
 done
 
-run_test "./glcpp-test --testdir=subtest-lf-cr"
+run_test "${glcpp_test} --testdir=subtest-lf-cr"
 
 echo ""
 echo "$pass/$total tests returned correct results"




More information about the mesa-commit mailing list