Skip to content

Commit

Permalink
tests: Fix missing wait() on spawned support commands
Browse files Browse the repository at this point in the history
   Compiling cloud-hypervisor v41.0.0 (/home/rob/src/cloud-hypervisor)
warning: spawned process is never `wait()`ed on
    --> tests/integration.rs:4250:31
     |
4250 |         let mut socat_child = socat_command.spawn().unwrap();
     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: consider calling `.wait()`
     = note: not doing so might leave behind zombie processes
     = note: see https://doc.rust-lang.org/stable/std/process/struct.Child.html#warning
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zombie_processes
     = note: `#[warn(clippy::zombie_processes)]` on by default

warning: spawned process is never `wait()`ed on
    --> tests/integration.rs:6687:9
     |
6687 | /         Command::new("/usr/local/bin/spdk-nvme/nvmf_tgt")
6688 | |             .args(["-i", "0", "-m", "0x1"])
6689 | |             .spawn()
6690 | |             .unwrap();
     | |                     ^- help: try: `.wait()`
     | |_____________________|
     |
     |
     = note: not doing so might leave behind zombie processes
     = note: see https://doc.rust-lang.org/stable/std/process/struct.Child.html#warning
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#zombie_processes

warning: `cloud-hypervisor` (test "integration") generated 2 warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.83s

Signed-off-by: Rob Bradford <[email protected]>
  • Loading branch information
rbradford committed Oct 21, 2024
1 parent 36b59a6 commit 107bfe1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4255,6 +4255,7 @@ mod common_parallel {
});

let _ = socat_child.kill();
let _ = socat_child.wait();

let r = std::panic::catch_unwind(|| {
guest.ssh_command("sudo shutdown -h now").unwrap();
Expand Down Expand Up @@ -6664,7 +6665,7 @@ mod common_parallel {
handle_child_output(r, &output);
}

fn setup_spdk_nvme(nvme_dir: &std::path::Path) {
fn setup_spdk_nvme(nvme_dir: &std::path::Path) -> Child {
cleanup_spdk_nvme();

assert!(exec_host_command_status(&format!(
Expand All @@ -6684,7 +6685,7 @@ mod common_parallel {
.success());

// Start the SPDK nvmf_tgt daemon to present NVMe device as a VFIO user device
Command::new("/usr/local/bin/spdk-nvme/nvmf_tgt")
let child = Command::new("/usr/local/bin/spdk-nvme/nvmf_tgt")
.args(["-i", "0", "-m", "0x1"])
.spawn()
.unwrap();
Expand Down Expand Up @@ -6713,6 +6714,8 @@ mod common_parallel {
nvme_dir.join("nvme-vfio-user").to_str().unwrap()
))
.success());

child
}

fn cleanup_spdk_nvme() {
Expand All @@ -6726,7 +6729,7 @@ mod common_parallel {
let guest = Guest::new(Box::new(jammy));

let spdk_nvme_dir = guest.tmp_dir.as_path().join("test-vfio-user");
setup_spdk_nvme(spdk_nvme_dir.as_path());
let mut spdk_child = setup_spdk_nvme(spdk_nvme_dir.as_path());

let api_socket = temp_api_path(&guest.tmp_dir);
let mut child = GuestCommand::new(&guest)
Expand Down Expand Up @@ -6797,7 +6800,8 @@ mod common_parallel {
);
});

cleanup_spdk_nvme();
let _ = spdk_child.kill();
let _ = spdk_child.wait();

kill_child(&mut child);
let output = child.wait_with_output().unwrap();
Expand Down

0 comments on commit 107bfe1

Please sign in to comment.