diff options
author | Jim Meyering <jim@meyering.net> | 2007-02-13 22:27:27 +0100 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-02-13 22:27:27 +0100 |
commit | d163cd681a5a2796f47c79faccd00d193b50dc09 (patch) | |
tree | c1072595f63926a6c0889da906f5809e97fea79b /tests | |
parent | 0d8ca457b3df2710819a99091c7960120999a421 (diff) | |
download | coreutils-d163cd681a5a2796f47c79faccd00d193b50dc09.tar.xz |
Also check for and print stderr output, in case a program fails.
* tests/misc/tty-eof: Occasionally (not reproducible), this
test would fail, with one or more programs exiting nonzero, e.g.,
tty-eof: sha224sum exited with status 1 (expected 0)
Now, maybe we'll get a clue, the next time that happens.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/misc/tty-eof | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/tests/misc/tty-eof b/tests/misc/tty-eof index 37d4c3a04..ef60fda0a 100755 --- a/tests/misc/tty-eof +++ b/tests/misc/tty-eof @@ -1,7 +1,8 @@ #!/bin/sh +# -*- perl -*- # Test whether programs exit upon a single EOF from a tty. -# Copyright (C) 2003, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -76,11 +77,12 @@ $@ and (warn "$ME: this script requires Perl's Expect package >=1.11\n"), uniq wc ); + my $stderr = 'tty-eof.err'; foreach my $cmd ((@stdin_reading_commands), 'cut -f2') { my $exp = new Expect; $exp->log_user(0); - $exp->spawn($cmd) + $exp->spawn("$cmd 2> $stderr") or (warn "$ME: cannot run `$cmd': $!\n"), $fail=1, next; # No input for cut -f2. $cmd =~ /^cut/ @@ -94,7 +96,7 @@ $@ and (warn "$ME: this script requires Perl's Expect package >=1.11\n"), defined $found || $cmd =~ /^cut/ or (warn "$ME: $cmd didn't produce expected output\n"), $fail=1, next; - defined defined $exp->exitstatus + defined $exp->exitstatus or (warn "$ME: $cmd didn't exit after ^D from standard input\n"), $fail=1, next; my $s = $exp->exitstatus; @@ -102,6 +104,22 @@ $@ and (warn "$ME: this script requires Perl's Expect package >=1.11\n"), or (warn "$ME: $cmd exited with status $s (expected 0)\n"), $fail=1; $exp->hard_close(); + + # dd normally writes to stderr. If it exits successfully, we're done. + $cmd eq 'dd' && $s == 0 + and next; + + if (-s $stderr) + { + warn "$ME: $cmd wrote to stderr:\n"; + system "cat $stderr"; + $fail = 1; + } + } + continue + { + unlink $stderr + or warn "$ME: failed to remove stderr file from $cmd, $stderr: $!\n"; } exit $fail |