@@ -83,17 +83,27 @@ fn test_fsync() {
83
83
let mut aiocb = AioCb :: from_fd ( f. as_raw_fd ( ) ,
84
84
0 , //priority
85
85
SigevNotify :: SigevNone ) ;
86
- let err = aiocb. fsync ( AioFsyncMode :: O_SYNC ) ;
87
- println ! ( "fsync returned {:?}" , err) ; //why does if fail on OSX?
88
- assert ! ( err. is_ok( ) ) ;
86
+ loop {
87
+ let err = aiocb. fsync ( AioFsyncMode :: O_SYNC ) ;
88
+ if err. is_ok ( ) {
89
+ break ;
90
+ } else if err == Err ( Error :: from ( Errno :: EAGAIN ) ) {
91
+ // On OSX the initial aio_fsync sometimes fails with EAGAIN
92
+ thread:: sleep ( time:: Duration :: from_millis ( 10 ) ) ;
93
+ } else {
94
+ panic ! ( "AioCb::fsync returned {:?}" , err. unwrap_err( ) ) ;
95
+ }
96
+ }
89
97
poll_aio ( & mut aiocb) . unwrap ( ) ;
90
98
aiocb. aio_return ( ) . unwrap ( ) ;
91
99
}
92
100
93
101
/// `AioCb::fsync` should not modify the `AioCb` object if libc::aio_fsync returns
94
102
/// an error
103
+ // Skip on Linux, because Linux's AIO implementation can't detect errors
104
+ // synchronously
95
105
#[ test]
96
- #[ cfg( target_env = "freebsd" ) ]
106
+ #[ cfg( any ( target_env = "freebsd" , target_env = "macos" ) ) ]
97
107
fn test_fsync_error ( ) {
98
108
const INITIAL : & ' static [ u8 ] = b"abcdef123456" ;
99
109
// Create an invalid AioFsyncMode
@@ -176,8 +186,10 @@ fn test_read() {
176
186
177
187
/// `AioCb::read` should not modify the `AioCb` object if libc::aio_read returns
178
188
/// an error
189
+ // Skip on Linux, because Linux's AIO implementation can't detect errors
190
+ // synchronously
179
191
#[ test]
180
- #[ cfg( target_env = "freebsd" ) ]
192
+ #[ cfg( any ( target_env = "freebsd" , target_env = "macos" ) ) ]
181
193
fn test_read_error ( ) {
182
194
const INITIAL : & ' static [ u8 ] = b"abcdef123456" ;
183
195
let rbuf = Rc :: new ( vec ! [ 0 ; 4 ] . into_boxed_slice ( ) ) ;
@@ -268,8 +280,10 @@ fn test_write() {
268
280
269
281
/// `AioCb::write` should not modify the `AioCb` object if libc::aio_write returns
270
282
/// an error
283
+ // Skip on Linux, because Linux's AIO implementation can't detect errors
284
+ // synchronously
271
285
#[ test]
272
- #[ cfg( target_env = "freebsd" ) ]
286
+ #[ cfg( any ( target_env = "freebsd" , target_env = "macos" ) ) ]
273
287
fn test_write_error ( ) {
274
288
let wbuf = "CDEF" . to_string ( ) . into_bytes ( ) ;
275
289
let mut aiocb = AioCb :: from_slice ( 666 , // An invalid file descriptor
@@ -498,7 +512,7 @@ fn test_lio_listio_read_immutable() {
498
512
// library should wait for the AioCb's completion.
499
513
#[ test]
500
514
#[ should_panic( expected = "Dropped an in-progress AioCb" ) ]
501
- #[ cfg_attr( all ( target_env = "musl" , target_arch = "x86_64" ) , ignore) ]
515
+ #[ cfg_attr( target_env = "musl" , ignore) ]
502
516
fn test_drop ( ) {
503
517
const WBUF : & ' static [ u8 ] = b"CDEF" ;
504
518
0 commit comments