MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / test_initramfs

Function test_initramfs

cloud-hypervisor/tests/integration.rs:5088–5134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5086
5087 #[test]
5088 fn test_initramfs() {
5089 let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string());
5090 let guest = Guest::new(Box::new(disk_config));
5091 let mut workload_path = dirs::home_dir().unwrap();
5092 workload_path.push("workloads");
5093
5094 #[cfg(target_arch = "x86_64")]
5095 let mut kernels = vec![direct_kernel_boot_path()];
5096 #[cfg(target_arch = "aarch64")]
5097 let kernels = [direct_kernel_boot_path()];
5098
5099 #[cfg(target_arch = "x86_64")]
5100 {
5101 let mut pvh_kernel_path = workload_path.clone();
5102 pvh_kernel_path.push("vmlinux-x86_64");
5103 kernels.push(pvh_kernel_path);
5104 }
5105
5106 let mut initramfs_path = workload_path;
5107 initramfs_path.push("alpine_initramfs.img");
5108
5109 let test_string = String::from("axz34i9rylotd8n50wbv6kcj7f2qushme1pg");
5110 let cmdline = format!("console=hvc0 quiet TEST_STRING={test_string}");
5111
5112 kernels.iter().for_each(|k_path| {
5113 let mut child = GuestCommand::new(&guest)
5114 .args(["--kernel", k_path.to_str().unwrap()])
5115 .args(["--initramfs", initramfs_path.to_str().unwrap()])
5116 .args(["--cmdline", &cmdline])
5117 .capture_output()
5118 .spawn()
5119 .unwrap();
5120
5121 thread::sleep(std::time::Duration::new(20, 0));
5122
5123 kill_child(&mut child);
5124 let output = child.wait_with_output().unwrap();
5125
5126 let r = std::panic::catch_unwind(|| {
5127 let s = String::from_utf8_lossy(&output.stdout);
5128
5129 assert_ne!(s.lines().position(|line| line == test_string), None);
5130 });
5131
5132 handle_child_output(r, &output);
5133 });
5134 }
5135
5136 #[test]
5137 fn test_counters() {

Callers

nothing calls this directly

Calls 10

newFunction · 0.85
direct_kernel_boot_pathFunction · 0.85
kill_childFunction · 0.85
handle_child_outputFunction · 0.85
iterMethod · 0.80
spawnMethod · 0.80
capture_outputMethod · 0.80
argsMethod · 0.80
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected