On Fri, Jun 30, 2017 at 9:04 AM, Bruno Haible <br...@clisp.org> wrote:
> Hi Jim,
>
>> Does this patch solve the problem?
>
> Yes, this patch fixes the filename-lineno.pl failure. Thanks.
>
> There are 3 similar failures, still. Logs are attached.

Thank you for the details.
Here's a patch that should address those others, too. Can you confirm
that it fixes those problems?
From 48dc9e5fa9191ad06f4221e1817654f84749b558 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyer...@fb.com>
Date: Thu, 29 Jun 2017 18:06:11 -0700
Subject: [PATCH] tests: avoid false failures when run in qemu user mode

* tests/filename-lineno.pl: Derive the program name that grep
will use in diagnostics, based on a suggestion from Assaf Gordon.
* tests/in-eq-out-infloop: Similar: accept an arbitrary "command_name: "
prefix on checked diagnostics, rather than requiring "grep: ".
* tests/reversed-range-endpoints: Likewise.
* tests/write-error-msg: Likewise.
Reported by Bruno Haible in http://bugs.gnu.org/27532
---
 tests/filename-lineno.pl       | 3 +++
 tests/in-eq-out-infloop        | 2 ++
 tests/reversed-range-endpoints | 6 +++---
 tests/write-error-msg          | 2 +-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/tests/filename-lineno.pl b/tests/filename-lineno.pl
index 8eead57..6cc86b7 100755
--- a/tests/filename-lineno.pl
+++ b/tests/filename-lineno.pl
@@ -24,6 +24,9 @@ use strict;
 (my $program_name = $0) =~ s|.*/||;

 my $prog = 'grep';
+my $full_prog_name = `$prog --no-such-option 2>&1`;
+$full_prog_name =~ s/:.*//s;
+$prog = $full_prog_name if $full_prog_name;

 # Turn off localization of executable's output.
 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
diff --git a/tests/in-eq-out-infloop b/tests/in-eq-out-infloop
index 1742825..c6d5968 100755
--- a/tests/in-eq-out-infloop
+++ b/tests/in-eq-out-infloop
@@ -24,6 +24,8 @@ for arg in out - ''; do
   # grep-2.10 and earlier would infloop with $arg = - or $arg = ''.
   timeout 10 grep 0 $arg < out >> out 2> err; st=$?; test $st = 2 || fail=1
   sed 's/file .* is/file ... is/' err > k && mv k err
+  # Normalize the diagnostic prefix from e.g., "/mnt/dir/grep: " to "grep: "
+  sed 's/^[^:]*: /grep: /' err > k && mv k err
   compare err.exp err || fail=1

   # But with each of the following options it must not exit-2.
diff --git a/tests/reversed-range-endpoints b/tests/reversed-range-endpoints
index 0737447..4c2193c 100755
--- a/tests/reversed-range-endpoints
+++ b/tests/reversed-range-endpoints
@@ -4,13 +4,13 @@

 fail=0

-printf 'Invalid range end\n' > exp
+printf 'grep: Invalid range end\n' > exp
 for prog in grep 'grep -E'; do
   # exit status must be 2, not 1
   returns_ 2 $prog '[b-a]' < /dev/null > out 2>&1 || fail=1

-  # Remove "$prog: " prefix from actual output.
-  sed 's/^[grep]*: //' out > k && mv k out
+  # Normalize the diagnostic prefix from e.g., "/mnt/dir/grep: " to "grep: "
+  sed 's/^[^:]*: /grep: /' out > k && mv k out

   compare exp out || fail=1
 done
diff --git a/tests/write-error-msg b/tests/write-error-msg
index f2ab6da..e79c45b 100755
--- a/tests/write-error-msg
+++ b/tests/write-error-msg
@@ -40,7 +40,7 @@ returns_ 2 grep -v '^$' <in >/dev/full 2>err2 \
 # ensure each error message file contains a 'write error' with additional text
 for f in err1 err2 ;
 do
-    grep -Eiq '^grep: write error: [a-z]+' $f \
+    grep -Eiq '^[^:]*: write error: [a-z]+' $f \
         || {
              warn_ "incorrect/missing error message in file $f"
              compare /dev/null $f   # print the content in the logs
-- 
2.13.0

Reply via email to