From 2ef201e43fd4c20936bf9412b2b92704d8e12527 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Mon, 28 Mar 2022 09:57:39 +0200 Subject: [PATCH] tests: Simplify test_vdpa_block() to increase stability It seems the vdpa_sim_block isn't behaving properly after the vhost device is closed, as it sometimes returns EBUSY when we try to open it again. The easiest way to deal with this issue is by simplifying the integration test, avoid to plug the same device after it's been unplugged. Signed-off-by: Sebastien Boeuf --- tests/integration.rs | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index cd91b9c2b..ecf115543 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -5925,10 +5925,16 @@ mod parallel { .ssh_command("sudo bash -c 'echo foobar > /dev/vdd'") .unwrap(); + // Check we can read the content back. + assert_eq!( + guest.ssh_command("sudo head -1 /dev/vdd").unwrap().trim(), + "foobar" + ); + // Unplug the device let cmd_success = remote_command(&api_socket, "remove-device", Some("myvdpa0")); assert!(cmd_success); - thread::sleep(std::time::Duration::new(30, 0)); + thread::sleep(std::time::Duration::new(10, 0)); // Check /dev/vdd doesn't exist anymore assert_eq!( @@ -5940,24 +5946,6 @@ mod parallel { .unwrap_or(1), 0 ); - - // Now let's plug it back - let (cmd_success, cmd_output) = remote_command_w_output( - &api_socket, - "add-vdpa", - Some("id=myvdpa0,path=/dev/vhost-vdpa-1,num_queues=1"), - ); - assert!(cmd_success); - assert!(String::from_utf8_lossy(&cmd_output) - .contains("{\"id\":\"myvdpa0\",\"bdf\":\"0000:00:07.0\"}")); - - thread::sleep(std::time::Duration::new(10, 0)); - - // And finally check the content - assert_eq!( - guest.ssh_command("sudo head -1 /dev/vdd").unwrap().trim(), - "foobar" - ); }); let _ = child.kill();