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     any(
10         target_os = "linux",
11         apple_targets,
12         target_os = "freebsd",
13         target_os = "netbsd"
14     )
15 ))]
test_drop()16 fn test_drop() {
17     use nix::sys::aio::*;
18     use nix::sys::signal::*;
19     use std::os::unix::io::AsRawFd;
20     use tempfile::tempfile;
21 
22     const WBUF: &[u8] = b"CDEF";
23 
24     let f = tempfile().unwrap();
25     f.set_len(6).unwrap();
26     let mut aiocb = Box::pin(AioWrite::new(
27         f.as_raw_fd(),
28         2, //offset
29         WBUF,
30         0, //priority
31         SigevNotify::SigevNone,
32     ));
33     aiocb.as_mut().submit().unwrap();
34 }
35