diff options
author | Jim Meyering <meyering@fb.com> | 2017-06-29 18:06:11 -0700 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2017-07-01 09:30:51 -0700 |
commit | 9fbc2fb1823c71a9d3370e0b04886c5994000fa8 (patch) | |
tree | 4c7866f579ce32503a97fee1a45f498d21d31416 /tests | |
parent | bdce7a23e55e82efa429e001dd6f2979d7f5d351 (diff) | |
download | grep-9fbc2fb1823c71a9d3370e0b04886c5994000fa8.tar.gz |
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
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/filename-lineno.pl | 3 | ||||
-rwxr-xr-x | tests/in-eq-out-infloop | 2 | ||||
-rwxr-xr-x | tests/reversed-range-endpoints | 6 | ||||
-rwxr-xr-x | 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 8eead57a..6cc86b79 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 17428256..c6d59687 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 07374478..4c2193cf 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 f2ab6da6..e79c45be 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 |