From e75a0912f5c72212f53f0595a0d5b1d276a6d0d6 Mon Sep 17 00:00:00 2001 From: Max Orok Date: Fri, 29 Nov 2019 17:00:11 -0500 Subject: [PATCH] Add single timeout test --- tests/timeout.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/timeout.rs diff --git a/tests/timeout.rs b/tests/timeout.rs new file mode 100644 index 0000000..7bac21a --- /dev/null +++ b/tests/timeout.rs @@ -0,0 +1,22 @@ +use iou::sqe::TimeoutFlags; + +#[test] +#[should_panic(expected = "Timer expired")] +fn timeout_test() { + let mut io_uring = iou::IoUring::new(2).unwrap(); + let mut sq = io_uring.sq(); + let mut sqe = sq.prepare_sqe().unwrap(); + + // make a timeout + let timeout_spec: _ = uring_sys::__kernel_timespec { + tv_sec: 0 as _, + tv_nsec: 2e4 as _, + }; + + unsafe { sqe.prep_timeout(&timeout_spec, 0, TimeoutFlags::empty()); } + io_uring.sq().submit().unwrap(); + + let mut cq = io_uring.cq(); + let cqe = cq.wait_for_cqe().unwrap(); + let _ = cqe.result().unwrap(); // panics with ETIME +}