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.3 by root, Fri Aug 12 00:53:29 2011 UTC vs.
Revision 1.10 by root, Tue Jul 30 23:14:34 2013 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;
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) }
19BEGIN { eval q{use AnyEvent::Impl::EV;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::EV not loadable 24 BEGIN { eval q{use AnyEvent::Impl::EV;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::EV not loadable\n}), exit 0) }
20}), exit 0) } 25
26
21 27
22$| = 1; print "1..15\n"; 28$| = 1; print "1..15\n";
23 29
24print "ok 1\n"; 30print "ok 1\n";
31
32$AnyEvent::MAX_SIGNAL_LATENCY = 0.05;
25 33
26my ($a, $b) = AnyEvent::Util::portable_socketpair; 34my ($a, $b) = AnyEvent::Util::portable_socketpair;
27 35
28# I/O write 36# I/O write
29{ 37{
40} 48}
41 49
42# I/O read 50# I/O read
43{ 51{
44 my $cv = AE::cv; 52 my $cv = AE::cv;
45 my $wt = AE::timer 0.1, 0, $cv; 53 my $wt = AE::timer 0.01, 0, $cv;
46 my $s = 0; 54 my $s = 0;
47 55
48 my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 }; 56 my $wa = AE::io $a, 0, sub { $cv->end; $s |= 1 };
49 my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 }; 57 my $wb = AE::io $a, 0, sub { $cv->end; $s |= 2 };
50 58
65 print $s == 3 ? "" : "not ", "ok 4 # $s\n"; 73 print $s == 3 ? "" : "not ", "ok 4 # $s\n";
66 74
67 sysread $a, my $dummy, 1; 75 sysread $a, my $dummy, 1;
68 76
69 $cv = AE::cv; 77 $cv = AE::cv;
70 $wt = AE::timer 0.1, 0, $cv; 78 $wt = AE::timer 0.01, 0, $cv;
71 79
72 $s = 0; 80 $s = 0;
73 $cv->recv; 81 $cv->recv;
74 82
75 print $s == 0 ? "" : "not ", "ok 5 # $s\n"; 83 print $s == 0 ? "" : "not ", "ok 5 # $s\n";
76} 84}
77 85
78# signal 86# signal
79{ 87{
80 my $cv = AE::cv; 88 my $cv = AE::cv;
81 my $wt = AE::timer 0.1, 0, $cv; 89 my $wt = AE::timer 0.01, 0, $cv;
82 my $s = 0; 90 my $s = 0;
83 91
84 $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 };
85 $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 };
86 94
89 print $s == 0 ? "" : "not ", "ok 6 # $s\n"; 97 print $s == 0 ? "" : "not ", "ok 6 # $s\n";
90 98
91 kill INT => $$; 99 kill INT => $$;
92 100
93 $cv = AE::cv; 101 $cv = AE::cv;
94 $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?
95 103
96 $s = 0; 104 $s = 0;
97 $cv->recv; 105 $cv->recv;
98 106
99 print $s == 3 ? "" : "not ", "ok 7 # $s\n"; 107 print $s == 3 ? "" : "not ", "ok 7 # $s\n";
100 108
101 $cv = AE::cv; 109 $cv = AE::cv;
102 $wt = AE::timer 0.1, 0, $cv; 110 $wt = AE::timer 0.01, 0, $cv;
103 111
104 $s = 0; 112 $s = 0;
105 $cv->recv; 113 $cv->recv;
106 114
107 print $s == 0 ? "" : "not ", "ok 8 # $s\n"; 115 print $s == 0 ? "" : "not ", "ok 8 # $s\n";
108} 116}
109 117
110$AnyEvent::MAX_SIGNAL_LATENCY = 0.2;
111
112# child 118# child
113{ 119{
114 my $cv = AE::cv; 120 my $cv = AE::cv;
115 my $wt = AE::timer 0.1, 0, $cv; 121 my $wt = AE::timer 0.01, 0, $cv;
116 my $s = 0; 122 my $s = 0;
117 123
118 my $pid = fork; 124 my $pid = fork;
119 125
120 unless ($pid) { 126 unless ($pid) {
132 print $s == 0 ? "" : "not ", "ok 9 # $s\n"; 138 print $s == 0 ? "" : "not ", "ok 9 # $s\n";
133 139
134 kill 9, $pid; 140 kill 9, $pid;
135 141
136 $cv = AE::cv; 142 $cv = AE::cv;
137 $wt = AE::timer 0.1, 0, $cv; 143 $wt = AE::timer 0.2, 0, $cv; # cygwin needs ages for this
138 144
139 $s = 0; 145 $s = 0;
140 $cv->recv; 146 $cv->recv;
141 147
142 print $s == 3 ? "" : "not ", "ok 10 # $s\n"; 148 print $s == 3 ? "" : "not ", "ok 10 # $s\n";
143 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";
144 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";
145 151
146 $cv = AE::cv; 152 $cv = AE::cv;
147 $wt = AE::timer 0.1, 0, $cv; 153 $wt = AE::timer 0.01, 0, $cv;
148 154
149 $s = 0; 155 $s = 0;
150 $cv->recv; 156 $cv->recv;
151 157
152 print $s == 0 ? "" : "not ", "ok 13 # $s\n"; 158 print $s == 0 ? "" : "not ", "ok 13 # $s\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines