@@ -15,7 +15,6 @@ use std::thread;
1515
1616#[ cfg( not( any( feature = "force-inprocess" , target_os = "windows" , target_os = "android" ) ) ) ]
1717use libc;
18- #[ cfg( not( any( feature = "force-inprocess" , target_os = "windows" , target_os = "android" ) ) ) ]
1918use platform:: { OsIpcSender , OsIpcOneShotServer } ;
2019#[ cfg( not( any( feature = "force-inprocess" , target_os = "windows" , target_os = "android" ) ) ) ]
2120use test:: { fork, Wait } ;
@@ -396,10 +395,27 @@ fn receiver_set() {
396395 }
397396}
398397
399- #[ cfg( not( any( feature = "force-inprocess" , target_os = "windows" , target_os = "android" ) ) ) ]
398+ #[ cfg( not( any( feature = "force-inprocess" , target_os = "android" ) ) ) ]
399+ #[ test]
400+ fn server_accept_first ( ) {
401+ let ( server, name) = OsIpcOneShotServer :: new ( ) . unwrap ( ) ;
402+ let data: & [ u8 ] = b"1234567" ;
403+
404+ thread:: spawn ( move || {
405+ thread:: sleep ( Duration :: from_millis ( 30 ) ) ;
406+ let tx = OsIpcSender :: connect ( name) . unwrap ( ) ;
407+ tx. send ( data, vec ! [ ] , vec ! [ ] ) . unwrap ( ) ;
408+ } ) ;
409+
410+ let ( _, mut received_data, received_channels, received_shared_memory_regions) =
411+ server. accept ( ) . unwrap ( ) ;
412+ received_data. truncate ( 7 ) ;
413+ assert_eq ! ( ( & received_data[ ..] , received_channels, received_shared_memory_regions) ,
414+ ( data, vec![ ] , vec![ ] ) ) ;
415+ }
416+
400417#[ test]
401- //XXXjdm This hangs indefinitely with inprocess impl and warrants further investigation.
402- fn server ( ) {
418+ fn server_connect_first ( ) {
403419 let ( server, name) = OsIpcOneShotServer :: new ( ) . unwrap ( ) ;
404420 let data: & [ u8 ] = b"1234567" ;
405421
@@ -408,6 +424,7 @@ fn server() {
408424 tx. send ( data, vec ! [ ] , vec ! [ ] ) . unwrap ( ) ;
409425 } ) ;
410426
427+ thread:: sleep ( Duration :: from_millis ( 30 ) ) ;
411428 let ( _, mut received_data, received_channels, received_shared_memory_regions) =
412429 server. accept ( ) . unwrap ( ) ;
413430 received_data. truncate ( 7 ) ;
0 commit comments