11import pytest
22
33import logging
4+ import time
45
6+ from lib .commands import SSHCommandFailed
7+ from lib .common import wait_for
58from lib .vm import VM
69
710from . import PowerAction , wait_for_vm_running_and_ssh_up_without_tools
5962@pytest .mark .multi_vms
6063@pytest .mark .usefixtures ("windows_vm" )
6164class 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,23 @@ 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+ def test_toggle_device_id (self , running_unsealed_windows_vm : VM , guest_tools_iso : dict [str , Any ]):
116+ vm = running_unsealed_windows_vm
117+ install_guest_tools (vm , guest_tools_iso , PowerAction .Shutdown , check = False )
118+ assert vm .param_get ("platform" , "device_id" ) == "0002"
119+ vm .param_set ("platform" , "0001" , "device_id" )
120+ vm .start ()
121+ vm .wait_for_vm_running_and_ssh_up ()
0 commit comments