summaryrefslogtreecommitdiff
path: root/contrib/dg-extract-results.sh
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2015-04-22 10:21:45 +0000
committer <>2015-04-25 21:44:09 +0000
commitf80b5ea1605c9f9408c5aa386ba71c16d918ebbf (patch)
treebb7eafaa81fc4b8c5c215bc08d517fd158db234a /contrib/dg-extract-results.sh
parentc27a97d04853380f1e80525391b3f0d156ed4c84 (diff)
downloadgcc-tarball-f80b5ea1605c9f9408c5aa386ba71c16d918ebbf.tar.gz
Imported from /home/lorry/working-area/delta_gcc-tarball/gcc-5.1.0.tar.bz2.gcc-5.1.0
Diffstat (limited to 'contrib/dg-extract-results.sh')
-rwxr-xr-xcontrib/dg-extract-results.sh34
1 files changed, 29 insertions, 5 deletions
diff --git a/contrib/dg-extract-results.sh b/contrib/dg-extract-results.sh
index 7029281383..5a8e67ea2f 100755
--- a/contrib/dg-extract-results.sh
+++ b/contrib/dg-extract-results.sh
@@ -28,6 +28,15 @@
PROGNAME=dg-extract-results.sh
+# Try to use the python version if possible, since it tends to be faster.
+PYTHON_VER=`echo "$0" | sed 's/sh$/py/'`
+if test "$PYTHON_VER" != "$0" &&
+ test -f "$PYTHON_VER" &&
+ python -c 'import sys, getopt, re, io, datetime, operator; sys.exit (0 if sys.version_info >= (2, 6) else 1)' \
+ > /dev/null 2> /dev/null; then
+ exec python $PYTHON_VER "$@"
+fi
+
usage() {
cat <<EOF >&2
Usage: $PROGNAME [-t tool] [-l variant-list] [-L] sum-file ...
@@ -118,13 +127,28 @@ do
done
test $ERROR -eq 0 || exit 1
+# Test if grep supports the '--text' option
+
+GREP=grep
+
+if echo -e '\x00foo\x00' | $GREP --text foo > /dev/null 2>&1 ; then
+ GREP="grep --text"
+else
+ # Our grep does not recognize the '--text' option. We have to
+ # treat our files in order to remove any non-printable character.
+ for file in $SUM_FILES ; do
+ mv $file ${file}.orig
+ cat -v ${file}.orig > $file
+ done
+fi
+
if [ -z "$TOOL" ]; then
# If no tool was specified, all specified summary files must be for
# the same tool.
- CNT=`grep '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l`
+ CNT=`$GREP '=== .* tests ===' $SUM_FILES | $AWK '{ print $3 }' | sort -u | wc -l`
if [ $CNT -eq 1 ]; then
- TOOL=`grep '=== .* tests ===' $FIRST_SUM | $AWK '{ print $2 }'`
+ TOOL=`$GREP '=== .* tests ===' $FIRST_SUM | $AWK '{ print $2 }'`
else
msg "${PROGNAME}: sum files are for multiple tools, specify a tool"
msg ""
@@ -135,7 +159,7 @@ else
# Ignore the specified summary files that are not for this tool. This
# should keep the relevant files in the same order.
- SUM_FILES=`grep -l "=== $TOOL" $SUM_FILES`
+ SUM_FILES=`$GREP -l "=== $TOOL" $SUM_FILES`
if test -z "$SUM_FILES" ; then
msg "${PROGNAME}: none of the specified files are results for $TOOL"
exit 1
@@ -224,7 +248,7 @@ else
VARIANTS=""
for VAR in $VARS
do
- grep "Running target $VAR" $SUM_FILES > /dev/null && VARIANTS="$VARIANTS $VAR"
+ $GREP "Running target $VAR" $SUM_FILES > /dev/null && VARIANTS="$VARIANTS $VAR"
done
fi
@@ -426,6 +450,6 @@ cat ${TMP}/var-* | $AWK -f $TOTAL_AWK
# This is ugly, but if there's version output from the compiler under test
# at the end of the file, we want it. The other thing that might be there
# is the final summary counts.
-tail -2 $FIRST_SUM | grep '^#' > /dev/null || tail -2 $FIRST_SUM
+tail -2 $FIRST_SUM | $GREP '^#' > /dev/null || tail -2 $FIRST_SUM
exit 0