Skip to content

Commit

Permalink
Hopefully fix the OSX failure in test_fsync
Browse files Browse the repository at this point in the history
  • Loading branch information
asomers committed Aug 2, 2017
1 parent b732877 commit 482d0c6
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions test/sys/test_aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,27 @@ fn test_fsync() {
let mut aiocb = AioCb::from_fd( f.as_raw_fd(),
0, //priority
SigevNotify::SigevNone);
let err = aiocb.fsync(AioFsyncMode::O_SYNC);
println!("fsync returned {:?}", err); //why does if fail on OSX?
assert!(err.is_ok());
loop {
let err = aiocb.fsync(AioFsyncMode::O_SYNC);
if err.is_ok() {
break;
} else if err == Err(Error::from(Errno::EAGAIN)) {
// On OSX the initial aio_fsync sometimes fails with EAGAIN
thread::sleep(time::Duration::from_millis(10));
} else {
panic!("AioCb::fsync returned {:?}", err.unwrap_err());
}
}
poll_aio(&mut aiocb).unwrap();
aiocb.aio_return().unwrap();
}

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

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

/// `AioCb::write` should not modify the `AioCb` object if libc::aio_write returns
/// an error
// Skip on Linux, because Linux's AIO implementation can't detect errors
// synchronously
#[test]
#[cfg(target_env = "freebsd")]
#[cfg(any(target_env = "freebsd", target_env = "macos"))]
fn test_write_error() {
let wbuf = "CDEF".to_string().into_bytes();
let mut aiocb = AioCb::from_slice( 666, // An invalid file descriptor
Expand Down Expand Up @@ -498,7 +512,7 @@ fn test_lio_listio_read_immutable() {
// library should wait for the AioCb's completion.
#[test]
#[should_panic(expected = "Dropped an in-progress AioCb")]
#[cfg_attr(all(target_env = "musl", target_arch = "x86_64"), ignore)]
#[cfg_attr(target_env = "musl", ignore)]
fn test_drop() {
const WBUF: &'static [u8] = b"CDEF";

Expand Down

0 comments on commit 482d0c6

Please sign in to comment.