compare_tests: Add -compr option

This allows to select how the .sum files are compressed.

It defaults to .xz (what we use in most jobs), but '-compr none'
allows to handle uncompressed sum files, for instance when running
this script right after a GCC build like we do in round-robin jobs.

Change-Id: I5f7085b16a65a470c27ad682be74a6cb8d2e496e
diff --git a/compare_tests b/compare_tests
index 97b44bd..ac9c8df 100755
--- a/compare_tests
+++ b/compare_tests
@@ -13,7 +13,7 @@
 		echo >&2
 	fi
 	cat >&2 <<EOUSAGE
-Usage: $0 [-target target-triplet] [-pass-thresh pass-ratio-threshold] PREVIOUS CURRENT
+Usage: $0 [-target target-triplet] [-pass-thresh pass-ratio-threshold] [-compr compression-type] PREVIOUS CURRENT
 
 Compare the PREVIOUS and CURRENT test case .sum files, reporting anything of interest.
 
@@ -26,6 +26,10 @@
         -pass-thresh controls the level of warning when too few tests
          pass.
 
+        -compr controls the compression type used when searching for
+         the .sum files. Defaults to xz, use 'none' for uncompressed
+         .sum files.
+
 	Exit with the following values:
 		0 if there is nothing of interest
 		1 if there are improvements
@@ -56,6 +60,8 @@
 sum1=/tmp/$tool-sum1.$$
 sum2=/tmp/$tool-sum2.$$
 tmps="$tmp1 $tmp2 $now_s $before_s $lst1 $lst2 $lst3 $lst4 $lst5 $sum1 $sum2"
+compr="xz"
+compr_suffix=".xz"
 
 while [ $# -gt 2 ]
 do
@@ -68,6 +74,15 @@
 	    pass_thresh=$2
 	    shift 2
 	    ;;
+	"-compr")
+	    compr=$2
+	    compr_suffix=".$2"
+	    shift 2
+	    if [ x"$compr" = xnone ]; then
+		compr=""
+		compr_suffix=""
+	    fi
+	    ;;
 	"-?")
 	    usage
 	    ;;
@@ -86,8 +101,8 @@
 exit_status=0
 
 if [ -d "$1" -a -d "$2" ] ; then
-	find "$1/" \( -name '*.sum.xz' \)>$lst1
-	find "$2/" \( -name '*.sum.xz' \)>$lst2
+	find "$1/" \( -name "*.sum${compr_suffix}" \)>$lst1
+	find "$2/" \( -name "*.sum${compr_suffix}" \)>$lst2
 	echo "# Comparing directories"
 	echo "# REFERENCE: $1"
 	echo "# CURRENT:   $2"
@@ -119,13 +134,13 @@
 	echo "# Comparing $cmnsums common sum files:"
 	cat $lst5
 	( for fname in `cat $lst5`; do
-	    bname=`basename $fname .sum.xz`
-	    xzcat $1/$fname | sed -e "s/^\([A-Z]*: \)/\1 $bname:/" | sed -r 's:of file /home.*/gcc/:of file :;s:==[0-9]+==:==X==:;s/output pattern test,.*$/output pattern XXX/' \
+	    bname=`basename $fname .sum${compr_suffix}`
+	    ${compr}cat $1/$fname | sed -e "s/^\([A-Z]*: \)/\1 $bname:/" | sed -r 's:of file /home.*/gcc/:of file :;s:==[0-9]+==:==X==:;s/output pattern test,.*$/output pattern XXX/' \
 		| sed -e "s|^\([A-Z]*: \).*/home/.*/testsuite/|\1|"
 	  done ) >$sum1
 	( for fname in `cat $lst5`; do
-	    bname=`basename $fname .sum.xz`
-	    xzcat $2/$fname | sed -e "s/^\([A-Z]*: \)/\1 $bname:/" | sed -r 's:of file /home.*/gcc/:of file :;s:==[0-9]+==:==X==:;s/output pattern test,.*$/output pattern XXX/' \
+	    bname=`basename $fname .sum${compr_suffix}`
+	    ${compr}cat $2/$fname | sed -e "s/^\([A-Z]*: \)/\1 $bname:/" | sed -r 's:of file /home.*/gcc/:of file :;s:==[0-9]+==:==X==:;s/output pattern test,.*$/output pattern XXX/' \
 		| sed -e "s|^\([A-Z]*: \).*/home/.*/testsuite/|\1|"
 	  done ) >$sum2
 	if [ "x${target}" != "x" ] ; then