@@ -264,6 +264,7 @@ mod channel_tests {
264264 assert ! ( tx2. send( 1 ) . is_err( ) ) ;
265265 }
266266
267+ #[ cfg_attr( miri, ignore) ] // Miri is too slow
267268 #[ test]
268269 fn port_gone_concurrent ( ) {
269270 let ( tx, rx) = channel :: < i32 > ( ) ;
@@ -274,6 +275,7 @@ mod channel_tests {
274275 t. join ( ) . unwrap ( ) ;
275276 }
276277
278+ #[ cfg_attr( miri, ignore) ] // Miri is too slow
277279 #[ test]
278280 fn port_gone_concurrent_shared ( ) {
279281 let ( tx, rx) = channel :: < i32 > ( ) ;
@@ -314,20 +316,28 @@ mod channel_tests {
314316
315317 #[ test]
316318 fn stress ( ) {
319+ #[ cfg( miri) ]
320+ const COUNT : usize = 500 ;
321+ #[ cfg( not( miri) ) ]
322+ const COUNT : usize = 10000 ;
323+
317324 let ( tx, rx) = channel :: < i32 > ( ) ;
318325 let t = thread:: spawn ( move || {
319- for _ in 0 ..10000 {
326+ for _ in 0 ..COUNT {
320327 tx. send ( 1 ) . unwrap ( ) ;
321328 }
322329 } ) ;
323- for _ in 0 ..10000 {
330+ for _ in 0 ..COUNT {
324331 assert_eq ! ( rx. recv( ) . unwrap( ) , 1 ) ;
325332 }
326333 t. join ( ) . ok ( ) . unwrap ( ) ;
327334 }
328335
329336 #[ test]
330337 fn stress_shared ( ) {
338+ #[ cfg( miri) ]
339+ const AMT : u32 = 500 ;
340+ #[ cfg( not( miri) ) ]
331341 const AMT : u32 = 10000 ;
332342 const NTHREADS : u32 = 8 ;
333343 let ( tx, rx) = channel :: < i32 > ( ) ;
@@ -735,12 +745,17 @@ mod channel_tests {
735745
736746 #[ test]
737747 fn recv_a_lot ( ) {
748+ #[ cfg( miri) ]
749+ const N : usize = 100 ;
750+ #[ cfg( not( miri) ) ]
751+ const N : usize = 10000 ;
752+
738753 // Regression test that we don't run out of stack in scheduler context
739754 let ( tx, rx) = channel ( ) ;
740- for _ in 0 ..10000 {
755+ for _ in 0 ..N {
741756 tx. send ( ( ) ) . unwrap ( ) ;
742757 }
743- for _ in 0 ..10000 {
758+ for _ in 0 ..N {
744759 rx. recv ( ) . unwrap ( ) ;
745760 }
746761 }
@@ -841,6 +856,7 @@ mod channel_tests {
841856 t. join ( ) . unwrap ( ) ;
842857 }
843858
859+ #[ cfg_attr( miri, ignore) ] // Miri is too slow
844860 #[ test]
845861 fn test_recv_try_iter ( ) {
846862 let ( request_tx, request_rx) = channel ( ) ;
@@ -955,6 +971,7 @@ mod channel_tests {
955971}
956972
957973// Source: https://github.com/rust-lang/rust/blob/master/src/libstd/sync/mpsc/mod.rs
974+ #[ cfg( not( miri) ) ] // Miri failed due to https://github.com/rust-lang/miri/issues/1371
958975mod sync_channel_tests {
959976 use super :: * ;
960977
@@ -1079,24 +1096,34 @@ mod sync_channel_tests {
10791096
10801097 #[ test]
10811098 fn stress ( ) {
1099+ #[ cfg( miri) ]
1100+ const N : usize = 100 ;
1101+ #[ cfg( not( miri) ) ]
1102+ const N : usize = 10000 ;
1103+
10821104 let ( tx, rx) = sync_channel :: < i32 > ( 0 ) ;
10831105 let t = thread:: spawn ( move || {
1084- for _ in 0 ..10000 {
1106+ for _ in 0 ..N {
10851107 tx. send ( 1 ) . unwrap ( ) ;
10861108 }
10871109 } ) ;
1088- for _ in 0 ..10000 {
1110+ for _ in 0 ..N {
10891111 assert_eq ! ( rx. recv( ) . unwrap( ) , 1 ) ;
10901112 }
10911113 t. join ( ) . unwrap ( ) ;
10921114 }
10931115
10941116 #[ test]
10951117 fn stress_recv_timeout_two_threads ( ) {
1118+ #[ cfg( miri) ]
1119+ const N : usize = 100 ;
1120+ #[ cfg( not( miri) ) ]
1121+ const N : usize = 10000 ;
1122+
10961123 let ( tx, rx) = sync_channel :: < i32 > ( 0 ) ;
10971124
10981125 let t = thread:: spawn ( move || {
1099- for _ in 0 ..10000 {
1126+ for _ in 0 ..N {
11001127 tx. send ( 1 ) . unwrap ( ) ;
11011128 }
11021129 } ) ;
@@ -1113,7 +1140,7 @@ mod sync_channel_tests {
11131140 }
11141141 }
11151142
1116- assert_eq ! ( recv_count, 10000 ) ;
1143+ assert_eq ! ( recv_count, N ) ;
11171144 t. join ( ) . unwrap ( ) ;
11181145 }
11191146
@@ -1449,12 +1476,17 @@ mod sync_channel_tests {
14491476
14501477 #[ test]
14511478 fn recv_a_lot ( ) {
1479+ #[ cfg( miri) ]
1480+ const N : usize = 100 ;
1481+ #[ cfg( not( miri) ) ]
1482+ const N : usize = 10000 ;
1483+
14521484 // Regression test that we don't run out of stack in scheduler context
1453- let ( tx, rx) = sync_channel ( 10000 ) ;
1454- for _ in 0 ..10000 {
1485+ let ( tx, rx) = sync_channel ( N ) ;
1486+ for _ in 0 ..N {
14551487 tx. send ( ( ) ) . unwrap ( ) ;
14561488 }
1457- for _ in 0 ..10000 {
1489+ for _ in 0 ..N {
14581490 rx. recv ( ) . unwrap ( ) ;
14591491 }
14601492 }
@@ -1792,7 +1824,11 @@ mod select_tests {
17921824
17931825 #[ test]
17941826 fn stress ( ) {
1827+ #[ cfg( miri) ]
1828+ const AMT : i32 = 100 ;
1829+ #[ cfg( not( miri) ) ]
17951830 const AMT : i32 = 10000 ;
1831+
17961832 let ( tx1, rx1) = channel :: < i32 > ( ) ;
17971833 let ( tx2, rx2) = channel :: < i32 > ( ) ;
17981834 let ( tx3, rx3) = channel :: < ( ) > ( ) ;
0 commit comments