-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tu Dinh <[email protected]>
- Loading branch information
Tu Dinh
committed
Nov 28, 2024
1 parent
25cea38
commit 83d7e20
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import logging | ||
from pathlib import PureWindowsPath | ||
from typing import Any | ||
import pytest | ||
from lib.common import wait_for | ||
from lib.vm import VM | ||
|
||
from . import wait_for_vm_running_and_ssh_up_without_tools | ||
|
||
|
||
def run_xenclean(vm: VM, guest_tools_iso: dict[str, Any]): | ||
vm.insert_cd(guest_tools_iso["name"]) | ||
wait_for(lambda: vm.path_exists("D:/")) | ||
|
||
logging.info("Run XenClean") | ||
xenclean_path = PureWindowsPath("D:\\") / guest_tools_iso["xenclean_path"] | ||
xenclean_cmd = f"Set-Location C:\\; {xenclean_path} -NoReboot -Confirm:$false; Stop-Computer -Force" | ||
vm.start_background_powershell(xenclean_cmd) | ||
|
||
wait_for(vm.is_halted, "Wait for VM halted") | ||
vm.eject_cd() | ||
|
||
vm.start() | ||
wait_for_vm_running_and_ssh_up_without_tools(vm) | ||
|
||
|
||
@pytest.mark.multi_vms | ||
@pytest.mark.usefixtures("windows_vm") | ||
class TestXenClean: | ||
def test_xenclean_without_tools(self, running_unsealed_windows_vm, guest_tools_iso): | ||
vm = running_unsealed_windows_vm | ||
logging.info("XenClean with empty VM") | ||
run_xenclean(vm, guest_tools_iso) | ||
assert vm.are_windows_tools_uninstalled() | ||
|
||
def test_xenclean_with_test_tools(self, vm_install_test_tools, guest_tools_iso): | ||
vm = vm_install_test_tools | ||
logging.info("XenClean with test tools") | ||
run_xenclean(vm, guest_tools_iso) | ||
assert vm.are_windows_tools_uninstalled() | ||
|
||
def test_xenclean_with_other_tools(self, vm_install_other_drivers, guest_tools_iso): | ||
vm, _ = vm_install_other_drivers | ||
logging.info(f"XenClean with other tools") | ||
run_xenclean(vm, guest_tools_iso) | ||
assert vm.are_windows_tools_uninstalled() |