Skip to content

Commit 0195214

Browse files
committed
Update Windows guest tool tests
Remove duplicate test_tools_after_reboot which was no longer used. Reenable upgrade tests. Add suspend test with emulated NVMe. Add device ID toggle test. Add VIF replug test. Signed-off-by: Tu Dinh <[email protected]>
1 parent 40cc048 commit 0195214

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

tests/guest_tools/win/test_guest_tools_win.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import pytest
22

33
import logging
4+
import time
45

6+
from lib.commands import SSHCommandFailed
7+
from lib.common import wait_for
58
from lib.vm import VM
69

710
from . import PowerAction, wait_for_vm_running_and_ssh_up_without_tools
@@ -59,13 +62,19 @@
5962
@pytest.mark.multi_vms
6063
@pytest.mark.usefixtures("windows_vm")
6164
class TestGuestToolsWindows:
62-
def test_tools_after_reboot(self, vm_install_test_tools_per_test_class: VM):
65+
def test_drivers_detected(self, vm_install_test_tools_per_test_class: VM):
6366
vm = vm_install_test_tools_per_test_class
6467
assert vm.are_windows_tools_working()
6568

66-
def test_drivers_detected(self, vm_install_test_tools_per_test_class: VM):
69+
def test_vif_replug(self, vm_install_test_tools_per_test_class: VM):
6770
vm = vm_install_test_tools_per_test_class
68-
assert vm.are_windows_tools_working()
71+
vifs = vm.vifs()
72+
for vif in vifs:
73+
vif.unplug()
74+
# HACK: Allow some time for the unplug to settle. If not, Windows guests have a tendency to explode.
75+
time.sleep(5)
76+
vif.plug()
77+
wait_for(vm.is_ssh_up, "Wait for SSH up")
6978

7079

7180
@pytest.mark.multi_vms
@@ -90,9 +99,25 @@ def test_install_with_other_tools(
9099
):
91100
vm, param = vm_install_other_drivers
92101
if param["upgradable"]:
93-
pytest.xfail("Upgrades may require multiple reboots and are not testable yet")
94102
install_guest_tools(vm, guest_tools_iso, PowerAction.Reboot, check=False)
95103
assert vm.are_windows_tools_working()
96104
else:
97105
exitcode = install_guest_tools(vm, guest_tools_iso, PowerAction.Nothing, check=False)
98106
assert exitcode == ERROR_INSTALL_FAILURE
107+
108+
@pytest.mark.usefixtures("uefi_vm")
109+
def test_uefi_vm_suspend_refused_without_tools(self, running_unsealed_windows_vm: VM):
110+
vm = running_unsealed_windows_vm
111+
with pytest.raises(SSHCommandFailed):
112+
vm.suspend()
113+
wait_for_vm_running_and_ssh_up_without_tools(vm)
114+
115+
# Test of the unplug rework, where the driver must remain activated even if the device ID changes.
116+
# Also serves as a "close-enough" test of vendor device toggling.
117+
def test_toggle_device_id(self, running_unsealed_windows_vm: VM, guest_tools_iso: dict[str, Any]):
118+
vm = running_unsealed_windows_vm
119+
assert vm.param_get("platform", "device_id") == "0002"
120+
install_guest_tools(vm, guest_tools_iso, PowerAction.Shutdown, check=False)
121+
vm.param_set("platform", "0001", "device_id")
122+
vm.start()
123+
vm.wait_for_vm_running_and_ssh_up()

0 commit comments

Comments
 (0)