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

Comparing AnyEvent/t/69_ev_09_multi.t (file contents):
Revision 1.1 by root, Tue Aug 2 22:07:18 2011 UTC vs.
Revision 1.10 by root, Tue Jul 30 23:14:34 2013 UTC

1BEGIN {
2 # check for broken perls
3 if ($^O =~ /mswin32/i) {
4 my $ok;
5 local $SIG{CHLD} = sub { $ok = 1 };
6 kill 'CHLD', 0;
7
8 unless ($ok) {
9 print <<EOF;
101..0 # SKIP Your perl interpreter is badly BROKEN. Child watchers will not work, ever. Try upgrading to a newer perl or a working perl (cygwin's perl is known to work). If that is not an option, you should be able to use the remaining functionality of AnyEvent, but child watchers WILL NOT WORK.
11EOF
12 exit 0;
13 }
14 }
15}
16
17$^W = 0; # 5.8.6 bugs
18
1use AnyEvent; 19use AnyEvent;
2use AnyEvent::Util; 20use AnyEvent::Util;
3BEGIN { eval q{use AnyEvent::Impl::EV;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::EV not loadable
4}), exit 0) }
5 21
22 BEGIN { $^W = 0 }
23 BEGIN { $ENV{PERL_ANYEVENT_LOOP_TESTS} or ((print qq{1..0 # SKIP PERL_ANYEVENT_LOOP_TESTS not true\n}), exit 0) }
24 BEGIN { eval q{use AnyEvent::Impl::EV;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::EV not loadable\n}), exit 0) }
25
26
27
6$| = 1; print "1..14\n"; 28$| = 1; print "1..15\n";
7 29
8print "ok 1\n"; 30print "ok 1\n";
31
32$AnyEvent::MAX_SIGNAL_LATENCY = 0.05;
9 33
10my ($a, $b) = AnyEvent::Util::portable_socketpair; 34my ($a, $b) = AnyEvent::Util::portable_socketpair;
11 35
12# I/O write 36# I/O write
13{ 37{
14 my $cv = AE::cv; 38 my $cv = AE::cv;
15 my $wt = AE::timer 0.1, 0, $cv; 39 my $wt = AE::timer 1, 0, $cv;
16 my $s = 0; 40 my $s = 0;
17 41
18 $cv->begin; my $wa = AE::io $a, 1, sub { $cv->end; $s |= 1 }; 42 $cv->begin; my $wa = AE::io $a, 1, sub { $cv->end; $s |= 1 };
19 $cv->begin; my $wb = AE::io $a, 1, sub { $cv->end; $s |= 2 }; 43 $cv->begin; my $wb = AE::io $a, 1, sub { $cv->end; $s |= 2 };
20 44
24} 48}
25 49
26# I/O read 50# I/O read
27{ 51{
28 my $cv = AE::cv; 52 my $cv = AE::cv;
29 my $wt = AE::timer 0.1, 0, $cv; 53 my $wt = AE::timer 0.01, 0, $cv;
30 my $s = 0; 54 my $s = 0;
31 55
32 my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 }; 56 my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 };
33 my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 }; 57 my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 };
34 58
37 print $s == 0 ? "" : "not ", "ok 3 # $s\n"; 61 print $s == 0 ? "" : "not ", "ok 3 # $s\n";
38 62
39 syswrite $b, "x"; 63 syswrite $b, "x";
40 64
41 $cv = AE::cv; 65 $cv = AE::cv;
42 $wt = AE::timer 0.1, 0, $cv; 66 $wt = AE::timer 1, 0, $cv;
43 67
44 $s = 0; 68 $s = 0;
45 $cv->begin; 69 $cv->begin;
46 $cv->begin; 70 $cv->begin;
47 $cv->recv; 71 $cv->recv;
49 print $s == 3 ? "" : "not ", "ok 4 # $s\n"; 73 print $s == 3 ? "" : "not ", "ok 4 # $s\n";
50 74
51 sysread $a, my $dummy, 1; 75 sysread $a, my $dummy, 1;
52 76
53 $cv = AE::cv; 77 $cv = AE::cv;
54 $wt = AE::timer 0.1, 0, $cv; 78 $wt = AE::timer 0.01, 0, $cv;
55 79
56 $s = 0; 80 $s = 0;
57 $cv->recv; 81 $cv->recv;
58 82
59 print $s == 0 ? "" : "not ", "ok 5 # $s\n"; 83 print $s == 0 ? "" : "not ", "ok 5 # $s\n";
60} 84}
61 85
62# signal 86# signal
63{ 87{
64 my $cv = AE::cv; 88 my $cv = AE::cv;
65 my $wt = AE::timer 0.1, 0, $cv; 89 my $wt = AE::timer 0.01, 0, $cv;
66 my $s = 0; 90 my $s = 0;
67 91
68 $cv->begin; my $wa = AE::signal INT => sub { $cv->end; $s |= 1 }; 92 $cv->begin; my $wa = AE::signal INT => sub { $cv->end; $s |= 1 };
69 $cv->begin; my $wb = AE::signal INT => sub { $cv->end; $s |= 2 }; 93 $cv->begin; my $wb = AE::signal INT => sub { $cv->end; $s |= 2 };
70 94
73 print $s == 0 ? "" : "not ", "ok 6 # $s\n"; 97 print $s == 0 ? "" : "not ", "ok 6 # $s\n";
74 98
75 kill INT => $$; 99 kill INT => $$;
76 100
77 $cv = AE::cv; 101 $cv = AE::cv;
78 $wt = AE::timer 0.1, 0, $cv; 102 $wt = AE::timer 0.2, 0, $cv; # maybe OS X needs more time here? or maybe some buggy arm kernel?
79 103
80 $s = 0; 104 $s = 0;
81 $cv->recv; 105 $cv->recv;
82 106
83 print $s == 3 ? "" : "not ", "ok 7 # $s\n"; 107 print $s == 3 ? "" : "not ", "ok 7 # $s\n";
84 108
85 $cv = AE::cv; 109 $cv = AE::cv;
86 $wt = AE::timer 0.1, 0, $cv; 110 $wt = AE::timer 0.01, 0, $cv;
87 111
88 $s = 0; 112 $s = 0;
89 $cv->recv; 113 $cv->recv;
90 114
91 print $s == 0 ? "" : "not ", "ok 8 # $s\n"; 115 print $s == 0 ? "" : "not ", "ok 8 # $s\n";
92} 116}
93 117
94$AnyEvent::MAX_SIGNAL_LATENCY = 0.2;
95
96# child 118# child
97{ 119{
98 my $cv = AE::cv; 120 my $cv = AE::cv;
99 my $wt = AE::timer 0.1, 0, $cv; 121 my $wt = AE::timer 0.01, 0, $cv;
100 my $s = 0; 122 my $s = 0;
101 123
102 my $pid = fork; 124 my $pid = fork;
103 125
104 unless ($pid) { 126 unless ($pid) {
116 print $s == 0 ? "" : "not ", "ok 9 # $s\n"; 138 print $s == 0 ? "" : "not ", "ok 9 # $s\n";
117 139
118 kill 9, $pid; 140 kill 9, $pid;
119 141
120 $cv = AE::cv; 142 $cv = AE::cv;
121 $wt = AE::timer 0.1, 0, $cv; 143 $wt = AE::timer 0.2, 0, $cv; # cygwin needs ages for this
122 144
123 $s = 0; 145 $s = 0;
124 $cv->recv; 146 $cv->recv;
125 147
126 print $s == 3 ? "" : "not ", "ok 10 # $s\n"; 148 print $s == 3 ? "" : "not ", "ok 10 # $s\n";
127 print $apid == $pid && $bpid == $pid ? "" : "not ", "ok 11 # $apid == $bpid == $pid\n"; 149 print $apid == $pid && $bpid == $pid ? "" : "not ", "ok 11 # $apid == $bpid == $pid\n";
128 print $astatus == 9 && $bstatus == 9 ? "" : "not ", "ok 12 # $astatus == $bstatus == 9\n"; 150 print $astatus == 9 && $bstatus == 9 ? "" : "not ", "ok 12 # $astatus == $bstatus == 9\n";
129 151
130 $cv = AE::cv; 152 $cv = AE::cv;
131 $wt = AE::timer 0.1, 0, $cv; 153 $wt = AE::timer 0.01, 0, $cv;
132 154
133 $s = 0; 155 $s = 0;
134 $cv->recv; 156 $cv->recv;
135 157
136 print $s == 0 ? "" : "not ", "ok 13 # $s\n"; 158 print $s == 0 ? "" : "not ", "ok 13 # $s\n";
137} 159}
138 160
161# timers (don't laugh, some event loops are more broken...)
162{
163 my $cv = AE::cv;
164 my $wt = AE::timer 1, 0, $cv;
165 my $s = 0;
166
167 $cv->begin; my $wa = AE::timer 0 , 0, sub { $cv->end; $s |= 1 };
168 $cv->begin; my $wb = AE::timer 0 , 0, sub { $cv->end; $s |= 2 };
169 $cv->begin; my $wc = AE::timer 0.01, 0, sub { $cv->end; $s |= 4 };
170
171 $cv->recv;
172
173 print $s == 7 ? "" : "not ", "ok 14 # $s\n";
174}
175
139print "ok 14\n"; 176print "ok 15\n";
140 177
141exit 0; 178exit 0;
142 179

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines