]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/sys/netlink/test_nl_core.py
netlink: use protocol specific receive buffer
[FreeBSD/FreeBSD.git] / tests / sys / netlink / test_nl_core.py
1 import errno
2 import socket
3
4 import pytest
5 from atf_python.sys.net.vnet import SingleVnetTestTemplate
6 from atf_python.sys.netlink.netlink import NetlinkTestTemplate
7 from atf_python.sys.netlink.utils import NlConst
8
9
10 class TestNlCore(NetlinkTestTemplate, SingleVnetTestTemplate):
11     @pytest.mark.parametrize(
12         "params",
13         [
14             pytest.param({"type": socket.SOCK_RAW}, id="SOCK_RAW"),
15             pytest.param({"type": socket.SOCK_DGRAM}, id="SOCK_DGRAM"),
16         ],
17     )
18     def test_socket_type(self, params):
19         s = socket.socket(NlConst.AF_NETLINK, params["type"], NlConst.NETLINK_ROUTE)
20         s.close()
21
22     @pytest.mark.parametrize(
23         "params",
24         [
25             pytest.param({"type": socket.SOCK_STREAM}, id="SOCK_STREAM"),
26             pytest.param({"type": socket.SOCK_RDM}, id="SOCK_RDM"),
27             pytest.param({"type": socket.SOCK_SEQPACKET}, id="SOCK_SEQPACKET"),
28         ],
29     )
30     def test_socket_type_unsup(self, params):
31         with pytest.raises(OSError) as exc_info:
32             socket.socket(NlConst.AF_NETLINK, params["type"], NlConst.NETLINK_ROUTE)
33         assert exc_info.value.errno == errno.EPROTOTYPE