From d163cd681a5a2796f47c79faccd00d193b50dc09 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 13 Feb 2007 22:27:27 +0100 Subject: 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. --- ChangeLog | 8 ++++++++ tests/misc/tty-eof | 24 +++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e201cf70a..77157c746 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-02-13 Jim Meyering + + 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. + 2007-02-12 Jim Meyering * .x-sc_useless_cpp_parens: Ignore a false-positive in a shell script. 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 -- cgit v1.2.3-70-g09d2