ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/t/69_ev_03_child.t
(Generate patch)

Comparing AnyEvent/t/69_ev_03_child.t (file contents):
Revision 1.1 by root, Thu Oct 2 08:43:58 2008 UTC vs.
Revision 1.4 by root, Sat Jul 18 00:05:29 2009 UTC

1$|=1; 1use POSIX ();
2BEGIN { unless (eval "require EV") { print "1..0 # skip because EV isn't installed"; exit } } 2
3use AnyEvent;
4BEGIN { eval q{use AnyEvent::Impl::EV;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::EV not found}), exit 0) }
3 5
4BEGIN { 6BEGIN {
5 # check for broken perls 7 # check for broken perls
6 if ($^O =~ /mswin32/i) { 8 if ($^O =~ /mswin32/i) {
7 my $ok; 9 my $ok;
15 exit 0; 17 exit 0;
16 } 18 }
17 } 19 }
18} 20}
19 21
20BEGIN {
21 print "1..7\n" 22$| = 1; print "1..7\n";
22}
23 23
24use AnyEvent; 24$AnyEvent::MAX_SIGNAL_LATENCY = 1;
25use AnyEvent::Impl::EV;
26 25
27print "ok 1\n"; 26print "ok 1\n";
28 27
29AnyEvent::detect; # force-load event model 28AnyEvent::detect; # force-load event model
30 29
37 36
38my $cv = AnyEvent->condvar; 37my $cv = AnyEvent->condvar;
39 38
40unless ($pid) { 39unless ($pid) {
41 print "ok 2\n"; 40 print "ok 2\n";
42 exit 3; 41 POSIX::_exit 3;
43} 42}
44 43
45my $w = AnyEvent->child (pid => $pid, cb => sub { 44my $w = AnyEvent->child (pid => $pid, cb => sub {
46 print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n"; 45 print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n";
47 print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n"; 46 print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n";
48 $cv->broadcast; 47 $cv->broadcast;
49}); 48});
50 49
51$cv->wait; 50$cv->wait;
52 51
53my $pid2 = fork || exit 7; 52my $pid2 = fork || POSIX::_exit 7;
54 53
55my $cv2 = AnyEvent->condvar; 54my $cv2 = AnyEvent->condvar;
56 55
57my $w2 = AnyEvent->child (pid => 0, cb => sub { 56my $w2 = AnyEvent->child (pid => 0, cb => sub {
58 print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n"; 57 print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines