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

Comparing AnyEvent/t/66_ioasync_09_multi.t (file contents):
Revision 1.2 by root, Thu Aug 4 09:14:03 2011 UTC vs.
Revision 1.7 by root, Sat Aug 27 15:59:13 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 { eval q{use AnyEvent::Impl::IOAsync;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::IOAsync not loadable
20}), exit 0) }
21 21
22 BEGIN { $ENV{PERL_ANYEVENT_LOOP_TESTS} or ((print qq{1..0 # SKIP PERL_ANYEVENT_LOOP_TESTS not true\n}), exit 0) }
23 BEGIN { eval q{use AnyEvent::Impl::IOAsync;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::IOAsync not loadable\n}), exit 0) }
24
25
26
22$| = 1; print "1..14\n"; 27$| = 1; print "1..15\n";
23 28
24print "ok 1\n"; 29print "ok 1\n";
25 30
26my ($a, $b) = AnyEvent::Util::portable_socketpair; 31my ($a, $b) = AnyEvent::Util::portable_socketpair;
27 32
28# I/O write 33# I/O write
29{ 34{
30 my $cv = AE::cv; 35 my $cv = AE::cv;
31 my $wt = AE::timer 0.1, 0, $cv; 36 my $wt = AE::timer 1, 0, $cv;
32 my $s = 0; 37 my $s = 0;
33 38
34 $cv->begin; my $wa = AE::io $a, 1, sub { $cv->end; $s |= 1 }; 39 $cv->begin; my $wa = AE::io $a, 1, sub { $cv->end; $s |= 1 };
35 $cv->begin; my $wb = AE::io $a, 1, sub { $cv->end; $s |= 2 }; 40 $cv->begin; my $wb = AE::io $a, 1, sub { $cv->end; $s |= 2 };
36 41
40} 45}
41 46
42# I/O read 47# I/O read
43{ 48{
44 my $cv = AE::cv; 49 my $cv = AE::cv;
45 my $wt = AE::timer 0.1, 0, $cv; 50 my $wt = AE::timer 0.01, 0, $cv;
46 my $s = 0; 51 my $s = 0;
47 52
48 my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 }; 53 my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 };
49 my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 }; 54 my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 };
50 55
53 print $s == 0 ? "" : "not ", "ok 3 # $s\n"; 58 print $s == 0 ? "" : "not ", "ok 3 # $s\n";
54 59
55 syswrite $b, "x"; 60 syswrite $b, "x";
56 61
57 $cv = AE::cv; 62 $cv = AE::cv;
58 $wt = AE::timer 0.1, 0, $cv; 63 $wt = AE::timer 1, 0, $cv;
59 64
60 $s = 0; 65 $s = 0;
61 $cv->begin; 66 $cv->begin;
62 $cv->begin; 67 $cv->begin;
63 $cv->recv; 68 $cv->recv;
65 print $s == 3 ? "" : "not ", "ok 4 # $s\n"; 70 print $s == 3 ? "" : "not ", "ok 4 # $s\n";
66 71
67 sysread $a, my $dummy, 1; 72 sysread $a, my $dummy, 1;
68 73
69 $cv = AE::cv; 74 $cv = AE::cv;
70 $wt = AE::timer 0.1, 0, $cv; 75 $wt = AE::timer 0.01, 0, $cv;
71 76
72 $s = 0; 77 $s = 0;
73 $cv->recv; 78 $cv->recv;
74 79
75 print $s == 0 ? "" : "not ", "ok 5 # $s\n"; 80 print $s == 0 ? "" : "not ", "ok 5 # $s\n";
76} 81}
77 82
78# signal 83# signal
79{ 84{
80 my $cv = AE::cv; 85 my $cv = AE::cv;
81 my $wt = AE::timer 0.1, 0, $cv; 86 my $wt = AE::timer 0.01, 0, $cv;
82 my $s = 0; 87 my $s = 0;
83 88
84 $cv->begin; my $wa = AE::signal INT => sub { $cv->end; $s |= 1 }; 89 $cv->begin; my $wa = AE::signal INT => sub { $cv->end; $s |= 1 };
85 $cv->begin; my $wb = AE::signal INT => sub { $cv->end; $s |= 2 }; 90 $cv->begin; my $wb = AE::signal INT => sub { $cv->end; $s |= 2 };
86 91
89 print $s == 0 ? "" : "not ", "ok 6 # $s\n"; 94 print $s == 0 ? "" : "not ", "ok 6 # $s\n";
90 95
91 kill INT => $$; 96 kill INT => $$;
92 97
93 $cv = AE::cv; 98 $cv = AE::cv;
94 $wt = AE::timer 0.1, 0, $cv; 99 $wt = AE::timer 0.1, 0, $cv; # maybe OS X needs more time here?
95 100
96 $s = 0; 101 $s = 0;
97 $cv->recv; 102 $cv->recv;
98 103
99 print $s == 3 ? "" : "not ", "ok 7 # $s\n"; 104 print $s == 3 ? "" : "not ", "ok 7 # $s\n";
100 105
101 $cv = AE::cv; 106 $cv = AE::cv;
102 $wt = AE::timer 0.1, 0, $cv; 107 $wt = AE::timer 0.01, 0, $cv;
103 108
104 $s = 0; 109 $s = 0;
105 $cv->recv; 110 $cv->recv;
106 111
107 print $s == 0 ? "" : "not ", "ok 8 # $s\n"; 112 print $s == 0 ? "" : "not ", "ok 8 # $s\n";
110$AnyEvent::MAX_SIGNAL_LATENCY = 0.2; 115$AnyEvent::MAX_SIGNAL_LATENCY = 0.2;
111 116
112# child 117# child
113{ 118{
114 my $cv = AE::cv; 119 my $cv = AE::cv;
115 my $wt = AE::timer 0.1, 0, $cv; 120 my $wt = AE::timer 0.01, 0, $cv;
116 my $s = 0; 121 my $s = 0;
117 122
118 my $pid = fork; 123 my $pid = fork;
119 124
120 unless ($pid) { 125 unless ($pid) {
132 print $s == 0 ? "" : "not ", "ok 9 # $s\n"; 137 print $s == 0 ? "" : "not ", "ok 9 # $s\n";
133 138
134 kill 9, $pid; 139 kill 9, $pid;
135 140
136 $cv = AE::cv; 141 $cv = AE::cv;
137 $wt = AE::timer 0.1, 0, $cv; 142 $wt = AE::timer 0.2, 0, $cv; # cygwin needs ages for this
138 143
139 $s = 0; 144 $s = 0;
140 $cv->recv; 145 $cv->recv;
141 146
142 print $s == 3 ? "" : "not ", "ok 10 # $s\n"; 147 print $s == 3 ? "" : "not ", "ok 10 # $s\n";
143 print $apid == $pid && $bpid == $pid ? "" : "not ", "ok 11 # $apid == $bpid == $pid\n"; 148 print $apid == $pid && $bpid == $pid ? "" : "not ", "ok 11 # $apid == $bpid == $pid\n";
144 print $astatus == 9 && $bstatus == 9 ? "" : "not ", "ok 12 # $astatus == $bstatus == 9\n"; 149 print $astatus == 9 && $bstatus == 9 ? "" : "not ", "ok 12 # $astatus == $bstatus == 9\n";
145 150
146 $cv = AE::cv; 151 $cv = AE::cv;
147 $wt = AE::timer 0.1, 0, $cv; 152 $wt = AE::timer 0.01, 0, $cv;
148 153
149 $s = 0; 154 $s = 0;
150 $cv->recv; 155 $cv->recv;
151 156
152 print $s == 0 ? "" : "not ", "ok 13 # $s\n"; 157 print $s == 0 ? "" : "not ", "ok 13 # $s\n";
153} 158}
154 159
160# timers (don't laugh, some event loops are more broken...)
161{
162 my $cv = AE::cv;
163 my $wt = AE::timer 1, 0, $cv;
164 my $s = 0;
165
166 $cv->begin; my $wa = AE::timer 0 , 0, sub { $cv->end; $s |= 1 };
167 $cv->begin; my $wb = AE::timer 0 , 0, sub { $cv->end; $s |= 2 };
168 $cv->begin; my $wc = AE::timer 0.01, 0, sub { $cv->end; $s |= 4 };
169
170 $cv->recv;
171
172 print $s == 7 ? "" : "not ", "ok 14 # $s\n";
173}
174
155print "ok 14\n"; 175print "ok 15\n";
156 176
157exit 0; 177exit 0;
158 178

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines