mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
devices: virtio: video: fix tests with base MemoryMapping
The MemoryMapping API has changed and these tests are not run by default, which prevented us from catching this. BUG=b:213149154 TEST=with crrev.com/c/3026355: cargo test --features "video-decoder,ffmpeg" -p devices virtio::video Change-Id: I79a07d5a60c520d16190dd220b9a0f7501565e2c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3493533 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
abfe4b5a53
commit
6e81be02c3
1 changed files with 9 additions and 7 deletions
|
@ -319,9 +319,7 @@ impl GuestResource {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use base::{MappedRegion, SafeDescriptor};
|
use base::{MappedRegion, SafeDescriptor, SharedMemory};
|
||||||
use base::{MemoryMapping, SharedMemory};
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
/// Creates a sparse guest memory handle using as many pages as there are entries in
|
/// Creates a sparse guest memory handle using as many pages as there are entries in
|
||||||
|
@ -349,14 +347,18 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the initialized vector's content into an anonymous shared memory.
|
// Copy the initialized vector's content into an anonymous shared memory.
|
||||||
let mut mem = SharedMemory::anon().unwrap();
|
let mem = SharedMemory::anon(data.len() as u64).unwrap();
|
||||||
mem.set_size(data.len() as u64).unwrap();
|
let mapping = MemoryMappingBuilder::new(mem.size() as usize)
|
||||||
let mapping = MemoryMapping::from_fd(&mem, mem.size() as usize).unwrap();
|
.from_shared_memory(&mem)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
assert_eq!(mapping.write_slice(&data, 0).unwrap(), data.len());
|
assert_eq!(mapping.write_slice(&data, 0).unwrap(), data.len());
|
||||||
|
|
||||||
// Create the `GuestMemHandle` we will try to map and retrieve the data from.
|
// Create the `GuestMemHandle` we will try to map and retrieve the data from.
|
||||||
let mem_handle = GuestResourceHandle::GuestPages(GuestMemHandle {
|
let mem_handle = GuestResourceHandle::GuestPages(GuestMemHandle {
|
||||||
desc: unsafe { SafeDescriptor::from_raw_descriptor(base::clone_fd(&mem).unwrap()) },
|
desc: unsafe {
|
||||||
|
SafeDescriptor::from_raw_descriptor(base::clone_descriptor(&mem).unwrap())
|
||||||
|
},
|
||||||
mem_areas: page_order
|
mem_areas: page_order
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&page| GuestMemArea {
|
.map(|&page| GuestMemArea {
|
||||||
|
|
Loading…
Reference in a new issue