mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
io_uring: use WaitContext
BUG=b:213153157 TEST=presubmit Change-Id: I5875151109f391fbd217269c864abe7d32b7b92e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3626209 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Noah Gold <nkgold@google.com> Auto-Submit: Vikram Auradkar <auradkar@google.com> Commit-Queue: Vikram Auradkar <auradkar@google.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
d724d41e19
commit
95707cfa9c
1 changed files with 6 additions and 5 deletions
|
@ -892,7 +892,7 @@ mod tests {
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use base::{pipe, EventContext};
|
use base::{pipe, WaitContext};
|
||||||
use sync::{Condvar, Mutex};
|
use sync::{Condvar, Mutex};
|
||||||
use tempfile::{tempfile, TempDir};
|
use tempfile::{tempfile, TempDir};
|
||||||
|
|
||||||
|
@ -1062,11 +1062,11 @@ mod tests {
|
||||||
f.write_all(&buf).unwrap();
|
f.write_all(&buf).unwrap();
|
||||||
f.write_all(&buf).unwrap();
|
f.write_all(&buf).unwrap();
|
||||||
|
|
||||||
let ctx: EventContext<u64> = EventContext::build_with(&[(&uring, 1)]).unwrap();
|
let ctx: WaitContext<u64> = WaitContext::build_with(&[(&uring, 1)]).unwrap();
|
||||||
{
|
{
|
||||||
// Test that the uring context isn't readable before any events are complete.
|
// Test that the uring context isn't readable before any events are complete.
|
||||||
let events = ctx.wait_timeout(Duration::from_millis(1)).unwrap();
|
let events = ctx.wait_timeout(Duration::from_millis(1)).unwrap();
|
||||||
assert!(events.iter_readable().next().is_none());
|
assert!(events.iter().next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -1077,8 +1077,9 @@ mod tests {
|
||||||
uring.submit().unwrap();
|
uring.submit().unwrap();
|
||||||
// Poll for completion with epoll.
|
// Poll for completion with epoll.
|
||||||
let events = ctx.wait().unwrap();
|
let events = ctx.wait().unwrap();
|
||||||
let event = events.iter_readable().next().unwrap();
|
let event = events.iter().next().unwrap();
|
||||||
assert_eq!(event.token(), 1);
|
assert!(event.is_readable);
|
||||||
|
assert_eq!(event.token, 1);
|
||||||
let (user_data, res) = uring.wait().unwrap().next().unwrap();
|
let (user_data, res) = uring.wait().unwrap().next().unwrap();
|
||||||
assert_eq!(user_data, 55_u64);
|
assert_eq!(user_data, 55_u64);
|
||||||
assert_eq!(res.unwrap(), buf.len() as u32);
|
assert_eq!(res.unwrap(), buf.len() as u32);
|
||||||
|
|
Loading…
Reference in a new issue