@@ -257,6 +257,8 @@ mod tests {
257
257
use super :: * ;
258
258
use io:: * ;
259
259
use io:: test:: * ;
260
+ use io:: fs:: PathExtensions ;
261
+ use time:: Duration ;
260
262
261
263
pub fn smalltest ( server : proc ( UnixStream ) : Send , client : proc ( UnixStream ) : Send ) {
262
264
let path1 = next_test_unix ( ) ;
@@ -277,7 +279,8 @@ mod tests {
277
279
}
278
280
}
279
281
280
- iotest ! ( fn bind_error( ) {
282
+ #[ test]
283
+ fn bind_error ( ) {
281
284
let path = "path/to/nowhere" ;
282
285
match UnixListener :: bind ( & path) {
283
286
Ok ( ..) => fail ! ( ) ,
@@ -286,9 +289,10 @@ mod tests {
286
289
e. kind == InvalidInput ) ;
287
290
}
288
291
}
289
- } )
292
+ }
290
293
291
- iotest ! ( fn connect_error( ) {
294
+ #[ test]
295
+ fn connect_error ( ) {
292
296
let path = if cfg ! ( windows) {
293
297
r"\\.\pipe\this_should_not_exist_ever"
294
298
} else {
@@ -300,29 +304,33 @@ mod tests {
300
304
assert ! ( e. kind == FileNotFound || e. kind == OtherIoError ) ;
301
305
}
302
306
}
303
- } )
307
+ }
304
308
305
- iotest ! ( fn smoke( ) {
309
+ #[ test]
310
+ fn smoke ( ) {
306
311
smalltest ( proc ( mut server) {
307
312
let mut buf = [ 0 ] ;
308
313
server. read ( buf) . unwrap ( ) ;
309
314
assert ! ( buf[ 0 ] == 99 ) ;
310
315
} , proc ( mut client) {
311
316
client. write ( [ 99 ] ) . unwrap ( ) ;
312
317
} )
313
- } )
318
+ }
314
319
315
- iotest ! ( fn read_eof( ) {
320
+ #[ cfg_attr( windows, ignore) ] // FIXME(#12516)
321
+ #[ test]
322
+ fn read_eof ( ) {
316
323
smalltest ( proc ( mut server) {
317
324
let mut buf = [ 0 ] ;
318
325
assert ! ( server. read( buf) . is_err( ) ) ;
319
326
assert ! ( server. read( buf) . is_err( ) ) ;
320
327
} , proc ( _client) {
321
328
// drop the client
322
329
} )
323
- } # [ cfg_attr ( windows , ignore ) ] ) // FIXME(#12516)
330
+ }
324
331
325
- iotest ! ( fn write_begone( ) {
332
+ #[ test]
333
+ fn write_begone ( ) {
326
334
smalltest ( proc ( mut server) {
327
335
let buf = [ 0 ] ;
328
336
loop {
@@ -340,9 +348,10 @@ mod tests {
340
348
} , proc ( _client) {
341
349
// drop the client
342
350
} )
343
- } )
351
+ }
344
352
345
- iotest ! ( fn accept_lots( ) {
353
+ #[ test]
354
+ fn accept_lots ( ) {
346
355
let times = 10 ;
347
356
let path1 = next_test_unix ( ) ;
348
357
let path2 = path1. clone ( ) ;
@@ -371,16 +380,18 @@ mod tests {
371
380
}
372
381
assert_eq ! ( buf[ 0 ] , 100 ) ;
373
382
}
374
- } )
383
+ }
375
384
376
385
#[ cfg( unix) ]
377
- iotest ! ( fn path_exists( ) {
386
+ #[ test]
387
+ fn path_exists ( ) {
378
388
let path = next_test_unix ( ) ;
379
389
let _acceptor = UnixListener :: bind ( & path) . listen ( ) ;
380
390
assert ! ( path. exists( ) ) ;
381
- } )
391
+ }
382
392
383
- iotest ! ( fn unix_clone_smoke( ) {
393
+ #[ test]
394
+ fn unix_clone_smoke ( ) {
384
395
let addr = next_test_unix ( ) ;
385
396
let mut acceptor = UnixListener :: bind ( & addr) . listen ( ) ;
386
397
@@ -414,9 +425,10 @@ mod tests {
414
425
assert_eq ! ( s1. read( buf) , Ok ( 1 ) ) ;
415
426
debug ! ( "reader done" ) ;
416
427
rx2. recv ( ) ;
417
- } )
428
+ }
418
429
419
- iotest ! ( fn unix_clone_two_read( ) {
430
+ #[ test]
431
+ fn unix_clone_two_read ( ) {
420
432
let addr = next_test_unix ( ) ;
421
433
let mut acceptor = UnixListener :: bind ( & addr) . listen ( ) ;
422
434
let ( tx1, rx) = channel ( ) ;
@@ -446,9 +458,10 @@ mod tests {
446
458
tx1. send ( ( ) ) ;
447
459
448
460
rx. recv ( ) ;
449
- } )
461
+ }
450
462
451
- iotest ! ( fn unix_clone_two_write( ) {
463
+ #[ test]
464
+ fn unix_clone_two_write ( ) {
452
465
let addr = next_test_unix ( ) ;
453
466
let mut acceptor = UnixListener :: bind ( & addr) . listen ( ) ;
454
467
@@ -471,25 +484,30 @@ mod tests {
471
484
s1. write ( [ 2 ] ) . unwrap ( ) ;
472
485
473
486
rx. recv ( ) ;
474
- } )
487
+ }
475
488
476
- iotest ! ( fn drop_removes_listener_path( ) {
489
+ #[ cfg( not( windows) ) ]
490
+ #[ test]
491
+ fn drop_removes_listener_path ( ) {
477
492
let path = next_test_unix ( ) ;
478
493
let l = UnixListener :: bind ( & path) . unwrap ( ) ;
479
494
assert ! ( path. exists( ) ) ;
480
495
drop ( l) ;
481
496
assert ! ( !path. exists( ) ) ;
482
- } # [ cfg ( not ( windows ) ) ] )
497
+ }
483
498
484
- iotest ! ( fn drop_removes_acceptor_path( ) {
499
+ #[ cfg( not( windows) ) ]
500
+ #[ test]
501
+ fn drop_removes_acceptor_path ( ) {
485
502
let path = next_test_unix ( ) ;
486
503
let l = UnixListener :: bind ( & path) . unwrap ( ) ;
487
504
assert ! ( path. exists( ) ) ;
488
505
drop ( l. listen ( ) . unwrap ( ) ) ;
489
506
assert ! ( !path. exists( ) ) ;
490
- } # [ cfg ( not ( windows ) ) ] )
507
+ }
491
508
492
- iotest ! ( fn accept_timeout( ) {
509
+ #[ test]
510
+ fn accept_timeout ( ) {
493
511
let addr = next_test_unix ( ) ;
494
512
let mut a = UnixListener :: bind ( & addr) . unwrap ( ) . listen ( ) . unwrap ( ) ;
495
513
@@ -527,32 +545,37 @@ mod tests {
527
545
drop ( UnixStream :: connect ( & addr2) . unwrap ( ) ) ;
528
546
} ) ;
529
547
a. accept ( ) . unwrap ( ) ;
530
- } )
548
+ }
531
549
532
- iotest ! ( fn connect_timeout_error( ) {
550
+ #[ test]
551
+ fn connect_timeout_error ( ) {
533
552
let addr = next_test_unix ( ) ;
534
553
assert ! ( UnixStream :: connect_timeout( & addr, Duration :: milliseconds( 100 ) ) . is_err( ) ) ;
535
- } )
554
+ }
536
555
537
- iotest ! ( fn connect_timeout_success( ) {
556
+ #[ test]
557
+ fn connect_timeout_success ( ) {
538
558
let addr = next_test_unix ( ) ;
539
559
let _a = UnixListener :: bind ( & addr) . unwrap ( ) . listen ( ) . unwrap ( ) ;
540
560
assert ! ( UnixStream :: connect_timeout( & addr, Duration :: milliseconds( 100 ) ) . is_ok( ) ) ;
541
- } )
561
+ }
542
562
543
- iotest ! ( fn connect_timeout_zero( ) {
563
+ #[ test]
564
+ fn connect_timeout_zero ( ) {
544
565
let addr = next_test_unix ( ) ;
545
566
let _a = UnixListener :: bind ( & addr) . unwrap ( ) . listen ( ) . unwrap ( ) ;
546
567
assert ! ( UnixStream :: connect_timeout( & addr, Duration :: milliseconds( 0 ) ) . is_err( ) ) ;
547
- } )
568
+ }
548
569
549
- iotest ! ( fn connect_timeout_negative( ) {
570
+ #[ test]
571
+ fn connect_timeout_negative ( ) {
550
572
let addr = next_test_unix ( ) ;
551
573
let _a = UnixListener :: bind ( & addr) . unwrap ( ) . listen ( ) . unwrap ( ) ;
552
574
assert ! ( UnixStream :: connect_timeout( & addr, Duration :: milliseconds( -1 ) ) . is_err( ) ) ;
553
- } )
575
+ }
554
576
555
- iotest ! ( fn close_readwrite_smoke( ) {
577
+ #[ test]
578
+ fn close_readwrite_smoke ( ) {
556
579
let addr = next_test_unix ( ) ;
557
580
let a = UnixListener :: bind ( & addr) . listen ( ) . unwrap ( ) ;
558
581
let ( _tx, rx) = channel :: < ( ) > ( ) ;
@@ -586,9 +609,10 @@ mod tests {
586
609
let _ = s2. close_write ( ) ;
587
610
let _ = s3. close_read ( ) ;
588
611
let _ = s3. close_write ( ) ;
589
- } )
612
+ }
590
613
591
- iotest ! ( fn close_read_wakes_up( ) {
614
+ #[ test]
615
+ fn close_read_wakes_up ( ) {
592
616
let addr = next_test_unix ( ) ;
593
617
let a = UnixListener :: bind ( & addr) . listen ( ) . unwrap ( ) ;
594
618
let ( _tx, rx) = channel :: < ( ) > ( ) ;
@@ -611,9 +635,10 @@ mod tests {
611
635
612
636
// this test will never finish if the child doesn't wake up
613
637
rx. recv ( ) ;
614
- } )
638
+ }
615
639
616
- iotest ! ( fn readwrite_timeouts( ) {
640
+ #[ test]
641
+ fn readwrite_timeouts ( ) {
617
642
let addr = next_test_unix ( ) ;
618
643
let mut a = UnixListener :: bind ( & addr) . listen ( ) . unwrap ( ) ;
619
644
let ( tx, rx) = channel :: < ( ) > ( ) ;
@@ -648,9 +673,10 @@ mod tests {
648
673
tx. send ( ( ) ) ;
649
674
s. set_timeout ( None ) ;
650
675
assert_eq ! ( s. read( [ 0 , 0 ] ) , Ok ( 1 ) ) ;
651
- } )
676
+ }
652
677
653
- iotest ! ( fn read_timeouts( ) {
678
+ #[ test]
679
+ fn read_timeouts ( ) {
654
680
let addr = next_test_unix ( ) ;
655
681
let mut a = UnixListener :: bind ( & addr) . listen ( ) . unwrap ( ) ;
656
682
let ( tx, rx) = channel :: < ( ) > ( ) ;
@@ -676,9 +702,10 @@ mod tests {
676
702
for _ in range ( 0 u, 100 ) {
677
703
assert ! ( s. write( [ 0 , ..128 * 1024 ] ) . is_ok( ) ) ;
678
704
}
679
- } )
705
+ }
680
706
681
- iotest ! ( fn write_timeouts( ) {
707
+ #[ test]
708
+ fn write_timeouts ( ) {
682
709
let addr = next_test_unix ( ) ;
683
710
let mut a = UnixListener :: bind ( & addr) . listen ( ) . unwrap ( ) ;
684
711
let ( tx, rx) = channel :: < ( ) > ( ) ;
@@ -702,9 +729,10 @@ mod tests {
702
729
703
730
tx. send ( ( ) ) ;
704
731
assert ! ( s. read( [ 0 ] ) . is_ok( ) ) ;
705
- } )
732
+ }
706
733
707
- iotest ! ( fn timeout_concurrent_read( ) {
734
+ #[ test]
735
+ fn timeout_concurrent_read ( ) {
708
736
let addr = next_test_unix ( ) ;
709
737
let mut a = UnixListener :: bind ( & addr) . listen ( ) . unwrap ( ) ;
710
738
let ( tx, rx) = channel :: < ( ) > ( ) ;
@@ -729,10 +757,11 @@ mod tests {
729
757
tx. send ( ( ) ) ;
730
758
731
759
rx2. recv ( ) ;
732
- } )
760
+ }
733
761
734
762
#[ cfg( not( windows) ) ]
735
- iotest ! ( fn clone_accept_smoke( ) {
763
+ #[ test]
764
+ fn clone_accept_smoke ( ) {
736
765
let addr = next_test_unix ( ) ;
737
766
let l = UnixListener :: bind ( & addr) ;
738
767
let mut a = l. listen ( ) . unwrap ( ) ;
@@ -749,10 +778,11 @@ mod tests {
749
778
assert ! ( a. accept( ) . is_ok( ) ) ;
750
779
drop ( a) ;
751
780
assert ! ( a2. accept( ) . is_ok( ) ) ;
752
- } )
781
+ }
753
782
754
783
#[ cfg( not( windows) ) ] // FIXME #17553
755
- iotest ! ( fn clone_accept_concurrent( ) {
784
+ #[ test]
785
+ fn clone_accept_concurrent ( ) {
756
786
let addr = next_test_unix ( ) ;
757
787
let l = UnixListener :: bind ( & addr) ;
758
788
let a = l. listen ( ) . unwrap ( ) ;
@@ -774,18 +804,20 @@ mod tests {
774
804
775
805
assert ! ( rx. recv( ) . is_ok( ) ) ;
776
806
assert ! ( rx. recv( ) . is_ok( ) ) ;
777
- } )
807
+ }
778
808
779
- iotest ! ( fn close_accept_smoke( ) {
809
+ #[ test]
810
+ fn close_accept_smoke ( ) {
780
811
let addr = next_test_unix ( ) ;
781
812
let l = UnixListener :: bind ( & addr) ;
782
813
let mut a = l. listen ( ) . unwrap ( ) ;
783
814
784
815
a. close_accept ( ) . unwrap ( ) ;
785
816
assert_eq ! ( a. accept( ) . err( ) . unwrap( ) . kind, EndOfFile ) ;
786
- } )
817
+ }
787
818
788
- iotest ! ( fn close_accept_concurrent( ) {
819
+ #[ test]
820
+ fn close_accept_concurrent ( ) {
789
821
let addr = next_test_unix ( ) ;
790
822
let l = UnixListener :: bind ( & addr) ;
791
823
let a = l. listen ( ) . unwrap ( ) ;
@@ -799,5 +831,5 @@ mod tests {
799
831
a2. close_accept ( ) . unwrap ( ) ;
800
832
801
833
assert_eq ! ( rx. recv( ) . err( ) . unwrap( ) . kind, EndOfFile ) ;
802
- } )
834
+ }
803
835
}
0 commit comments