Skip to content

Commit 1882a3d

Browse files
committed
tests: refactor test_nv.py to use uvm_any_booted
Use a new uvm_any_booted fixture to make the test simpler. Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent c2ebbb4 commit 1882a3d

File tree

2 files changed

+9
-27
lines changed

2 files changed

+9
-27
lines changed

tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,3 +494,9 @@ def uvm_ctor(request):
494494
def uvm_any(microvm_factory, uvm_ctor, guest_kernel, rootfs, cpu_template_any):
495495
"""Return booted and restored uvms"""
496496
return uvm_ctor(microvm_factory, guest_kernel, rootfs, cpu_template_any)
497+
498+
499+
@pytest.fixture
500+
def uvm_any_booted(microvm_factory, guest_kernel, rootfs, cpu_template_any):
501+
"""Return booted uvms"""
502+
return uvm_booted(microvm_factory, guest_kernel, rootfs, cpu_template_any)

tests/integration_tests/security/test_nv.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,7 @@
1616
start providing the feature by mistake.
1717
"""
1818

19-
import pytest
2019

21-
22-
@pytest.fixture
23-
def uvm_with_cpu_template(microvm_factory, guest_kernel, rootfs, cpu_template_any):
24-
"""A microvm fixture parametrized with all possible templates"""
25-
vm = microvm_factory.build(guest_kernel, rootfs)
26-
vm.spawn()
27-
cpu_template = None
28-
if isinstance(cpu_template_any, str):
29-
cpu_template = cpu_template_any
30-
vm.basic_config(cpu_template=cpu_template)
31-
if isinstance(cpu_template_any, dict):
32-
vm.api.cpu_config.put(**cpu_template_any["template"])
33-
vm.add_net_iface()
34-
vm.start()
35-
yield vm
36-
37-
38-
def test_no_nv_when_using_cpu_templates(uvm_with_cpu_template):
39-
"""
40-
Double-check that guests using CPU templates don't have Nested Virtualization
41-
enabled.
42-
"""
43-
44-
vm = uvm_with_cpu_template
45-
rc, _, _ = vm.ssh.run("[ ! -e /dev/kvm ]")
46-
assert rc == 0, "/dev/kvm exists"
20+
def test_no_nested_virtualization(uvm_any_booted):
21+
"""Validate that guests don't have Nested Virtualization enabled."""
22+
uvm_any_booted.ssh.check_output("[ ! -e /dev/kvm ]")

0 commit comments

Comments
 (0)