4 from atf_python.ktest import BaseKernelTest
5 from atf_python.sys.netlink.attrs import NlAttrU32
10 NS_WRITER_TYPE_MBUF = 0
11 NS_WRITER_TYPE_BUF = 1
12 NS_WRITER_TYPE_LBUF = 1
15 MCLBYTES = 2048 # XXX: may differ on some archs?
16 MJUMPAGESIZE = mmap.PAGESIZE
18 MJUM16BYTES = 16 * 1024
21 class TestNetlinkMessageWriter(BaseKernelTest):
22 KTEST_MODULE_NAME = "ktest_netlink_message_writer"
24 @pytest.mark.parametrize(
27 pytest.param(M_NOWAIT, id="NOWAIT"),
28 pytest.param(M_WAITOK, id="WAITOK"),
31 @pytest.mark.parametrize(
34 pytest.param(NS_WRITER_TYPE_MBUF, id="MBUF"),
35 pytest.param(NS_WRITER_TYPE_BUF, id="BUF"),
38 @pytest.mark.parametrize(
41 pytest.param([160, 160], id="MHLEN"),
42 pytest.param([MCLBYTES, MCLBYTES], id="MCLBYTES"),
45 def test_mbuf_writer_allocation(self, sz, writer_type, malloc_flags):
46 """override to parametrize"""
49 NlAttrU32(1, sz[0]), # size
50 NlAttrU32(2, sz[1]), # expected_avail
51 NlAttrU32(4, writer_type),
52 NlAttrU32(5, malloc_flags),
54 self.runtest(test_meta)
56 @pytest.mark.parametrize(
59 pytest.param(M_NOWAIT, id="NOWAIT"),
60 pytest.param(M_WAITOK, id="WAITOK"),
63 @pytest.mark.parametrize(
66 pytest.param([160, 160, 1], id="MHLEN"),
67 pytest.param([MCLBYTES, MCLBYTES, 1], id="MCLBYTES"),
68 pytest.param([MCLBYTES + 1, MCLBYTES + 1, 2], id="MCLBYTES_MHLEN"),
69 pytest.param([MCLBYTES + 256, MCLBYTES * 2, 2], id="MCLBYTESx2"),
72 def test_mbuf_chain_allocation(self, sz, malloc_flags):
74 NlAttrU32(1, sz[0]), # size
75 NlAttrU32(2, sz[1]), # expected_avail
76 NlAttrU32(3, sz[2]), # expected_count
77 NlAttrU32(5, malloc_flags),
79 self.runtest(test_meta)