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(not(target_env = "musl"),
7           any(target_os = "linux",
8               target_os = "ios",
9               target_os = "macos",
10               target_os = "freebsd",
11               target_os = "netbsd")))]
12 #[cfg_attr(target_env = "gnu", ignore = "Occasionally fails in Travis; glibc bug suspected")]
test_drop()13 fn test_drop() {
14     use nix::sys::aio::*;
15     use nix::sys::signal::*;
16     use std::os::unix::io::AsRawFd;
17     use tempfile::tempfile;
18 
19     const WBUF: &[u8] = b"CDEF";
20 
21     let f = tempfile().unwrap();
22     f.set_len(6).unwrap();
23     let mut aiocb = AioCb::from_slice( f.as_raw_fd(),
24                            2,   //offset
25                            WBUF,
26                            0,   //priority
27                            SigevNotify::SigevNone,
28                            LioOpcode::LIO_NOP);
29     aiocb.write().unwrap();
30 }
31