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

Comparing AnyEvent/t/62_cocoa_03_child.t (file contents):
Revision 1.2 by root, Mon Jul 4 21:14:27 2011 UTC vs.
Revision 1.6 by root, Sat Oct 1 22:39:29 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines