Skip to content

Commit 58403e1

Browse files
committed
tests/xen/test_ring0: add type hints
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent 2185374 commit 58403e1

2 files changed

Lines changed: 23 additions & 21 deletions

File tree

tests/xen/conftest.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@
88
from lib.host import Host
99
from pkgfixtures import host_with_saved_yum_state
1010

11+
from typing import Generator
12+
1113
@pytest.fixture(scope="package")
12-
def host_with_hvm_fep(host: Host):
14+
def host_with_hvm_fep(host: Host) -> Generator[Host, None, None]:
1315
logging.info("Checking for HVM FEP support")
1416
xen_args = host.ssh('xl info xen_commandline').split()
1517
if 'hvm_fep' not in xen_args and 'hvm_fep=1' not in xen_args:
1618
pytest.fail("HVM FEP is required for some of the XTF tests")
1719
yield host
1820

1921
@pytest.fixture(scope="package")
20-
def host_with_dynamically_disabled_ept_sp(host: Host):
22+
def host_with_dynamically_disabled_ept_sp(host: Host) -> Generator[Host, None, None]:
2123
"""
2224
Disable EPT superpages before running XTF.
2325
@@ -30,7 +32,7 @@ def host_with_dynamically_disabled_ept_sp(host: Host):
3032
host.ssh('xl set-parameters ept=exec-sp')
3133

3234
@pytest.fixture(scope="package")
33-
def host_with_git_and_gcc_and_py3(host_with_saved_yum_state: Host):
35+
def host_with_git_and_gcc_and_py3(host_with_saved_yum_state: Host) -> Generator[Host, None, None]:
3436
host = host_with_saved_yum_state
3537
host_less_8_3 = host.xcp_version < version.parse("8.3")
3638
if host_less_8_3:
@@ -43,7 +45,7 @@ def host_with_git_and_gcc_and_py3(host_with_saved_yum_state: Host):
4345
host.ssh('rm /usr/bin/python3')
4446

4547
@pytest.fixture(scope="package")
46-
def xtf_runner(host_with_git_and_gcc_and_py3: Host):
48+
def xtf_runner(host_with_git_and_gcc_and_py3: Host) -> Generator[str, None, None]:
4749
host = host_with_git_and_gcc_and_py3
4850
logging.info("Download and build XTF")
4951
tmp_dir = host.ssh('mktemp -d')
@@ -64,7 +66,7 @@ def xtf_runner(host_with_git_and_gcc_and_py3: Host):
6466
host.ssh(f'rm -rf {tmp_dir}')
6567

6668
@pytest.fixture(scope="package")
67-
def host_with_dom0_tests(host_with_saved_yum_state):
69+
def host_with_dom0_tests(host_with_saved_yum_state: Host) -> Generator[Host, None, None]:
6870
host = host_with_saved_yum_state
6971
host.yum_install(['xen-dom0-tests'])
7072
yield host

tests/xen/test_ring0.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,42 +49,42 @@ def do_execute_xst(host: Host, modname: str, testname: str | None = None) -> Non
4949
@pytest.mark.reboot # host_with_ring0_tests
5050
@pytest.mark.usefixtures("host_with_ring0_tests")
5151
class TestRing0Tests:
52-
def test_privcmd_restrict(self, host: Host):
52+
def test_privcmd_restrict(self, host: Host) -> None:
5353
host.ssh("/usr/bin/privcmd-restrict_test")
5454

55-
def test_xst_alloc_balloon(self, host: Host):
55+
def test_xst_alloc_balloon(self, host: Host) -> None:
5656
do_execute_xst(host, "alloc_balloon")
5757

58-
def test_xst_big_module(self, host: Host):
58+
def test_xst_big_module(self, host: Host) -> None:
5959
do_execute_xst(host, "big_module")
6060

6161
@pytest.mark.skip("may hang system with fifo evtchn")
62-
def test_xst_evtchn_latency(self, host: Host):
62+
def test_xst_evtchn_latency(self, host: Host) -> None:
6363
do_execute_xst(host, "evtchn_latency", "evtchn_lat")
6464

6565
@pytest.mark.skip("only makes sense for 2l evtchn")
66-
def test_xst_evtchn_limit(self, host: Host):
66+
def test_xst_evtchn_limit(self, host: Host) -> None:
6767
do_execute_xst(host, "evtchn_limit")
6868

69-
def test_xst_evtchn_stress(self, host: Host):
69+
def test_xst_evtchn_stress(self, host: Host) -> None:
7070
do_execute_xst(host, "evtchn_stress")
7171

7272
@pytest.mark.skip("leaks event channels infinitely")
73-
def test_xst_evtchn_unbind(self, host: Host):
73+
def test_xst_evtchn_unbind(self, host: Host) -> None:
7474
do_execute_xst(host, "evtchn_unbind")
7575

76-
def test_xst_get_user_pages(self, host: Host):
76+
def test_xst_get_user_pages(self, host: Host) -> None:
7777
host.ssh("modprobe xst_get_user_pages")
7878
try:
7979
host.ssh("/usr/bin/gup_test")
8080
finally:
8181
host.ssh("modprobe -r xst_get_user_pages", check=False)
8282

83-
def test_xst_grant_copy_perf(self, host: Host):
83+
def test_xst_grant_copy_perf(self, host: Host) -> None:
8484
do_execute_xst(host, "grant_copy_perf", "gntcpy_perf")
8585

8686
@pytest.mark.small_vm
87-
def test_xst_ioemu_msi(self, host: Host, running_unix_vm: VM):
87+
def test_xst_ioemu_msi(self, host: Host, running_unix_vm: VM) -> None:
8888
# TODO: validate MSI reception in guest
8989
vm = running_unix_vm
9090
domid = vm.param_get("dom-id")
@@ -98,7 +98,7 @@ def test_xst_ioemu_msi(self, host: Host, running_unix_vm: VM):
9898
host.ssh("modprobe -r xst_ioemu_msi", check=False)
9999

100100
@pytest.mark.usefixtures("host_at_least_8_3")
101-
def test_xst_livepatch(self, host_without_livepatch_loaded: Host):
101+
def test_xst_livepatch(self, host_without_livepatch_loaded: Host) -> None:
102102
"""
103103
This test loads a `livepatch_testee` module, and triggers the test
104104
function `test_function_default` by writing to
@@ -130,7 +130,7 @@ def test_xst_livepatch(self, host_without_livepatch_loaded: Host):
130130
finally:
131131
host.ssh("modprobe -r livepatch_testee", check=False)
132132

133-
def test_xst_memory_leak(self, host: Host):
133+
def test_xst_memory_leak(self, host: Host) -> None:
134134
if not host.file_exists("/sys/kernel/debug/kmemleak"):
135135
pytest.skip("CONFIG_DEBUG_KMEMLEAK is not set")
136136

@@ -148,15 +148,15 @@ def test_xst_memory_leak(self, host: Host):
148148
finally:
149149
host.ssh("modprobe -r xst_memory_leak", check=False)
150150

151-
def test_xst_pte_set_clear_flags(self, host: Host):
151+
def test_xst_pte_set_clear_flags(self, host: Host) -> None:
152152
do_execute_xst(host, "pte_set_clear_flags")
153153

154-
def test_xst_ptwr_xchg(self, host: Host):
154+
def test_xst_ptwr_xchg(self, host: Host) -> None:
155155
do_execute_xst(host, "ptwr_xchg")
156156

157-
def test_xst_set_memory_uc(self, host: Host):
157+
def test_xst_set_memory_uc(self, host: Host) -> None:
158158
do_execute_xst(host, "set_memory_uc")
159159

160160
@pytest.mark.skip("crashes the host, disabled by default")
161-
def test_xst_soft_lockup(self, host: Host):
161+
def test_xst_soft_lockup(self, host: Host) -> None:
162162
do_execute_xst(host, "soft_lockup")

0 commit comments

Comments
 (0)