Skip to content

Commit c051cb9

Browse files
committed
Move test_aio_drop into its own process
This works around a bug in OSX that hoses the AIO subsystem.
1 parent 030e93d commit c051cb9

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ nix-test = { path = "nix-test", version = "0.0.1" }
3131
name = "test"
3232
path = "test/test.rs"
3333

34+
[[test]]
35+
name = "test-aio-drop"
36+
path = "test/sys/test_aio_drop.rs"
37+
3438
[[test]]
3539
name = "test-mount"
3640
path = "test/test_mount.rs"

test/sys/test_aio.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -499,23 +499,3 @@ fn test_lio_listio_read_immutable() {
499499
LioOpcode::LIO_READ);
500500
let _ = lio_listio(LioMode::LIO_NOWAIT, &[&mut rcb], SigevNotify::SigevNone);
501501
}
502-
503-
// Test dropping an AioCb that hasn't yet finished.
504-
// Skip on OSX where this test seems to hose the AIO subsystem and
505-
// causes subsequent tests to fail
506-
#[test]
507-
#[should_panic(expected = "Dropped an in-progress AioCb")]
508-
#[cfg(not(any(target_os = "macos", target_env = "musl")))]
509-
fn test_drop() {
510-
const WBUF: &'static [u8] = b"CDEF";
511-
512-
let f = tempfile().unwrap();
513-
f.set_len(6).unwrap();
514-
let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
515-
2, //offset
516-
&WBUF,
517-
0, //priority
518-
SigevNotify::SigevNone,
519-
LioOpcode::LIO_NOP);
520-
aiocb.write().unwrap();
521-
}

test/sys/test_aio_drop.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
extern crate nix;
2+
extern crate tempfile;
3+
4+
use nix::sys::aio::*;
5+
use nix::sys::signal::*;
6+
use std::os::unix::io::AsRawFd;
7+
use tempfile::tempfile;
8+
9+
// Test dropping an AioCb that hasn't yet finished.
10+
// This must happen in its own process, because on OSX this test seems to hose
11+
// the AIO subsystem and causes subsequent tests to fail
12+
#[test]
13+
#[should_panic(expected = "Dropped an in-progress AioCb")]
14+
#[cfg(not(target_env = "musl"))]
15+
fn test_drop() {
16+
const WBUF: &'static [u8] = b"CDEF";
17+
18+
let f = tempfile().unwrap();
19+
f.set_len(6).unwrap();
20+
let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
21+
2, //offset
22+
&WBUF,
23+
0, //priority
24+
SigevNotify::SigevNone,
25+
LioOpcode::LIO_NOP);
26+
aiocb.write().unwrap();
27+
}

0 commit comments

Comments
 (0)