]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compare_tests: Don't hardcode grep -E
authorPietro Monteiro <pietro@sociotechnical.xyz>
Sat, 31 Jan 2026 03:27:14 +0000 (22:27 -0500)
committerPietro Monteiro <pietro@sociotechnical.xyz>
Sat, 31 Jan 2026 03:27:14 +0000 (22:27 -0500)
The non-unique test names report is broken on systems where 'grep -E' is
not supported.  Use egrep if a simple test for 'grep -E' fails.

contrib/ChangeLog:

* compare_tests: Use egrep if 'grep -E' is not supported.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
contrib/compare_tests

index 8efd15e903f15fd7673b14ed3fe6b522a1e1e1a8..d507eead908689e31617762552f9e0a57e9f0b44 100755 (executable)
@@ -136,8 +136,14 @@ sort -t ':' $skip1 "$before" > "$before_s"
 # If we used the input files (so generally several times the same
 # results in one section per target), we would incorreclty detect
 # duplicates (as many as targets)
-grep -E '^(PASS|XPASS|FAIL|XFAIL|UNRESOLVED|UNSUPPORTED|UNTESTED|ERROR):' "$now_s"    | uniq -cd > "$now_u"
-grep -E '^(PASS|XPASS|FAIL|XFAIL|UNRESOLVED|UNSUPPORTED|UNTESTED|ERROR):' "$before_s" | uniq -cd > "$before_u"
+EGREP="grep -E"
+
+if ! echo PASS | $EGREP '^(PASS|FAIL)' >/dev/null 2>&1; then
+    EGREP="egrep"
+fi
+
+$EGREP '^(PASS|XPASS|FAIL|XFAIL|UNRESOLVED|UNSUPPORTED|UNTESTED|ERROR):' "$now_s"    | uniq -cd > "$now_u"
+$EGREP '^(PASS|XPASS|FAIL|XFAIL|UNRESOLVED|UNSUPPORTED|UNTESTED|ERROR):' "$before_s" | uniq -cd > "$before_u"
 
 same_uniq=" now"
 cmp -s "$before_u" "$now_u" && same_uniq=""
@@ -151,7 +157,7 @@ fi
 
 if [ -s "$before_u" -a "x$same_uniq" != "x" ]; then
     echo "Changes to non-unique test names:"
-    diff -u "$before_u" "$now_u" | grep -E '^[-\\+] '
+    diff -u "$before_u" "$now_u" | $EGREP '^[-\\+] '
     echo
     exit_status=1
 fi