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

Comparing AnyEvent/t/09_multi.t (file contents):
Revision 1.4 by root, Fri Aug 12 00:53:29 2011 UTC vs.
Revision 1.8 by root, Sat Aug 27 16:01:49 2011 UTC

12 exit 0; 12 exit 0;
13 } 13 }
14 } 14 }
15} 15}
16 16
17$^W = 0; # 5.8.6 bugs
18
17use AnyEvent; 19use AnyEvent;
18use AnyEvent::Util; 20use AnyEvent::Util;
19BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} } 21BEGIN { require AnyEvent::Impl::Perl unless $ENV{PERL_ANYEVENT_MODEL} }
20 22
21$| = 1; print "1..15\n"; 23$| = 1; print "1..15\n";
22 24
23print "ok 1\n"; 25print "ok 1\n";
26
27$AnyEvent::MAX_SIGNAL_LATENCY = 0.05;
24 28
25my ($a, $b) = AnyEvent::Util::portable_socketpair; 29my ($a, $b) = AnyEvent::Util::portable_socketpair;
26 30
27# I/O write 31# I/O write
28{ 32{
39} 43}
40 44
41# I/O read 45# I/O read
42{ 46{
43 my $cv = AE::cv; 47 my $cv = AE::cv;
44 my $wt = AE::timer 0.1, 0, $cv; 48 my $wt = AE::timer 0.01, 0, $cv;
45 my $s = 0; 49 my $s = 0;
46 50
47 my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 }; 51 my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 };
48 my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 }; 52 my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 };
49 53
64 print $s == 3 ? "" : "not ", "ok 4 # $s\n"; 68 print $s == 3 ? "" : "not ", "ok 4 # $s\n";
65 69
66 sysread $a, my $dummy, 1; 70 sysread $a, my $dummy, 1;
67 71
68 $cv = AE::cv; 72 $cv = AE::cv;
69 $wt = AE::timer 0.1, 0, $cv; 73 $wt = AE::timer 0.01, 0, $cv;
70 74
71 $s = 0; 75 $s = 0;
72 $cv->recv; 76 $cv->recv;
73 77
74 print $s == 0 ? "" : "not ", "ok 5 # $s\n"; 78 print $s == 0 ? "" : "not ", "ok 5 # $s\n";
75} 79}
76 80
77# signal 81# signal
78{ 82{
79 my $cv = AE::cv; 83 my $cv = AE::cv;
80 my $wt = AE::timer 0.1, 0, $cv; 84 my $wt = AE::timer 0.01, 0, $cv;
81 my $s = 0; 85 my $s = 0;
82 86
83 $cv->begin; my $wa = AE::signal INT => sub { $cv->end; $s |= 1 }; 87 $cv->begin; my $wa = AE::signal INT => sub { $cv->end; $s |= 1 };
84 $cv->begin; my $wb = AE::signal INT => sub { $cv->end; $s |= 2 }; 88 $cv->begin; my $wb = AE::signal INT => sub { $cv->end; $s |= 2 };
85 89
88 print $s == 0 ? "" : "not ", "ok 6 # $s\n"; 92 print $s == 0 ? "" : "not ", "ok 6 # $s\n";
89 93
90 kill INT => $$; 94 kill INT => $$;
91 95
92 $cv = AE::cv; 96 $cv = AE::cv;
93 $wt = AE::timer 0.1, 0, $cv; 97 $wt = AE::timer 0.2, 0, $cv; # maybe OS X needs more time here?
94 98
95 $s = 0; 99 $s = 0;
96 $cv->recv; 100 $cv->recv;
97 101
98 print $s == 3 ? "" : "not ", "ok 7 # $s\n"; 102 print $s == 3 ? "" : "not ", "ok 7 # $s\n";
99 103
100 $cv = AE::cv; 104 $cv = AE::cv;
101 $wt = AE::timer 0.1, 0, $cv; 105 $wt = AE::timer 0.01, 0, $cv;
102 106
103 $s = 0; 107 $s = 0;
104 $cv->recv; 108 $cv->recv;
105 109
106 print $s == 0 ? "" : "not ", "ok 8 # $s\n"; 110 print $s == 0 ? "" : "not ", "ok 8 # $s\n";
107} 111}
108 112
109$AnyEvent::MAX_SIGNAL_LATENCY = 0.2;
110
111# child 113# child
112{ 114{
113 my $cv = AE::cv; 115 my $cv = AE::cv;
114 my $wt = AE::timer 0.1, 0, $cv; 116 my $wt = AE::timer 0.01, 0, $cv;
115 my $s = 0; 117 my $s = 0;
116 118
117 my $pid = fork; 119 my $pid = fork;
118 120
119 unless ($pid) { 121 unless ($pid) {
131 print $s == 0 ? "" : "not ", "ok 9 # $s\n"; 133 print $s == 0 ? "" : "not ", "ok 9 # $s\n";
132 134
133 kill 9, $pid; 135 kill 9, $pid;
134 136
135 $cv = AE::cv; 137 $cv = AE::cv;
136 $wt = AE::timer 0.1, 0, $cv; 138 $wt = AE::timer 0.2, 0, $cv; # cygwin needs ages for this
137 139
138 $s = 0; 140 $s = 0;
139 $cv->recv; 141 $cv->recv;
140 142
141 print $s == 3 ? "" : "not ", "ok 10 # $s\n"; 143 print $s == 3 ? "" : "not ", "ok 10 # $s\n";
142 print $apid == $pid && $bpid == $pid ? "" : "not ", "ok 11 # $apid == $bpid == $pid\n"; 144 print $apid == $pid && $bpid == $pid ? "" : "not ", "ok 11 # $apid == $bpid == $pid\n";
143 print $astatus == 9 && $bstatus == 9 ? "" : "not ", "ok 12 # $astatus == $bstatus == 9\n"; 145 print $astatus == 9 && $bstatus == 9 ? "" : "not ", "ok 12 # $astatus == $bstatus == 9\n";
144 146
145 $cv = AE::cv; 147 $cv = AE::cv;
146 $wt = AE::timer 0.1, 0, $cv; 148 $wt = AE::timer 0.01, 0, $cv;
147 149
148 $s = 0; 150 $s = 0;
149 $cv->recv; 151 $cv->recv;
150 152
151 print $s == 0 ? "" : "not ", "ok 13 # $s\n"; 153 print $s == 0 ? "" : "not ", "ok 13 # $s\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines