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

Comparing AnyEvent/t/03_child.t (file contents):
Revision 1.19 by root, Wed Dec 29 04:16:33 2010 UTC vs.
Revision 1.22 by root, Sat Oct 1 22:39:29 2011 UTC

32 32
33 my $pid = fork; 33 my $pid = fork;
34 34
35 defined $pid or die "unable to fork"; 35 defined $pid or die "unable to fork";
36 36
37# work around Tk bug until it has been fixed. 37 # work around Tk bug until it has been fixed.
38#my $timer = AnyEvent->timer (after => 2, cb => sub { }); 38 #my $timer = AnyEvent->timer (after => 2, cb => sub { });
39 39
40 my $cv = AnyEvent->condvar; 40 my $cv = AnyEvent->condvar;
41 41
42 unless ($pid) { 42 unless ($pid) {
43 print "ok ${it}2\n"; 43 print "ok ${it}2 # child $$\n";
44 POSIX::_exit 3; 44 POSIX::_exit 3;
45 } 45 }
46
47 my $w = AnyEvent->child (pid => $pid, cb => sub { 46 my $w = AnyEvent->child (pid => $pid, cb => sub {
48 print $pid == $_[0] ? "" : "not ", "ok ${it}3\ # $pid == $_[0]\n"; 47 print $pid == $_[0] ? "" : "not ", "ok ${it}3\ # $pid == $_[0]\n";
49 print 3 == ($_[1] >> 8) ? "" : "not ", "ok ${it}4 # 3 == $_[1] >> 8 ($_[1])\n"; 48 print 3 == ($_[1] >> 8) ? "" : "not ", "ok ${it}4 # 3 == $_[1] >> 8 ($_[1])\n";
50 $cv->broadcast; 49 $cv->broadcast;
51 }); 50 });
52 51
53 $cv->wait; 52 $cv->recv;
54 53
55 my $pid2 = fork || POSIX::_exit 7; 54 my $pid2 = fork || POSIX::_exit 7;
56 55
57 my $cv2 = AnyEvent->condvar; 56 my $cv2 = AnyEvent->condvar;
58 57
58 # Glib is the only model that doesn't support pid == 0
59 my $pid0 = $AnyEvent::MODEL eq "AnyEvent::Impl::Glib" ? $pid2 : 0;
60
59 my $w2 = AnyEvent->child (pid => 0, cb => sub { 61 my $w2 = AnyEvent->child (pid => $pid0, cb => sub {
60 print $pid2 == $_[0] ? "" : "not ", "ok ${it}5 # $pid2 == $_[0]\n"; 62 print $pid2 == $_[0] ? "" : "not ", "ok ${it}5 # $pid2 == $_[0]\n";
61 print 7 == ($_[1] >> 8) ? "" : "not ", "ok ${it}6 # 7 == $_[1] >> 8 ($_[1])\n"; 63 print 7 == ($_[1] >> 8) ? "" : "not ", "ok ${it}6 # 7 == $_[1] >> 8 ($_[1])\n";
62 $cv2->broadcast; 64 $cv2->broadcast;
63 }); 65 });
64 66
67Bail 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"; 69Bail 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";
68EOF 70EOF
69 exit 0; 71 exit 0;
70 }); 72 });
71 73
72 $cv2->wait; 74 $cv2->recv;
73 75
74 print "ok ${it}7\n"; 76 print "ok ${it}7\n";
75 print "ok ${it}8\n"; 77 print "ok ${it}8\n";
76 print "ok ${it}9\n"; 78 print "ok ${it}9\n";
77 print "ok ", $it*10+10, "\n"; 79 print "ok ", $it*10+10, "\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines