]> git.proxmox.com Git - rustc.git/blob - vendor/nix/test/sys/test_aio_drop.rs
New upstream version 1.70.0+dfsg2
[rustc.git] / vendor / nix / test / sys / test_aio_drop.rs
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 target_os = "ios",
12 target_os = "macos",
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::AsRawFd;
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_raw_fd(),
29 2, //offset
30 WBUF,
31 0, //priority
32 SigevNotify::SigevNone,
33 ));
34 aiocb.as_mut().submit().unwrap();
35 }