summaryrefslogtreecommitdiff
path: root/t/io/openpid.t
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2001-12-09 22:27:02 -0500
committerJarkko Hietaniemi <jhi@iki.fi>2001-12-10 13:18:17 +0000
commitf0060996d7bafc6d707ef3515e2e04ddfaa8e018 (patch)
tree9f3958745bb72b467078798a1337f3bd4594dd60 /t/io/openpid.t
parent799d3a59780e57cb02724d2751aa6f96a6697751 (diff)
downloadperl-f0060996d7bafc6d707ef3515e2e04ddfaa8e018.tar.gz
Re: [PATCH t/io/openpid.t] Cleanup
Message-ID: <20011210082702.GN1770@blackrider> p4raw-id: //depot/perl@13591
Diffstat (limited to 't/io/openpid.t')
-rwxr-xr-xt/io/openpid.t56
1 files changed, 27 insertions, 29 deletions
diff --git a/t/io/openpid.t b/t/io/openpid.t
index 7c04a29fe8..3b0ac6bdd0 100755
--- a/t/io/openpid.t
+++ b/t/io/openpid.t
@@ -10,19 +10,22 @@
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
- if ($^O eq 'dos') {
- print "1..0 # Skip: no multitasking\n";
- exit 0;
- }
+ require './test.pl';
}
+if ($^O eq 'dos') {
+ skip_all("no multitasking");
+}
+
+plan tests => 10;
+
+
use Config;
$| = 1;
$SIG{PIPE} = 'IGNORE';
-print "1..10\n";
-
-$perl = qq[$^X "-I../lib"];
+my $perl = which_perl();
+$perl .= qq[ "-I../lib"];
#
# commands run 4 perl programs. Two of these programs write a
@@ -39,14 +42,10 @@ $cmd4 = qq/$perl -e "print scalar <>;"/;
#warn "#$cmd1\n#$cmd2\n#$cmd3\n#$cmd4\n";
# start the processes
-$pid1 = open(FH1, "$cmd1 |") or print "not ";
-print "ok 1\n";
-$pid2 = open(FH2, "$cmd2 |") or print "not ";
-print "ok 2\n";
-$pid3 = open(FH3, "| $cmd3") or print "not ";
-print "ok 3\n";
-$pid4 = open(FH4, "| $cmd4") or print "not ";
-print "ok 4\n";
+ok( $pid1 = open(FH1, "$cmd1 |"), 'first process started');
+ok( $pid2 = open(FH2, "$cmd2 |"), ' second' );
+ok( $pid3 = open(FH3, "| $cmd3"), ' third' );
+ok( $pid4 = open(FH4, "| $cmd4"), ' fourth' );
print "# pids were $pid1, $pid2, $pid3, $pid4\n";
@@ -55,28 +54,27 @@ $killsig = 1 unless $Config{sig_name} =~ /\bHUP\b/;
# get message from first process and kill it
chomp($from_pid1 = scalar(<FH1>));
-print "# child1 returned [$from_pid1]\nnot "
- unless $from_pid1 eq 'first process';
-print "ok 5\n";
+is( $from_pid1, 'first process', 'message from first process' );
+
$kill_cnt = kill $killsig, $pid1;
-print "not " unless $kill_cnt == 1;
-print "ok 6\n";
+is( $kill_cnt, 1, 'first process killed' ) ||
+ print "# errno == $!\n";
# get message from second process and kill second process and reader process
chomp($from_pid2 = scalar(<FH2>));
-print "# child2 returned [$from_pid2]\nnot "
- unless $from_pid2 eq 'second process';
-print "ok 7\n";
+is( $from_pid2, 'second process', 'message from second process' );
+
$kill_cnt = kill $killsig, $pid2, $pid3;
-print "not " unless $kill_cnt == 2;
-print "ok 8\n";
+is( $kill_cnt, 2, 'killing procs 2 & 3' ) ||
+ print "# errno == $!\n";
+
# send one expected line of text to child process and then wait for it
select(FH4); $| = 1; select(STDOUT);
-print FH4 "ok 9\n";
+printf FH4 "ok %d - text sent to fourth process\n", curr_test();
+next_test();
print "# waiting for process $pid4 to exit\n";
$reap_pid = waitpid $pid4, 0;
-print "# reaped pid $reap_pid != $pid4\nnot "
- unless $reap_pid == $pid4;
-print "ok 10\n";
+is( $reap_pid, $pid4, 'fourth process reaped' );
+