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.4 by root, Fri Aug 12 18:41:30 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines