File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,47 @@ mod test {
141
141
sleep ( 1 u) ;
142
142
}
143
143
144
+ #[ test]
145
+ fn test_gl_timer_sleep_stress1 ( ) {
146
+ iter:: repeat ( 500 u) { ||
147
+ sleep ( 1 u) ;
148
+ }
149
+ }
150
+
151
+ #[ test]
152
+ fn test_gl_timer_sleep_stress2 ( ) {
153
+ let po = comm:: port ( ) ;
154
+ let ch = comm:: chan ( po) ;
155
+
156
+ let repeat = 100 u;
157
+ let spec = {
158
+
159
+ [ ( 1 u, 100 u) ,
160
+ ( 10 u, 10 u) ,
161
+ ( 100 u, 2 u) ]
162
+
163
+ } ;
164
+
165
+ iter:: repeat ( repeat) { ||
166
+
167
+ for spec. each { |spec|
168
+ let ( times, maxms) = spec;
169
+ task:: spawn { ||
170
+ import rand:: * ;
171
+ let rng = rng ( ) ;
172
+ iter:: repeat ( times) { ||
173
+ sleep ( rng. next ( ) as uint % maxms) ;
174
+ }
175
+ comm:: send ( ch, ( ) ) ;
176
+ }
177
+ }
178
+ }
179
+
180
+ iter:: repeat ( repeat * spec. len ( ) ) { ||
181
+ comm:: recv ( po)
182
+ }
183
+ }
184
+
144
185
#[ test]
145
186
fn test_gl_timer_recv_timeout_before_time_passes ( ) {
146
187
let expected = rand:: rng ( ) . gen_str ( 16 u) ;
You can’t perform that action at this time.
0 commit comments