vmbase_example: Clarify that the payload is a BIOS
Rename all Soong targets to include "_bios" and refactor the linker
script and idmap.S to be preprocessed and receive a CPP macro
representing the "mode". Rename image.ld to reflect this.
Modify the test to use the new "_bios" binary name and refactor it to
make the core logic re-usable for future vmbase_example modes.
No functional change intended.
Test: atest vmbase_example.integration_test
Change-Id: I06679d154494d85916ff534298a066519b1b0778
diff --git a/tests/vmbase_example/src/main.rs b/tests/vmbase_example/src/main.rs
index 8f9fafc..de704fa 100644
--- a/tests/vmbase_example/src/main.rs
+++ b/tests/vmbase_example/src/main.rs
@@ -31,13 +31,17 @@
};
use vmclient::{DeathReason, VmInstance};
-const VMBASE_EXAMPLE_PATH: &str = "vmbase_example.bin";
+const VMBASE_EXAMPLE_BIOS_PATH: &str = "vmbase_example_bios.bin";
const TEST_DISK_IMAGE_PATH: &str = "test_disk.img";
const EMPTY_DISK_IMAGE_PATH: &str = "empty_disk.img";
-/// Runs the vmbase_example VM as an unprotected VM via VirtualizationService.
+/// Runs the vmbase_example VM as an unprotected VM BIOS via VirtualizationService.
#[test]
-fn test_run_example_vm() -> Result<(), Error> {
+fn test_run_example_bios_vm() -> Result<(), Error> {
+ run_test(Some(open_payload(VMBASE_EXAMPLE_BIOS_PATH)?))
+}
+
+fn run_test(bootloader: Option<ParcelFileDescriptor>) -> Result<(), Error> {
android_logger::init_once(
android_logger::Config::default()
.with_tag("vmbase")
@@ -56,12 +60,6 @@
vmclient::VirtualizationService::new().context("Failed to spawn VirtualizationService")?;
let service = virtmgr.connect().context("Failed to connect to VirtualizationService")?;
- // Start example VM.
- let bootloader = ParcelFileDescriptor::new(
- File::open(VMBASE_EXAMPLE_PATH)
- .with_context(|| format!("Failed to open VM image {}", VMBASE_EXAMPLE_PATH))?,
- );
-
// Make file for test disk image.
let mut test_image = File::options()
.create(true)
@@ -94,7 +92,7 @@
kernel: None,
initrd: None,
params: None,
- bootloader: Some(bootloader),
+ bootloader,
disks: vec![disk_image, empty_disk_image],
protectedVm: false,
memoryMib: 300,
@@ -142,6 +140,11 @@
Ok((reader_fd.into(), writer_fd.into()))
}
+fn open_payload(path: &str) -> Result<ParcelFileDescriptor, Error> {
+ let file = File::open(path).with_context(|| format!("Failed to open VM image {path}"))?;
+ Ok(ParcelFileDescriptor::new(file))
+}
+
struct VmLogProcessor {
reader: Option<File>,
expected: VecDeque<String>,