tests: Enable integration test for initramfs on AArch64

Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
Michael Zhao 2020-07-14 18:13:38 +08:00 committed by Rob Bradford
parent 3e051e7b2c
commit b363d1c706

View File

@ -4585,7 +4585,6 @@ mod tests {
} }
#[test] #[test]
#[cfg(target_arch = "x86_64")]
fn test_initramfs() { fn test_initramfs() {
test_block!(tb, "", { test_block!(tb, "", {
let mut focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string()); let mut focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
@ -4593,10 +4592,15 @@ mod tests {
let mut workload_path = dirs::home_dir().unwrap(); let mut workload_path = dirs::home_dir().unwrap();
workload_path.push("workloads"); workload_path.push("workloads");
let kernel_path = direct_kernel_boot_path().unwrap(); let mut kernels = vec![];
kernels.push(direct_kernel_boot_path().unwrap());
let mut pvh_kernel_path = workload_path.clone(); #[cfg(target_arch = "x86_64")]
pvh_kernel_path.push("vmlinux.pvh"); {
let mut pvh_kernel_path = workload_path.clone();
pvh_kernel_path.push("vmlinux.pvh");
kernels.push(pvh_kernel_path);
}
let mut initramfs_path = workload_path; let mut initramfs_path = workload_path;
initramfs_path.push("alpine_initramfs.img"); initramfs_path.push("alpine_initramfs.img");
@ -4604,28 +4608,26 @@ mod tests {
let test_string = String::from("axz34i9rylotd8n50wbv6kcj7f2qushme1pg"); let test_string = String::from("axz34i9rylotd8n50wbv6kcj7f2qushme1pg");
let cmdline = format!("console=hvc0 quiet TEST_STRING={}", test_string); let cmdline = format!("console=hvc0 quiet TEST_STRING={}", test_string);
vec![kernel_path, pvh_kernel_path] kernels.iter().for_each(|k_path| {
.iter() let mut child = GuestCommand::new(&guest)
.for_each(|k_path| { .args(&["--kernel", k_path.to_str().unwrap()])
let mut child = GuestCommand::new(&guest) .args(&["--initramfs", initramfs_path.to_str().unwrap()])
.args(&["--kernel", k_path.to_str().unwrap()]) .args(&["--cmdline", &cmdline])
.args(&["--initramfs", initramfs_path.to_str().unwrap()]) .capture_output()
.args(&["--cmdline", &cmdline]) .spawn()
.capture_output() .unwrap();
.spawn()
.unwrap();
thread::sleep(std::time::Duration::new(20, 0)); thread::sleep(std::time::Duration::new(20, 0));
let _ = child.kill(); let _ = child.kill();
match child.wait_with_output() { match child.wait_with_output() {
Ok(out) => { Ok(out) => {
let s = String::from_utf8_lossy(&out.stdout); let s = String::from_utf8_lossy(&out.stdout);
aver_ne!(tb, s.lines().position(|line| line == test_string), None); aver_ne!(tb, s.lines().position(|line| line == test_string), None);
}
Err(_) => aver!(tb, false),
} }
}); Err(_) => aver!(tb, false),
}
});
Ok(()) Ok(())
}); });
} }