mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: add support for initramfs
the integration test creates an initramfs image based on AlpineLinux mini root filesystem with a simple /init script that just echoes a string to the console. The string is passed via the kernel cmdline as an environment variable. Signed-off-by: Damjan Georgievski <gdamjan@gmail.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
6cce7b9560
commit
3b470d4f4b
@@ -3842,4 +3842,45 @@ mod tests {
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_initramfs() {
|
||||
test_block!(tb, "", {
|
||||
let mut clear = ClearDiskConfig::new();
|
||||
let guest = Guest::new(&mut clear);
|
||||
let mut workload_path = dirs::home_dir().unwrap();
|
||||
workload_path.push("workloads");
|
||||
|
||||
let mut kernel_path = workload_path.clone();
|
||||
kernel_path.push("vmlinux");
|
||||
|
||||
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();
|
||||
|
||||
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),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user