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

Comparing AnyEvent/t/68_poe_09_multi.t (file contents):
Revision 1.2 by root, Thu Aug 4 09:14:03 2011 UTC vs.
Revision 1.8 by root, Sat Oct 1 22:39:30 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::POE;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::POE not loadable
20}), exit 0) } $^W = 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::POE;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::POE not loadable\n}), exit 0) }
24 $^W = 0;
25
26
22$| = 1; print "1..14\n"; 27$| = 1; print "1..15\n";
23 28
24print "ok 1\n"; 29print "ok 1\n";
30
31$AnyEvent::MAX_SIGNAL_LATENCY = 0.05;
25 32
26my ($a, $b) = AnyEvent::Util::portable_socketpair; 33my ($a, $b) = AnyEvent::Util::portable_socketpair;
27 34
28# I/O write 35# I/O write
29{ 36{
30 my $cv = AE::cv; 37 my $cv = AE::cv;
31 my $wt = AE::timer 0.1, 0, $cv; 38 my $wt = AE::timer 1, 0, $cv;
32 my $s = 0; 39 my $s = 0;
33 40
34 $cv->begin; my $wa = AE::io $a, 1, sub { $cv->end; $s |= 1 }; 41 $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 }; 42 $cv->begin; my $wb = AE::io $a, 1, sub { $cv->end; $s |= 2 };
36 43
40} 47}
41 48
42# I/O read 49# I/O read
43{ 50{
44 my $cv = AE::cv; 51 my $cv = AE::cv;
45 my $wt = AE::timer 0.1, 0, $cv; 52 my $wt = AE::timer 0.01, 0, $cv;
46 my $s = 0; 53 my $s = 0;
47 54
48 my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 }; 55 my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 };
49 my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 }; 56 my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 };
50 57
53 print $s == 0 ? "" : "not ", "ok 3 # $s\n"; 60 print $s == 0 ? "" : "not ", "ok 3 # $s\n";
54 61
55 syswrite $b, "x"; 62 syswrite $b, "x";
56 63
57 $cv = AE::cv; 64 $cv = AE::cv;
58 $wt = AE::timer 0.1, 0, $cv; 65 $wt = AE::timer 1, 0, $cv;
59 66
60 $s = 0; 67 $s = 0;
61 $cv->begin; 68 $cv->begin;
62 $cv->begin; 69 $cv->begin;
63 $cv->recv; 70 $cv->recv;
65 print $s == 3 ? "" : "not ", "ok 4 # $s\n"; 72 print $s == 3 ? "" : "not ", "ok 4 # $s\n";
66 73
67 sysread $a, my $dummy, 1; 74 sysread $a, my $dummy, 1;
68 75
69 $cv = AE::cv; 76 $cv = AE::cv;
70 $wt = AE::timer 0.1, 0, $cv; 77 $wt = AE::timer 0.01, 0, $cv;
71 78
72 $s = 0; 79 $s = 0;
73 $cv->recv; 80 $cv->recv;
74 81
75 print $s == 0 ? "" : "not ", "ok 5 # $s\n"; 82 print $s == 0 ? "" : "not ", "ok 5 # $s\n";
76} 83}
77 84
78# signal 85# signal
79{ 86{
80 my $cv = AE::cv; 87 my $cv = AE::cv;
81 my $wt = AE::timer 0.1, 0, $cv; 88 my $wt = AE::timer 0.01, 0, $cv;
82 my $s = 0; 89 my $s = 0;
83 90
84 $cv->begin; my $wa = AE::signal INT => sub { $cv->end; $s |= 1 }; 91 $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 }; 92 $cv->begin; my $wb = AE::signal INT => sub { $cv->end; $s |= 2 };
86 93
89 print $s == 0 ? "" : "not ", "ok 6 # $s\n"; 96 print $s == 0 ? "" : "not ", "ok 6 # $s\n";
90 97
91 kill INT => $$; 98 kill INT => $$;
92 99
93 $cv = AE::cv; 100 $cv = AE::cv;
94 $wt = AE::timer 0.1, 0, $cv; 101 $wt = AE::timer 0.2, 0, $cv; # maybe OS X needs more time here?
95 102
96 $s = 0; 103 $s = 0;
97 $cv->recv; 104 $cv->recv;
98 105
99 print $s == 3 ? "" : "not ", "ok 7 # $s\n"; 106 print $s == 3 ? "" : "not ", "ok 7 # $s\n";
100 107
101 $cv = AE::cv; 108 $cv = AE::cv;
102 $wt = AE::timer 0.1, 0, $cv; 109 $wt = AE::timer 0.01, 0, $cv;
103 110
104 $s = 0; 111 $s = 0;
105 $cv->recv; 112 $cv->recv;
106 113
107 print $s == 0 ? "" : "not ", "ok 8 # $s\n"; 114 print $s == 0 ? "" : "not ", "ok 8 # $s\n";
108} 115}
109 116
110$AnyEvent::MAX_SIGNAL_LATENCY = 0.2;
111
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