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

Comparing AnyEvent/t/68_poe_03_child.t (file contents):
Revision 1.2 by root, Thu Apr 23 22:44:30 2009 UTC vs.
Revision 1.3 by root, Thu Jul 9 22:49:18 2009 UTC

1$|=1;
2$^W=0;
3
4BEGIN { 1BEGIN {
5 # check for broken perls 2 # check for broken perls
6 if ($^O =~ /mswin32/i) { 3 if ($^O =~ /mswin32/i) {
7 my $ok; 4 my $ok;
8 local $SIG{CHLD} = sub { $ok = 1 }; 5 local $SIG{CHLD} = sub { $ok = 1 };
16 } 13 }
17 } 14 }
18} 15}
19 16
20BEGIN { 17BEGIN {
18 $|=1;
21 print "1..7\n" 19 print "1..7\n"
22} 20}
23 21
22use POSIX ();
23
24use AnyEvent; 24use AnyEvent;
25use AnyEvent::Impl::POE; 25use AnyEvent::Impl::POE; $^W = 0;
26 26
27print "ok 1\n"; 27print "ok 1\n";
28 28
29AnyEvent::detect; # force-load event model 29AnyEvent::detect; # force-load event model
30 30
37 37
38my $cv = AnyEvent->condvar; 38my $cv = AnyEvent->condvar;
39 39
40unless ($pid) { 40unless ($pid) {
41 print "ok 2\n"; 41 print "ok 2\n";
42 exit 3; 42 POSIX::_exit 3;
43} 43}
44 44
45my $w = AnyEvent->child (pid => $pid, cb => sub { 45my $w = AnyEvent->child (pid => $pid, cb => sub {
46 print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n"; 46 print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n";
47 print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n"; 47 print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n";
48 $cv->broadcast; 48 $cv->broadcast;
49}); 49});
50 50
51$cv->wait; 51$cv->wait;
52 52
53my $pid2 = fork || exit 7; 53my $pid2 = fork || POSIX::_exit 7;
54 54
55my $cv2 = AnyEvent->condvar; 55my $cv2 = AnyEvent->condvar;
56 56
57my $w2 = AnyEvent->child (pid => 0, cb => sub { 57my $w2 = AnyEvent->child (pid => 0, cb => sub {
58 print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n"; 58 print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n";
59 print 7 == ($_[1] >> 8) ? "" : "not ", "ok 6 # 7 == $_[1] >> 8 ($_[1])\n"; 59 print 7 == ($_[1] >> 8) ? "" : "not ", "ok 6 # 7 == $_[1] >> 8 ($_[1])\n";
60 $cv2->broadcast; 60 $cv2->broadcast;
61}); 61});
62 62
63my $error = AnyEvent->timer (after => 5, cb => sub { 63my $error = AnyEvent->timer (after => 15, cb => sub {
64 print <<EOF; 64 print <<EOF;
65Bail out! No child exit detected. This is either a bug in AnyEvent or a bug in your Perl (mostly some windows distributions suffer from that): child watchers might not work properly on this platform. You can force installation of this module if you do not rely on child watchers, or you could upgrade to a working version of Perl for your platform.\n"; 65Bail out! No child exit detected. This is either a bug in AnyEvent or a bug in your Perl (mostly some windows distributions suffer from that): child watchers might not work properly on this platform. You can force installation of this module if you do not rely on child watchers, or you could upgrade to a working version of Perl for your platform.\n";
66EOF 66EOF
67 exit 0; 67 exit 0;
68});
69
70my $inter = AnyEvent->timer (after => 14, cb => sub {
71 print "not ok 5 # inter\n";
72 print "not ok 6 # inter\n";
73 $cv2->send;
68}); 74});
69 75
70$cv2->wait; 76$cv2->wait;
71 77
72print "ok 7\n"; 78print "ok 7\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines