From: Jim Meyering Date: Tue, 18 Feb 2003 07:59:58 +0000 (+0000) Subject: Generalize, clean-up, and test for X-Git-Tag: v4.5.8~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33c62fcef39b82c46ee94c3194dbf4650a11de55;p=thirdparty%2Fcoreutils.git Generalize, clean-up, and test for cat, cksum, md5sum, and sha1sum all in the same loop. --- diff --git a/tests/misc/cat-tty-eof b/tests/misc/cat-tty-eof index c8acdd54b4..1d7a3edbb7 100755 --- a/tests/misc/cat-tty-eof +++ b/tests/misc/cat-tty-eof @@ -21,15 +21,26 @@ eval { require Expect }; $@ and (warn "$ME: this script requires Perl's Expect package\n"), exit 77; { - my $exp = new Expect; - # $exp->log_user(0); - $exp->spawn('cat') - or die "$ME: cannot run `cat': $!\n"; - - $exp->send(''); - !defined $exp->exitstatus || $exp->exitstatus - or die "$ME: cat didn't exit after ^D from standard input\n"; - $exp->hard_close(); - exit 0 + my $fail = 0; + foreach my $cmd (qw(md5sum sha1sum cksum cat)) + { + my $exp = new Expect; + $exp->log_user(0); + $exp->spawn($cmd) + or (warn "$ME: cannot run `$cmd': $!\n"), $fail=1, next; + $exp->send("foo\n"); + $exp->send(''); # FIXME: it'd be better not to hard-code ^D here + $exp->expect (0, '-re', "^foo\\r?\$"); + my $found = $exp->expect (1, '-re', "^.+\$"); + $found and warn "F: $found: " . $exp->exp_match () . "\n"; + $exp->expect(0, 'eof'); + # defined $exp->exitstatus and warn "E: " . $exp->exitstatus . "\n"; + defined $found && defined $exp->exitstatus && $exp->exitstatus == 0 + or (warn "$ME: $cmd didn't exit after ^D from standard input\n"), + $fail=1; + $exp->hard_close(); + } + + exit $fail } EOF