mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
tests: Test initramfs loading with PVH boot
Add an integration test to verify loading an initramfs using the PVH boot protocol. Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
This commit is contained in:
parent
7134f3129f
commit
4617aefd60
@ -3883,32 +3883,37 @@ mod tests {
|
||||
let mut kernel_path = workload_path.clone();
|
||||
kernel_path.push("vmlinux");
|
||||
|
||||
let mut pvh_kernel_path = workload_path.clone();
|
||||
pvh_kernel_path.push("vmlinux.pvh");
|
||||
|
||||
let mut initramfs_path = workload_path;
|
||||
initramfs_path.push("alpine_initramfs.img");
|
||||
|
||||
let test_string = String::from("axz34i9rylotd8n50wbv6kcj7f2qushme1pg");
|
||||
let cmdline = format!("console=hvc0 quiet TEST_STRING={}", test_string);
|
||||
|
||||
let mut child = GuestCommand::new(&guest)
|
||||
.args(&["--kernel", kernel_path.to_str().unwrap()])
|
||||
.args(&["--initramfs", initramfs_path.to_str().unwrap()])
|
||||
.args(&["--cmdline", &cmdline])
|
||||
.capture_output()
|
||||
.spawn()
|
||||
.unwrap();
|
||||
vec![kernel_path, pvh_kernel_path]
|
||||
.iter()
|
||||
.for_each(|k_path| {
|
||||
let mut child = GuestCommand::new(&guest)
|
||||
.args(&["--kernel", k_path.to_str().unwrap()])
|
||||
.args(&["--initramfs", initramfs_path.to_str().unwrap()])
|
||||
.args(&["--cmdline", &cmdline])
|
||||
.capture_output()
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
thread::sleep(std::time::Duration::new(20, 0));
|
||||
|
||||
let _ = child.kill();
|
||||
match child.wait_with_output() {
|
||||
Ok(out) => {
|
||||
let s = String::from_utf8_lossy(&out.stdout);
|
||||
println!("{}", s);
|
||||
aver_ne!(tb, s.lines().position(|line| line == test_string), None);
|
||||
}
|
||||
Err(_) => aver!(tb, false),
|
||||
}
|
||||
thread::sleep(std::time::Duration::new(20, 0));
|
||||
|
||||
let _ = child.kill();
|
||||
match child.wait_with_output() {
|
||||
Ok(out) => {
|
||||
let s = String::from_utf8_lossy(&out.stdout);
|
||||
aver_ne!(tb, s.lines().position(|line| line == test_string), None);
|
||||
}
|
||||
Err(_) => aver!(tb, false),
|
||||
}
|
||||
});
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user