@@ -434,22 +434,39 @@ fn test_read_and_block() {
434
434
}
435
435
}
436
436
437
- #[ test] # [ ignore ( reason = "needs server" ) ]
437
+ #[ test]
438
438
fn test_read_read_read ( ) {
439
439
do run_in_newsched_task {
440
440
let addr = Ipv4 ( 127 , 0 , 0 , 1 , next_test_port ( ) ) ;
441
+ static MAX : uint = 5000000 ;
442
+
443
+ do spawn_immediately {
444
+ unsafe {
445
+ let io = local_sched:: unsafe_borrow_io ( ) ;
446
+ let mut listener = io. bind ( addr) . unwrap ( ) ;
447
+ let mut stream = listener. listen ( ) . unwrap ( ) ;
448
+ let mut buf = [ 0 , .. 2048 ] ;
449
+ let mut total_bytes_written = 0 ;
450
+ while total_bytes_written < MAX {
451
+ stream. write ( buf) ;
452
+ total_bytes_written += buf. len ( ) ;
453
+ }
454
+ stream. close ( ) ;
455
+ listener. close ( ) ;
456
+ }
457
+ }
441
458
442
459
do spawn_immediately {
443
460
let io = unsafe { local_sched:: unsafe_borrow_io ( ) } ;
444
461
let mut stream = io. connect ( addr) . unwrap ( ) ;
445
462
let mut buf = [ 0 , .. 2048 ] ;
446
463
let mut total_bytes_read = 0 ;
447
- while total_bytes_read < 500000000 {
464
+ while total_bytes_read < MAX {
448
465
let nread = stream. read ( buf) . unwrap ( ) ;
449
466
rtdebug ! ( "read %u bytes" , nread as uint) ;
450
467
total_bytes_read += nread;
451
468
}
452
- rtdebug_ ! ( "read %u bytes total" , total_bytes_read as uint) ;
469
+ rtdebug ! ( "read %u bytes total" , total_bytes_read as uint) ;
453
470
stream. close ( ) ;
454
471
}
455
472
}
0 commit comments