Skip to content

Commit

Permalink
Move test_aio_drop into its own process
Browse files Browse the repository at this point in the history
This works around a bug in OSX that hoses the AIO subsystem.
  • Loading branch information
asomers committed Sep 2, 2017
1 parent 030e93d commit c051cb9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ nix-test = { path = "nix-test", version = "0.0.1" }
name = "test"
path = "test/test.rs"

[[test]]
name = "test-aio-drop"
path = "test/sys/test_aio_drop.rs"

[[test]]
name = "test-mount"
path = "test/test_mount.rs"
Expand Down
20 changes: 0 additions & 20 deletions test/sys/test_aio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,23 +499,3 @@ fn test_lio_listio_read_immutable() {
LioOpcode::LIO_READ);
let _ = lio_listio(LioMode::LIO_NOWAIT, &[&mut rcb], SigevNotify::SigevNone);
}

// Test dropping an AioCb that hasn't yet finished.
// Skip on OSX where this test seems to hose the AIO subsystem and
// causes subsequent tests to fail
#[test]
#[should_panic(expected = "Dropped an in-progress AioCb")]
#[cfg(not(any(target_os = "macos", target_env = "musl")))]
fn test_drop() {
const WBUF: &'static [u8] = b"CDEF";

let f = tempfile().unwrap();
f.set_len(6).unwrap();
let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
2, //offset
&WBUF,
0, //priority
SigevNotify::SigevNone,
LioOpcode::LIO_NOP);
aiocb.write().unwrap();
}
27 changes: 27 additions & 0 deletions test/sys/test_aio_drop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
extern crate nix;
extern crate tempfile;

use nix::sys::aio::*;
use nix::sys::signal::*;
use std::os::unix::io::AsRawFd;
use tempfile::tempfile;

// Test dropping an AioCb that hasn't yet finished.
// This must happen in its own process, because on OSX this test seems to hose
// the AIO subsystem and causes subsequent tests to fail
#[test]
#[should_panic(expected = "Dropped an in-progress AioCb")]
#[cfg(not(target_env = "musl"))]
fn test_drop() {
const WBUF: &'static [u8] = b"CDEF";

let f = tempfile().unwrap();
f.set_len(6).unwrap();
let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
2, //offset
&WBUF,
0, //priority
SigevNotify::SigevNone,
LioOpcode::LIO_NOP);
aiocb.write().unwrap();
}

0 comments on commit c051cb9

Please sign in to comment.