3 # The build system runs this test from a different working directory, and may
4 # be in a build directory entirely separate from the source. So if the
5 # "srcdir" variable is set, we must use it to locate the test files and the
8 if [ ! -z "$srcdir" ]; then
9 testdir
="$srcdir/glsl/glcpp/tests"
10 glcpp_test
="$srcdir/glsl/glcpp/tests/glcpp-test.sh"
13 glcpp_test
=.
/glcpp-test.sh
19 # This supports a pipe that doesn't destroy the exit status of first command
21 # http://unix.stackexchange.com/questions/14270/get-exit-status-of-process-thats-piped-to-another
33 if [ "$VERBOSE" = "yes" ]; then
41 # This is "$cmd | tail -2" but with the exit status of "$cmd" not "tail -2"
42 if (((($cmd; echo $?
>&3) |
tail -2 |
head -1 >&4) 3>&1) | stdintoexitstatus
) 4>&1; then
54 Usage: glcpp-cr-lf [options...]
56 Run the entire glcpp-test suite several times, each time with each source
57 file transformed to use a non-standard line-termination character. Each
58 entire run with a different line-termination character is considered a
61 Valid options include:
63 -v|--verbose Print all output from the various sub-tests
67 # Parse command-line options
74 echo "Unrecognized option: $option" >&2
82 # All tests depend on the .out files being present. So first do a
83 # normal run of the test suite, (silently) just to create the .out
84 # files as a side effect.
87 for file in "$testdir"/*.c
; do
88 base
=$
(basename "$file")
92 ${glcpp_test} --testdir=subtest-lf
>/dev
/null
2>&1
94 echo "===== Testing with \\\\r line terminators (old Mac format) ====="
96 # Prepare test files with '\r' instead of '\n'
99 for file in "$testdir"/*.c
; do
100 base
=$
(basename "$file")
101 tr "\n" "\r" < "$file" > subtest-cr
/"$base"
102 cp `pwd`/glsl
/glcpp
/tests
/subtest-lf
/"$base".out subtest-cr
/"$base".expected
105 run_test
"${glcpp_test} --testdir=subtest-cr"
107 echo "===== Testing with \\\\r\\\\n line terminators (DOS format) ====="
109 # Prepare test files with '\r\n' instead of '\n'
110 rm -rf .
/subtest-cr-lf
112 for file in "$testdir"/*.c
; do
113 base
=$
(basename "$file")
114 sed -e 's/$/
/' < "$file" > subtest-cr-lf
/"$base"
115 cp `pwd`/glsl
/glcpp
/tests
/subtest-lf
/"$base".out subtest-cr-lf
/"$base".expected
118 run_test
"${glcpp_test} --testdir=subtest-cr-lf"
120 echo "===== Testing with \\\\n\\\\r (bizarre, but allowed by GLSL spec.) ====="
122 # Prepare test files with '\n\r' instead of '\n'
123 rm -rf .
/subtest-lf-cr
125 for file in "$testdir"/*.c
; do
126 base
=$
(basename "$file")
127 sed -e 's/$/
/' < "$file" |
tr "\n\r" "\r\n" > subtest-lf-cr
/"$base"
128 cp `pwd`/glsl
/glcpp
/tests
/subtest-lf
/"$base".out subtest-lf-cr
/"$base".expected
131 run_test
"${glcpp_test} --testdir=subtest-lf-cr"
134 echo "$pass/$total tests returned correct results"
137 if [ "$pass" = "$total" ]; then