summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-02-18 07:59:58 +0000
committerJim Meyering <jim@meyering.net>2003-02-18 07:59:58 +0000
commit33c62fcef39b82c46ee94c3194dbf4650a11de55 (patch)
treefc6904c8ecc4e3d266976de3e6a847f4efa74f12 /tests/misc
parentd3dbf68beb13c32120f689d75e94a43ccf28b33d (diff)
downloadcoreutils-33c62fcef39b82c46ee94c3194dbf4650a11de55.tar.xz
Generalize, clean-up, and test for
cat, cksum, md5sum, and sha1sum all in the same loop.
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/cat-tty-eof31
1 files changed, 21 insertions, 10 deletions
diff --git a/tests/misc/cat-tty-eof b/tests/misc/cat-tty-eof
index c8acdd54b..1d7a3edbb 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