freebsd-src/tests/sys/netlink/test_nl_core.py
Alexander V. Chernikov fee65b7e21 tests: split netlink.py into multiple files to impove maintainability.
This diff does not contain any functional changes.
Its sole purpose is splitting netlink.py into smaller chunks.
The new code simplifies the upcoming generic netlink support
introduction.

MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D39365
2023-04-01 19:31:38 +00:00

34 lines
1.1 KiB
Python

import errno
import socket
import pytest
from atf_python.sys.net.vnet import SingleVnetTestTemplate
from atf_python.sys.netlink.netlink import NetlinkTestTemplate
from atf_python.sys.netlink.utils import NlConst
class TestNlCore(NetlinkTestTemplate, SingleVnetTestTemplate):
@pytest.mark.parametrize(
"params",
[
pytest.param({"type": socket.SOCK_RAW}, id="SOCK_RAW"),
pytest.param({"type": socket.SOCK_DGRAM}, id="SOCK_DGRAM"),
],
)
def test_socket_type(self, params):
s = socket.socket(NlConst.AF_NETLINK, params["type"], NlConst.NETLINK_ROUTE)
s.close()
@pytest.mark.parametrize(
"params",
[
pytest.param({"type": socket.SOCK_STREAM}, id="SOCK_STREAM"),
pytest.param({"type": socket.SOCK_RDM}, id="SOCK_RDM"),
pytest.param({"type": socket.SOCK_SEQPACKET}, id="SOCK_SEQPACKET"),
],
)
def test_socket_type_unsup(self, params):
with pytest.raises(OSError) as exc_info:
socket.socket(NlConst.AF_NETLINK, params["type"], NlConst.NETLINK_ROUTE)
assert exc_info.value.errno == errno.EPROTOTYPE