mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-11 04:26:38 +00:00
ac97: Add top level unit test
Check that the device can be created. This test would have caught the bug with adding pci bars. Change-Id: Ib0cc2edf0d8d1b2d95d9c3588ac325b5da886603 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1497738 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
This commit is contained in:
parent
2de0088c9e
commit
e4ece32798
1 changed files with 21 additions and 0 deletions
|
@ -210,3 +210,24 @@ impl PciDevice for Ac97Dev {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use audio_streams::DummyStreamSource;
|
||||
use resources::AddressRanges;
|
||||
use sys_util::GuestAddress;
|
||||
|
||||
#[test]
|
||||
fn create() {
|
||||
let mem = GuestMemory::new(&[(GuestAddress(0u64), 4 * 1024 * 1024)]).unwrap();
|
||||
let mut ac97_dev = Ac97Dev::new(mem, Box::new(DummyStreamSource::new()));
|
||||
let mut allocator = AddressRanges::new()
|
||||
.add_io_addresses(0x1000_0000, 0x1000_0000)
|
||||
.add_mmio_addresses(0x2000_0000, 0x1000_0000)
|
||||
.add_device_addresses(0x3000_0000, 0x1000_0000)
|
||||
.create_allocator(5, false)
|
||||
.unwrap();
|
||||
assert!(ac97_dev.allocate_io_bars(&mut allocator).is_ok());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue