1
1
import pytest
2
2
3
3
import logging
4
+ import time
4
5
6
+ from lib .commands import SSHCommandFailed
7
+ from lib .common import wait_for
5
8
from lib .vm import VM
6
9
7
10
from . import PowerAction , wait_for_vm_running_and_ssh_up_without_tools
59
62
@pytest .mark .multi_vms
60
63
@pytest .mark .usefixtures ("windows_vm" )
61
64
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 ):
63
66
vm = vm_install_test_tools_per_test_class
64
67
assert vm .are_windows_tools_working ()
65
68
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 ):
67
70
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" )
69
78
70
79
71
80
@pytest .mark .multi_vms
@@ -90,9 +99,25 @@ def test_install_with_other_tools(
90
99
):
91
100
vm , param = vm_install_other_drivers
92
101
if param ["upgradable" ]:
93
- pytest .xfail ("Upgrades may require multiple reboots and are not testable yet" )
94
102
install_guest_tools (vm , guest_tools_iso , PowerAction .Reboot , check = False )
95
103
assert vm .are_windows_tools_working ()
96
104
else :
97
105
exitcode = install_guest_tools (vm , guest_tools_iso , PowerAction .Nothing , check = False )
98
106
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