Skip to content

Commit

Permalink
Add single timeout test
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Orok committed Nov 29, 2019
1 parent 4272735 commit 30324c4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/timeout.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use std::io;
use iou::sys;

#[test]
fn timeout_test() -> io::Result<()> {
let mut io_uring = iou::IoUring::new(2)?;

let mut sq = io_uring.sq();
let mut sqe = sq.next_sqe().unwrap();

// make a timeout
let timeout_spec: _ = sys::__kernel_timespec {
tv_sec: 0 as _,
tv_nsec: 2e8 as _,
};

unsafe { sqe.prep_timeout(&timeout_spec); }

io_uring.sq().submit()?;

// check that timeout reading works
{
let mut cq = io_uring.cq();
let cqe = cq.wait_for_cqe()?;
assert!(cqe.is_timeout());
}

Ok(())
}

0 comments on commit 30324c4

Please sign in to comment.