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.7 by root, Sat Jul 18 15:51:52 2009 UTC vs.
Revision 1.11 by root, Tue Aug 2 22:07:18 2011 UTC

1use POSIX (); 1use POSIX ();
2 2
3no warnings; 3no warnings;
4
5use AnyEvent;
6BEGIN { eval q{use AnyEvent::Impl::POE;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::POE not found}), exit 0) } $^W = 0;
7 4
8BEGIN { 5BEGIN {
9 # check for broken perls 6 # check for broken perls
10 if ($^O =~ /mswin32/i) { 7 if ($^O =~ /mswin32/i) {
11 my $ok; 8 my $ok;
12 local $SIG{CHLD} = sub { $ok = 1 }; 9 local $SIG{CHLD} = sub { $ok = 1 };
13 kill 'CHLD', 0; 10 kill 'CHLD', 0;
14 11
15 unless ($ok) { 12 unless ($ok) {
16 print <<EOF; 13 print <<EOF;
171..0 # Your perl interpreter is badly BROKEN. Child watchers will not work, ever. Try upgrading to a newer perl or a working perl (cygwin's perl is known to work). If that is not an option, you should be able to use the remaining functionality of AnyEvent, but child watchers WILL NOT WORK. 141..0 # SKIP Your perl interpreter is badly BROKEN. Child watchers will not work, ever. Try upgrading to a newer perl or a working perl (cygwin's perl is known to work). If that is not an option, you should be able to use the remaining functionality of AnyEvent, but child watchers WILL NOT WORK.
18EOF 15EOF
19 exit 0; 16 exit 0;
20 } 17 }
21 } 18 }
22} 19}
20
21use AnyEvent;
22BEGIN { eval q{use AnyEvent::Impl::POE;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::POE not loadable
23}), exit 0) } $^W = 0;
23 24
24$| = 1; print "1..50\n"; 25$| = 1; print "1..50\n";
25 26
26$AnyEvent::MAX_SIGNAL_LATENCY = 0.2; 27$AnyEvent::MAX_SIGNAL_LATENCY = 0.2;
27 28
32 33
33 my $pid = fork; 34 my $pid = fork;
34 35
35 defined $pid or die "unable to fork"; 36 defined $pid or die "unable to fork";
36 37
37# work around Tk bug until it has been fixed. 38 # work around Tk bug until it has been fixed.
38#my $timer = AnyEvent->timer (after => 2, cb => sub { }); 39 #my $timer = AnyEvent->timer (after => 2, cb => sub { });
39 40
40 my $cv = AnyEvent->condvar; 41 my $cv = AnyEvent->condvar;
41 42
42 unless ($pid) { 43 unless ($pid) {
43 print "ok ${it}2\n"; 44 print "ok ${it}2\n";
48 print $pid == $_[0] ? "" : "not ", "ok ${it}3\ # $pid == $_[0]\n"; 49 print $pid == $_[0] ? "" : "not ", "ok ${it}3\ # $pid == $_[0]\n";
49 print 3 == ($_[1] >> 8) ? "" : "not ", "ok ${it}4 # 3 == $_[1] >> 8 ($_[1])\n"; 50 print 3 == ($_[1] >> 8) ? "" : "not ", "ok ${it}4 # 3 == $_[1] >> 8 ($_[1])\n";
50 $cv->broadcast; 51 $cv->broadcast;
51 }); 52 });
52 53
53 $cv->wait; 54 $cv->recv;
54 55
55 my $pid2 = fork || POSIX::_exit 7; 56 my $pid2 = fork || POSIX::_exit 7;
56 57
57 my $cv2 = AnyEvent->condvar; 58 my $cv2 = AnyEvent->condvar;
58 59
60 # Glib is the only model that doesn't support pid == 0
61 my $pid0 = $AnyEvent::MODEL eq "AnyEvent::Impl::Glib" ? $pid2 : 0;
62
59 my $w2 = AnyEvent->child (pid => 0, cb => sub { 63 my $w2 = AnyEvent->child (pid => $pid0, cb => sub {
60 print $pid2 == $_[0] ? "" : "not ", "ok ${it}5 # $pid2 == $_[0]\n"; 64 print $pid2 == $_[0] ? "" : "not ", "ok ${it}5 # $pid2 == $_[0]\n";
61 print 7 == ($_[1] >> 8) ? "" : "not ", "ok ${it}6 # 7 == $_[1] >> 8 ($_[1])\n"; 65 print 7 == ($_[1] >> 8) ? "" : "not ", "ok ${it}6 # 7 == $_[1] >> 8 ($_[1])\n";
62 $cv2->broadcast; 66 $cv2->broadcast;
63 }); 67 });
64 68
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"; 71Bail 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 72EOF
69 exit 0; 73 exit 0;
70 }); 74 });
71 75
72 $cv2->wait; 76 $cv2->recv;
73 77
74 print "ok ${it}7\n"; 78 print "ok ${it}7\n";
75 print "ok ${it}8\n"; 79 print "ok ${it}8\n";
76 print "ok ${it}9\n"; 80 print "ok ${it}9\n";
77 print "ok ", $it*10+10, "\n"; 81 print "ok ", $it*10+10, "\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines