()
| 11551 | #[test] |
| 11552 | #[cfg_attr(feature = "mshv", ignore = "See #7434")] |
| 11553 | fn test_fw_cfg() { |
| 11554 | let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string()); |
| 11555 | let guest = Guest::new(Box::new(disk_config)); |
| 11556 | let mut cmd = GuestCommand::new(&guest); |
| 11557 | |
| 11558 | let kernel_path = direct_kernel_boot_path(); |
| 11559 | let cmd_line = DIRECT_KERNEL_BOOT_CMDLINE; |
| 11560 | |
| 11561 | let test_file = guest.tmp_dir.as_path().join("test-file"); |
| 11562 | std::fs::write(&test_file, "test-file-content").unwrap(); |
| 11563 | |
| 11564 | cmd.args(["--cpus", "boot=4"]) |
| 11565 | .default_memory() |
| 11566 | .args(["--kernel", kernel_path.to_str().unwrap()]) |
| 11567 | .args(["--cmdline", cmd_line]) |
| 11568 | .default_disks() |
| 11569 | .default_net() |
| 11570 | .args([ |
| 11571 | "--fw-cfg-config", |
| 11572 | &format!( |
| 11573 | "initramfs=off,items=[name=opt/org.test/test-file,file={}]", |
| 11574 | test_file.to_str().unwrap() |
| 11575 | ), |
| 11576 | ]) |
| 11577 | .capture_output(); |
| 11578 | |
| 11579 | let mut child = cmd.spawn().unwrap(); |
| 11580 | |
| 11581 | let r = std::panic::catch_unwind(|| { |
| 11582 | guest.wait_vm_boot().unwrap(); |
| 11583 | // Wait a while for guest |
| 11584 | thread::sleep(std::time::Duration::new(3, 0)); |
| 11585 | let result = guest |
| 11586 | .ssh_command( |
| 11587 | "sudo cat /sys/firmware/qemu_fw_cfg/by_name/opt/org.test/test-file/raw", |
| 11588 | ) |
| 11589 | .unwrap(); |
| 11590 | assert_eq!(result, "test-file-content"); |
| 11591 | }); |
| 11592 | |
| 11593 | kill_child(&mut child); |
| 11594 | let output = child.wait_with_output().unwrap(); |
| 11595 | |
| 11596 | handle_child_output(r, &output); |
| 11597 | } |
| 11598 | |
| 11599 | #[test] |
| 11600 | #[cfg_attr(feature = "mshv", ignore = "See #7434")] |
nothing calls this directly
no test coverage detected