Skip to content

Commit

Permalink
Teardown sd-viewer-disposable after test run
Browse files Browse the repository at this point in the history
VM existance tests introduced in the parent commit were failing due
to the fact that the test-only sd-viewer-disposable was laying
around after the test and appearing as vm with @tag:sd-workstation.

Fixes #1091.
  • Loading branch information
deeplow authored and legoktm committed Jun 25, 2024
1 parent 0cc8f84 commit 35b1519
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
33 changes: 22 additions & 11 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,25 @@ def test_enforced_apparmor_profiles(self):
class SD_Unnamed_DVM_Local_Test(SD_VM_Local_Test):
"""Tests disposables based on the provided DVM template"""

def setUp(self, dispvm_template_name):
self.app = Qubes()
self.vm_name = f"{dispvm_template_name}-disposable"

if self.vm_name not in self.app.domains:
cmd_create_disp = (
f"qvm-create --disp --property auto_cleanup=True "
f"--template {dispvm_template_name} {self.vm_name}"
)
subprocess.run(cmd_create_disp.split(), check=True)
super().setUp()
@classmethod
def _kill_test_vm(cls):
subprocess.run(["qvm-kill", cls.vm_name], check=True)

@classmethod
def setUpClass(cls, dispvm_template_name):
cls.app = Qubes()
cls.vm_name = f"{dispvm_template_name}-disposable"

# VM was running and needs a restart to test on the latest version
if cls.vm_name in cls.app.domains:
cls._kill_test_vm()
# Create disposable based on specified template
cmd_create_disp = (
f"qvm-create --disp --property auto_cleanup=True "
f"--template {dispvm_template_name} {cls.vm_name}"
)
subprocess.run(cmd_create_disp.split(), check=True)

@classmethod
def tearDownClass(cls):
cls._kill_test_vm()
6 changes: 5 additions & 1 deletion tests/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@


class SD_Viewer_Tests(SD_Unnamed_DVM_Local_Test):
@classmethod
def setUpClass(cls):
super().setUpClass("sd-viewer")

def setUp(self):
super().setUp("sd-viewer")
super().setUp()
self.expected_config_keys = {"SD_MIME_HANDLING"}
# this is not a comprehensive list, just a few that users are likely to use
self.enforced_apparmor_profiles = {
Expand Down

0 comments on commit 35b1519

Please sign in to comment.