[Mesa-dev] [PATCH] glx/tests: Fix bash-specific code in dispatch-index-check

Aaron Watry awatry at gmail.com
Sat Feb 25 04:03:36 UTC 2017


Using <<< for variable redirection is bash-specific behavior.
Ubuntu redirects sh -> dash, so this was erroring out.

Also, the initial error that led me to this was that srcdir is null when running make check
so I just copied something similar to what the optimization-test script does.
---
 src/glx/tests/dispatch-index-check | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/glx/tests/dispatch-index-check b/src/glx/tests/dispatch-index-check
index 78464b8..ee1b9ee 100755
--- a/src/glx/tests/dispatch-index-check
+++ b/src/glx/tests/dispatch-index-check
@@ -1,24 +1,31 @@
 #!/bin/sh
 
+if [ -z "$srcdir" ]; then
+   scriptdir=`dirname "$0"`
+else
+   scriptdir=$srcdir
+fi
+
+
 # extract enum definition
 dispatch_list=$(sed '/__GLXdispatchIndex/,/__GLXdispatchIndex/!d' \
-  "$srcdir"/../g_glxglvnddispatchindices.h)
+  "$scriptdir"/../g_glxglvnddispatchindices.h)
 
 # extract values inside of enum
-dispatch_list=$(sed '1d;$d' <<< "$dispatch_list")
+dispatch_list=$(printf "$dispatch_list" | sed '1d;$d')
 
 # remove indentation
-dispatch_list=$(sed 's/^\s\+//' <<< "$dispatch_list")
+dispatch_list=$(printf "$dispatch_list" | sed 's/^\s\+//')
 
 # extract function names
-dispatch_list=$(sed 's/DI_//;s/,//' <<< "$dispatch_list")
+dispatch_list=$(printf "$dispatch_list" | sed 's/DI_//;s/,//')
 
 # same for commented functions, we want to keep them sorted too
-dispatch_list=$(sed 's#// ##;s/ implemented by [a-z]\+//' <<< "$dispatch_list")
+dispatch_list=$(printf "$dispatch_list" | sed 's#// ##;s/ implemented by [a-z]\+//')
 
 # remove LAST_INDEX, as it will not be in alphabetical order
-dispatch_list=$(sed '/LAST_INDEX/d' <<< "$dispatch_list")
+dispatch_list=$(printf "$dispatch_list" | sed '/LAST_INDEX/d')
 
-sorted=$(LC_ALL=C sort <<< "$dispatch_list")
+sorted=$(LC_ALL=C printf "$dispatch_list" | sort)
 
 test "$dispatch_list" = "$sorted"
-- 
2.9.3



More information about the mesa-dev mailing list