Skip to content

Commit 482d0c6

Browse files
committed
Hopefully fix the OSX failure in test_fsync
1 parent b732877 commit 482d0c6

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

test/sys/test_aio.rs

+21-7
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,27 @@ fn test_fsync() {
8383
let mut aiocb = AioCb::from_fd( f.as_raw_fd(),
8484
0, //priority
8585
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+
}
8997
poll_aio(&mut aiocb).unwrap();
9098
aiocb.aio_return().unwrap();
9199
}
92100

93101
/// `AioCb::fsync` should not modify the `AioCb` object if libc::aio_fsync returns
94102
/// an error
103+
// Skip on Linux, because Linux's AIO implementation can't detect errors
104+
// synchronously
95105
#[test]
96-
#[cfg(target_env = "freebsd")]
106+
#[cfg(any(target_env = "freebsd", target_env = "macos"))]
97107
fn test_fsync_error() {
98108
const INITIAL: &'static [u8] = b"abcdef123456";
99109
// Create an invalid AioFsyncMode
@@ -176,8 +186,10 @@ fn test_read() {
176186

177187
/// `AioCb::read` should not modify the `AioCb` object if libc::aio_read returns
178188
/// an error
189+
// Skip on Linux, because Linux's AIO implementation can't detect errors
190+
// synchronously
179191
#[test]
180-
#[cfg(target_env = "freebsd")]
192+
#[cfg(any(target_env = "freebsd", target_env = "macos"))]
181193
fn test_read_error() {
182194
const INITIAL: &'static [u8] = b"abcdef123456";
183195
let rbuf = Rc::new(vec![0; 4].into_boxed_slice());
@@ -268,8 +280,10 @@ fn test_write() {
268280

269281
/// `AioCb::write` should not modify the `AioCb` object if libc::aio_write returns
270282
/// an error
283+
// Skip on Linux, because Linux's AIO implementation can't detect errors
284+
// synchronously
271285
#[test]
272-
#[cfg(target_env = "freebsd")]
286+
#[cfg(any(target_env = "freebsd", target_env = "macos"))]
273287
fn test_write_error() {
274288
let wbuf = "CDEF".to_string().into_bytes();
275289
let mut aiocb = AioCb::from_slice( 666, // An invalid file descriptor
@@ -498,7 +512,7 @@ fn test_lio_listio_read_immutable() {
498512
// library should wait for the AioCb's completion.
499513
#[test]
500514
#[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)]
502516
fn test_drop() {
503517
const WBUF: &'static [u8] = b"CDEF";
504518

0 commit comments

Comments
 (0)