@@ -257,6 +257,8 @@ mod tests {
257257 use super :: * ;
258258 use io:: * ;
259259 use io:: test:: * ;
260+ use io:: fs:: PathExtensions ;
261+ use time:: Duration ;
260262
261263 pub fn smalltest ( server : proc ( UnixStream ) : Send , client : proc ( UnixStream ) : Send ) {
262264 let path1 = next_test_unix ( ) ;
@@ -277,7 +279,8 @@ mod tests {
277279 }
278280 }
279281
280- iotest ! ( fn bind_error( ) {
282+ #[ test]
283+ fn bind_error ( ) {
281284 let path = "path/to/nowhere" ;
282285 match UnixListener :: bind ( & path) {
283286 Ok ( ..) => fail ! ( ) ,
@@ -286,9 +289,10 @@ mod tests {
286289 e. kind == InvalidInput ) ;
287290 }
288291 }
289- } )
292+ }
290293
291- iotest ! ( fn connect_error( ) {
294+ #[ test]
295+ fn connect_error ( ) {
292296 let path = if cfg ! ( windows) {
293297 r"\\.\pipe\this_should_not_exist_ever"
294298 } else {
@@ -300,29 +304,33 @@ mod tests {
300304 assert ! ( e. kind == FileNotFound || e. kind == OtherIoError ) ;
301305 }
302306 }
303- } )
307+ }
304308
305- iotest ! ( fn smoke( ) {
309+ #[ test]
310+ fn smoke ( ) {
306311 smalltest ( proc ( mut server) {
307312 let mut buf = [ 0 ] ;
308313 server. read ( buf) . unwrap ( ) ;
309314 assert ! ( buf[ 0 ] == 99 ) ;
310315 } , proc ( mut client) {
311316 client. write ( [ 99 ] ) . unwrap ( ) ;
312317 } )
313- } )
318+ }
314319
315- iotest ! ( fn read_eof( ) {
320+ #[ cfg_attr( windows, ignore) ] // FIXME(#12516)
321+ #[ test]
322+ fn read_eof ( ) {
316323 smalltest ( proc ( mut server) {
317324 let mut buf = [ 0 ] ;
318325 assert ! ( server. read( buf) . is_err( ) ) ;
319326 assert ! ( server. read( buf) . is_err( ) ) ;
320327 } , proc ( _client) {
321328 // drop the client
322329 } )
323- } # [ cfg_attr ( windows , ignore ) ] ) // FIXME(#12516)
330+ }
324331
325- iotest ! ( fn write_begone( ) {
332+ #[ test]
333+ fn write_begone ( ) {
326334 smalltest ( proc ( mut server) {
327335 let buf = [ 0 ] ;
328336 loop {
@@ -340,9 +348,10 @@ mod tests {
340348 } , proc ( _client) {
341349 // drop the client
342350 } )
343- } )
351+ }
344352
345- iotest ! ( fn accept_lots( ) {
353+ #[ test]
354+ fn accept_lots ( ) {
346355 let times = 10 ;
347356 let path1 = next_test_unix ( ) ;
348357 let path2 = path1. clone ( ) ;
@@ -371,16 +380,18 @@ mod tests {
371380 }
372381 assert_eq ! ( buf[ 0 ] , 100 ) ;
373382 }
374- } )
383+ }
375384
376385 #[ cfg( unix) ]
377- iotest ! ( fn path_exists( ) {
386+ #[ test]
387+ fn path_exists ( ) {
378388 let path = next_test_unix ( ) ;
379389 let _acceptor = UnixListener :: bind ( & path) . listen ( ) ;
380390 assert ! ( path. exists( ) ) ;
381- } )
391+ }
382392
383- iotest ! ( fn unix_clone_smoke( ) {
393+ #[ test]
394+ fn unix_clone_smoke ( ) {
384395 let addr = next_test_unix ( ) ;
385396 let mut acceptor = UnixListener :: bind ( & addr) . listen ( ) ;
386397
@@ -414,9 +425,10 @@ mod tests {
414425 assert_eq ! ( s1. read( buf) , Ok ( 1 ) ) ;
415426 debug ! ( "reader done" ) ;
416427 rx2. recv ( ) ;
417- } )
428+ }
418429
419- iotest ! ( fn unix_clone_two_read( ) {
430+ #[ test]
431+ fn unix_clone_two_read ( ) {
420432 let addr = next_test_unix ( ) ;
421433 let mut acceptor = UnixListener :: bind ( & addr) . listen ( ) ;
422434 let ( tx1, rx) = channel ( ) ;
@@ -446,9 +458,10 @@ mod tests {
446458 tx1. send ( ( ) ) ;
447459
448460 rx. recv ( ) ;
449- } )
461+ }
450462
451- iotest ! ( fn unix_clone_two_write( ) {
463+ #[ test]
464+ fn unix_clone_two_write ( ) {
452465 let addr = next_test_unix ( ) ;
453466 let mut acceptor = UnixListener :: bind ( & addr) . listen ( ) ;
454467
@@ -471,25 +484,30 @@ mod tests {
471484 s1. write ( [ 2 ] ) . unwrap ( ) ;
472485
473486 rx. recv ( ) ;
474- } )
487+ }
475488
476- iotest ! ( fn drop_removes_listener_path( ) {
489+ #[ cfg( not( windows) ) ]
490+ #[ test]
491+ fn drop_removes_listener_path ( ) {
477492 let path = next_test_unix ( ) ;
478493 let l = UnixListener :: bind ( & path) . unwrap ( ) ;
479494 assert ! ( path. exists( ) ) ;
480495 drop ( l) ;
481496 assert ! ( !path. exists( ) ) ;
482- } # [ cfg ( not ( windows ) ) ] )
497+ }
483498
484- iotest ! ( fn drop_removes_acceptor_path( ) {
499+ #[ cfg( not( windows) ) ]
500+ #[ test]
501+ fn drop_removes_acceptor_path ( ) {
485502 let path = next_test_unix ( ) ;
486503 let l = UnixListener :: bind ( & path) . unwrap ( ) ;
487504 assert ! ( path. exists( ) ) ;
488505 drop ( l. listen ( ) . unwrap ( ) ) ;
489506 assert ! ( !path. exists( ) ) ;
490- } # [ cfg ( not ( windows ) ) ] )
507+ }
491508
492- iotest ! ( fn accept_timeout( ) {
509+ #[ test]
510+ fn accept_timeout ( ) {
493511 let addr = next_test_unix ( ) ;
494512 let mut a = UnixListener :: bind ( & addr) . unwrap ( ) . listen ( ) . unwrap ( ) ;
495513
@@ -527,32 +545,37 @@ mod tests {
527545 drop ( UnixStream :: connect ( & addr2) . unwrap ( ) ) ;
528546 } ) ;
529547 a. accept ( ) . unwrap ( ) ;
530- } )
548+ }
531549
532- iotest ! ( fn connect_timeout_error( ) {
550+ #[ test]
551+ fn connect_timeout_error ( ) {
533552 let addr = next_test_unix ( ) ;
534553 assert ! ( UnixStream :: connect_timeout( & addr, Duration :: milliseconds( 100 ) ) . is_err( ) ) ;
535- } )
554+ }
536555
537- iotest ! ( fn connect_timeout_success( ) {
556+ #[ test]
557+ fn connect_timeout_success ( ) {
538558 let addr = next_test_unix ( ) ;
539559 let _a = UnixListener :: bind ( & addr) . unwrap ( ) . listen ( ) . unwrap ( ) ;
540560 assert ! ( UnixStream :: connect_timeout( & addr, Duration :: milliseconds( 100 ) ) . is_ok( ) ) ;
541- } )
561+ }
542562
543- iotest ! ( fn connect_timeout_zero( ) {
563+ #[ test]
564+ fn connect_timeout_zero ( ) {
544565 let addr = next_test_unix ( ) ;
545566 let _a = UnixListener :: bind ( & addr) . unwrap ( ) . listen ( ) . unwrap ( ) ;
546567 assert ! ( UnixStream :: connect_timeout( & addr, Duration :: milliseconds( 0 ) ) . is_err( ) ) ;
547- } )
568+ }
548569
549- iotest ! ( fn connect_timeout_negative( ) {
570+ #[ test]
571+ fn connect_timeout_negative ( ) {
550572 let addr = next_test_unix ( ) ;
551573 let _a = UnixListener :: bind ( & addr) . unwrap ( ) . listen ( ) . unwrap ( ) ;
552574 assert ! ( UnixStream :: connect_timeout( & addr, Duration :: milliseconds( -1 ) ) . is_err( ) ) ;
553- } )
575+ }
554576
555- iotest ! ( fn close_readwrite_smoke( ) {
577+ #[ test]
578+ fn close_readwrite_smoke ( ) {
556579 let addr = next_test_unix ( ) ;
557580 let a = UnixListener :: bind ( & addr) . listen ( ) . unwrap ( ) ;
558581 let ( _tx, rx) = channel :: < ( ) > ( ) ;
@@ -586,9 +609,10 @@ mod tests {
586609 let _ = s2. close_write ( ) ;
587610 let _ = s3. close_read ( ) ;
588611 let _ = s3. close_write ( ) ;
589- } )
612+ }
590613
591- iotest ! ( fn close_read_wakes_up( ) {
614+ #[ test]
615+ fn close_read_wakes_up ( ) {
592616 let addr = next_test_unix ( ) ;
593617 let a = UnixListener :: bind ( & addr) . listen ( ) . unwrap ( ) ;
594618 let ( _tx, rx) = channel :: < ( ) > ( ) ;
@@ -611,9 +635,10 @@ mod tests {
611635
612636 // this test will never finish if the child doesn't wake up
613637 rx. recv ( ) ;
614- } )
638+ }
615639
616- iotest ! ( fn readwrite_timeouts( ) {
640+ #[ test]
641+ fn readwrite_timeouts ( ) {
617642 let addr = next_test_unix ( ) ;
618643 let mut a = UnixListener :: bind ( & addr) . listen ( ) . unwrap ( ) ;
619644 let ( tx, rx) = channel :: < ( ) > ( ) ;
@@ -648,9 +673,10 @@ mod tests {
648673 tx. send ( ( ) ) ;
649674 s. set_timeout ( None ) ;
650675 assert_eq ! ( s. read( [ 0 , 0 ] ) , Ok ( 1 ) ) ;
651- } )
676+ }
652677
653- iotest ! ( fn read_timeouts( ) {
678+ #[ test]
679+ fn read_timeouts ( ) {
654680 let addr = next_test_unix ( ) ;
655681 let mut a = UnixListener :: bind ( & addr) . listen ( ) . unwrap ( ) ;
656682 let ( tx, rx) = channel :: < ( ) > ( ) ;
@@ -676,9 +702,10 @@ mod tests {
676702 for _ in range ( 0 u, 100 ) {
677703 assert ! ( s. write( [ 0 , ..128 * 1024 ] ) . is_ok( ) ) ;
678704 }
679- } )
705+ }
680706
681- iotest ! ( fn write_timeouts( ) {
707+ #[ test]
708+ fn write_timeouts ( ) {
682709 let addr = next_test_unix ( ) ;
683710 let mut a = UnixListener :: bind ( & addr) . listen ( ) . unwrap ( ) ;
684711 let ( tx, rx) = channel :: < ( ) > ( ) ;
@@ -702,9 +729,10 @@ mod tests {
702729
703730 tx. send ( ( ) ) ;
704731 assert ! ( s. read( [ 0 ] ) . is_ok( ) ) ;
705- } )
732+ }
706733
707- iotest ! ( fn timeout_concurrent_read( ) {
734+ #[ test]
735+ fn timeout_concurrent_read ( ) {
708736 let addr = next_test_unix ( ) ;
709737 let mut a = UnixListener :: bind ( & addr) . listen ( ) . unwrap ( ) ;
710738 let ( tx, rx) = channel :: < ( ) > ( ) ;
@@ -729,10 +757,11 @@ mod tests {
729757 tx. send ( ( ) ) ;
730758
731759 rx2. recv ( ) ;
732- } )
760+ }
733761
734762 #[ cfg( not( windows) ) ]
735- iotest ! ( fn clone_accept_smoke( ) {
763+ #[ test]
764+ fn clone_accept_smoke ( ) {
736765 let addr = next_test_unix ( ) ;
737766 let l = UnixListener :: bind ( & addr) ;
738767 let mut a = l. listen ( ) . unwrap ( ) ;
@@ -749,10 +778,11 @@ mod tests {
749778 assert ! ( a. accept( ) . is_ok( ) ) ;
750779 drop ( a) ;
751780 assert ! ( a2. accept( ) . is_ok( ) ) ;
752- } )
781+ }
753782
754783 #[ cfg( not( windows) ) ] // FIXME #17553
755- iotest ! ( fn clone_accept_concurrent( ) {
784+ #[ test]
785+ fn clone_accept_concurrent ( ) {
756786 let addr = next_test_unix ( ) ;
757787 let l = UnixListener :: bind ( & addr) ;
758788 let a = l. listen ( ) . unwrap ( ) ;
@@ -774,18 +804,20 @@ mod tests {
774804
775805 assert ! ( rx. recv( ) . is_ok( ) ) ;
776806 assert ! ( rx. recv( ) . is_ok( ) ) ;
777- } )
807+ }
778808
779- iotest ! ( fn close_accept_smoke( ) {
809+ #[ test]
810+ fn close_accept_smoke ( ) {
780811 let addr = next_test_unix ( ) ;
781812 let l = UnixListener :: bind ( & addr) ;
782813 let mut a = l. listen ( ) . unwrap ( ) ;
783814
784815 a. close_accept ( ) . unwrap ( ) ;
785816 assert_eq ! ( a. accept( ) . err( ) . unwrap( ) . kind, EndOfFile ) ;
786- } )
817+ }
787818
788- iotest ! ( fn close_accept_concurrent( ) {
819+ #[ test]
820+ fn close_accept_concurrent ( ) {
789821 let addr = next_test_unix ( ) ;
790822 let l = UnixListener :: bind ( & addr) ;
791823 let a = l. listen ( ) . unwrap ( ) ;
@@ -799,5 +831,5 @@ mod tests {
799831 a2. close_accept ( ) . unwrap ( ) ;
800832
801833 assert_eq ! ( rx. recv( ) . err( ) . unwrap( ) . kind, EndOfFile ) ;
802- } )
834+ }
803835}
0 commit comments