From ea82632c70b1bbeac1f604354b2f87b56a837209 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 15 Apr 2020 18:17:51 +0100 Subject: [PATCH] tests: Enhance test_pmem_hotplug to also unplug device Ensure that the device is removed and the removed device stays away after a reboot. Signed-off-by: Rob Bradford --- tests/integration.rs | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/tests/integration.rs b/tests/integration.rs index 09a99b6e9..2a1bbe746 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -3798,7 +3798,7 @@ mod tests { &api_socket, "add-pmem", Some(&format!( - "file={},size=128M", + "file={},size=128M,id=test0", pmem_temp_file.path().to_str().unwrap() )) ) @@ -3839,6 +3839,48 @@ mod tests { 1 ); + aver!( + tb, + remote_command(&api_socket, "remove-device", Some("test0")) + ); + + thread::sleep(std::time::Duration::new(20, 0)); + + // Check device has gone away + aver_eq!( + tb, + guest + .ssh_command("lsblk | grep pmem0 | grep -c 128M") + .unwrap_or_default() + .trim() + .parse::() + .unwrap_or(1), + 0 + ); + + guest.ssh_command("sudo reboot").unwrap_or_default(); + + thread::sleep(std::time::Duration::new(20, 0)); + let reboot_count = guest + .ssh_command("sudo journalctl | grep -c -- \"-- Reboot --\"") + .unwrap_or_default() + .trim() + .parse::() + .unwrap_or_default(); + aver_eq!(tb, reboot_count, 2); + + // Check still absent after reboot + aver_eq!( + tb, + guest + .ssh_command("lsblk | grep pmem0 | grep -c 128M") + .unwrap_or_default() + .trim() + .parse::() + .unwrap_or(1), + 0 + ); + let _ = child.kill(); let _ = child.wait(); Ok(())