| 1 |
// Test dropping an AioCb that hasn't yet finished. |
| 2 |
// This must happen in its own process, because on OSX this test seems to hose |
| 3 |
// the AIO subsystem and causes subsequent tests to fail |
| 4 |
#[test] |
| 5 |
#[should_panic(expected = "Dropped an in-progress AioCb")] |
| 6 |
#[cfg(all( |
| 7 |
not(target_env = "musl"), |
| 8 |
not(target_env = "uclibc"), |
| 9 |
not(target_env = "ohos"), |
| 10 |
any( |
| 11 |
target_os = "linux", |
| 12 |
apple_targets, |
| 13 |
target_os = "freebsd", |
| 14 |
target_os = "netbsd" |
| 15 |
) |
| 16 |
))] |
| 17 |
fn test_drop() { |
| 18 |
use nix::sys::aio::*; |
| 19 |
use nix::sys::signal::*; |
| 20 |
use std::os::unix::io::AsFd; |
| 21 |
use tempfile::tempfile; |
| 22 |
|
| 23 |
const WBUF: &[u8] = b"CDEF"; |
| 24 |
|
| 25 |
let f = tempfile().unwrap(); |
| 26 |
f.set_len(6).unwrap(); |
| 27 |
let mut aiocb = Box::pin(AioWrite::new( |
| 28 |
f.as_fd(), |
| 29 |
2, //offset |
| 30 |
WBUF, |
| 31 |
0, //priority |
| 32 |
SigevNotify::SigevNone, |
| 33 |
)); |
| 34 |
aiocb.as_mut().submit().unwrap(); |
| 35 |
} |