-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathtest_kernel_module.py
More file actions
105 lines (85 loc) · 3.19 KB
/
test_kernel_module.py
File metadata and controls
105 lines (85 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""Tests for the SLE15 kernel-module container."""
## Maintainer: BCI team (#proj-bci)
import re
import pytest
from _pytest.mark import ParameterSet
from pytest_container import DerivedContainer
from pytest_container import GitRepositoryBuild
from pytest_container import container_and_marks_from_pytest_param
from pytest_container.container import ContainerData
from pytest_container.runtime import LOCALHOST
from bci_tester.data import KERNEL_MODULE_CONTAINER
from bci_tester.data import OS_VERSION
CONTAINER_IMAGES = [KERNEL_MODULE_CONTAINER]
pytestmark = pytest.mark.skipif(
OS_VERSION in ("tumbleweed",),
reason="no kernel-module containers for Tumbleweed",
)
_DRBD_VERSION = "9.2.11"
def create_kernel_test(containerfile: str) -> ParameterSet:
return pytest.param(
DerivedContainer(
base=container_and_marks_from_pytest_param(
KERNEL_MODULE_CONTAINER
)[0],
containerfile=containerfile,
),
marks=KERNEL_MODULE_CONTAINER.marks,
id=KERNEL_MODULE_CONTAINER.id,
)
DRBD_CONTAINER = create_kernel_test(
rf"""WORKDIR /src/
RUN zypper -n in coccinelle tar
RUN set -euxo pipefail; \
curl -Lsf -o - https://pkg.linbit.com/downloads/drbd/9/drbd-{_DRBD_VERSION}.tar.gz | tar xzf - ; \
cd drbd-{_DRBD_VERSION}; \
make -C drbd all KDIR=/usr/src/linux-obj/$(uname -m)/default
""",
)
@pytest.mark.skipif(
OS_VERSION in ("16.0",),
reason="can't install additional packages yet on 16",
)
@pytest.mark.parametrize("container", [DRBD_CONTAINER], indirect=True)
def test_drbd_builds(container: ContainerData) -> None:
"""Test that the DRBD kernel module builds."""
drbd_kernel_module_file = (
f"/src/drbd-{_DRBD_VERSION}/drbd/build-current/drbd.ko"
)
assert container.connection.file(drbd_kernel_module_file).exists
modinfo_out = container.connection.check_output(
f"modinfo {drbd_kernel_module_file}"
)
assert re.search(r"^name:\s+drbd", modinfo_out, flags=re.MULTILINE)
assert re.search(
rf"^version:\s+{_DRBD_VERSION}", modinfo_out, flags=re.MULTILINE
)
@pytest.mark.skipif(
LOCALHOST.system_info.arch not in ("x86_64", "aarch64", "ppc64le"),
reason="DPDK is not supported on this architecture",
)
@pytest.mark.parametrize(
"container_git_clone",
[
GitRepositoryBuild(
repository_url="https://dpdk.org/git/dpdk-kmods",
repository_tag="main",
build_command="""cd linux/igb_uio/;
make KSRC=/usr/src/linux-obj/$(uname -m)/default""",
).to_pytest_param(),
],
indirect=["container_git_clone"],
)
def test_igb_uio(auto_container_per_test, container_git_clone) -> None:
"""Test that the DPDK kernel module builds."""
igb_uio_kernel_module_file = "/dpdk-kmods/linux/igb_uio/igb_uio.ko"
auto_container_per_test.connection.check_output(
container_git_clone.test_command
)
assert auto_container_per_test.connection.file(
igb_uio_kernel_module_file
).exists
modinfo_out = auto_container_per_test.connection.check_output(
f"modinfo {igb_uio_kernel_module_file}"
)
assert re.search(r"^name:\s+igb_uio", modinfo_out, flags=re.MULTILINE)