Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tests/sys/netlink/test_netlink_message_writer.py
39536 views
1
import mmap
2
import pytest
3
4
from atf_python.ktest import BaseKernelTest
5
from atf_python.sys.netlink.attrs import NlAttrU32
6
7
M_NOWAIT = 1
8
M_WAITOK = 2
9
10
NLMSG_SMALL = 128
11
NLMSG_LARGE = 2048
12
13
class TestNetlinkMessageWriter(BaseKernelTest):
14
KTEST_MODULE_NAME = "ktest_netlink_message_writer"
15
16
@pytest.mark.parametrize(
17
"malloc_flags",
18
[
19
pytest.param(M_NOWAIT, id="NOWAIT"),
20
pytest.param(M_WAITOK, id="WAITOK"),
21
],
22
)
23
@pytest.mark.parametrize(
24
"sz",
25
[
26
pytest.param([NLMSG_SMALL, NLMSG_SMALL], id="NLMSG_SMALL"),
27
pytest.param([NLMSG_LARGE, NLMSG_LARGE], id="NLMSG_LARGE"),
28
pytest.param([NLMSG_LARGE + 256, NLMSG_LARGE + 256], id="NLMSG_LARGE+256"),
29
],
30
)
31
def test_nlbuf_writer_allocation(self, sz, malloc_flags):
32
"""override to parametrize"""
33
34
test_meta = [
35
NlAttrU32(1, sz[0]), # size
36
NlAttrU32(2, sz[1]), # expected_avail
37
NlAttrU32(3, malloc_flags),
38
]
39
self.runtest(test_meta)
40
41