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:
Alejandro Jimenez 2020-04-08 13:20:56 -04:00 committed by Sebastien Boeuf
parent 7134f3129f
commit 4617aefd60

View File

@ -3883,14 +3883,20 @@ 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);
vec![kernel_path, pvh_kernel_path]
.iter()
.for_each(|k_path| {
let mut child = GuestCommand::new(&guest)
.args(&["--kernel", kernel_path.to_str().unwrap()])
.args(&["--kernel", k_path.to_str().unwrap()])
.args(&["--initramfs", initramfs_path.to_str().unwrap()])
.args(&["--cmdline", &cmdline])
.capture_output()
@ -3903,12 +3909,11 @@ mod tests {
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),
}
});
Ok(())
});
}