-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Max Orok
committed
Nov 29, 2019
1 parent
4272735
commit 30324c4
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |