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

Comparing AnyEvent/t/64_glib_03_child.t (file contents):
Revision 1.1 by root, Thu Oct 2 08:43:57 2008 UTC vs.
Revision 1.3 by root, Fri Jul 17 22:05:12 2009 UTC

1$|=1;
2
3BEGIN { 1BEGIN {
4 # check for broken perls 2 # check for broken perls
5 if ($^O =~ /mswin32/i) { 3 if ($^O =~ /mswin32/i) {
6 my $ok; 4 my $ok;
7 local $SIG{CHLD} = sub { $ok = 1 }; 5 local $SIG{CHLD} = sub { $ok = 1 };
15 } 13 }
16 } 14 }
17} 15}
18 16
19BEGIN { 17BEGIN {
18 $|=1;
20 print "1..7\n" 19 print "1..7\n"
21} 20}
22 21
22use POSIX ();
23
23use AnyEvent; 24use AnyEvent;
24use AnyEvent::Impl::Glib; 25use AnyEvent::Impl::Glib;
26
27$AnyEvent::MAX_SIGNAL_LATENCY = 1;
25 28
26print "ok 1\n"; 29print "ok 1\n";
27 30
28AnyEvent::detect; # force-load event model 31AnyEvent::detect; # force-load event model
29 32
36 39
37my $cv = AnyEvent->condvar; 40my $cv = AnyEvent->condvar;
38 41
39unless ($pid) { 42unless ($pid) {
40 print "ok 2\n"; 43 print "ok 2\n";
41 exit 3; 44 POSIX::_exit 3;
42} 45}
43 46
44my $w = AnyEvent->child (pid => $pid, cb => sub { 47my $w = AnyEvent->child (pid => $pid, cb => sub {
45 print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n"; 48 print $pid == $_[0] ? "" : "not ", "ok 3\ # $pid == $_[0]\n";
46 print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n"; 49 print 3 == ($_[1] >> 8) ? "" : "not ", "ok 4 # 3 == $_[1] >> 8 ($_[1])\n";
47 $cv->broadcast; 50 $cv->broadcast;
48}); 51});
49 52
50$cv->wait; 53$cv->wait;
51 54
52my $pid2 = fork || exit 7; 55my $pid2 = fork || POSIX::_exit 7;
53 56
54my $cv2 = AnyEvent->condvar; 57my $cv2 = AnyEvent->condvar;
55 58
56my $w2 = AnyEvent->child (pid => 0, cb => sub { 59my $w2 = AnyEvent->child (pid => 0, cb => sub {
57 print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n"; 60 print $pid2 == $_[0] ? "" : "not ", "ok 5 # $pid2 == $_[0]\n";
58 print 7 == ($_[1] >> 8) ? "" : "not ", "ok 6 # 7 == $_[1] >> 8 ($_[1])\n"; 61 print 7 == ($_[1] >> 8) ? "" : "not ", "ok 6 # 7 == $_[1] >> 8 ($_[1])\n";
59 $cv2->broadcast; 62 $cv2->broadcast;
60}); 63});
61 64
62my $error = AnyEvent->timer (after => 5, cb => sub { 65my $error = AnyEvent->timer (after => 15, cb => sub {
63 print <<EOF; 66 print <<EOF;
64Bail 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"; 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";
65EOF 68EOF
66 exit 0; 69 exit 0;
70});
71
72my $inter = AnyEvent->timer (after => 14, cb => sub {
73 print "not ok 5 # inter\n";
74 print "not ok 6 # inter\n";
75 $cv2->send;
67}); 76});
68 77
69$cv2->wait; 78$cv2->wait;
70 79
71print "ok 7\n"; 80print "ok 7\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines