aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2023-01-21 14:36:23 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2023-01-21 14:58:19 +0000
commit0079d177ab69168df5e103128a2b15bd8e74d4eb (patch)
tree637005c7076fad657447ca379e0aaa7b0b3b7c26 /tests
parent03a1b75950c95cd9360e5c283219b886d36afb53 (diff)
downloadsrc-0079d177ab69168df5e103128a2b15bd8e74d4eb.tar.gz
src-0079d177ab69168df5e103128a2b15bd8e74d4eb.zip
Diffstat (limited to 'tests')
-rw-r--r--tests/sys/netlink/Makefile1
-rw-r--r--tests/sys/netlink/test_nl_core.py33
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/sys/netlink/Makefile b/tests/sys/netlink/Makefile
index 87cee15c9d33..880e5e6e4007 100644
--- a/tests/sys/netlink/Makefile
+++ b/tests/sys/netlink/Makefile
@@ -6,6 +6,7 @@ WARNS?= 1
TESTSDIR= ${TESTSBASE}/sys/netlink
ATF_TESTS_C += test_snl
+ATF_TESTS_PYTEST += test_nl_core.py
ATF_TESTS_PYTEST += test_rtnl_iface.py
ATF_TESTS_PYTEST += test_rtnl_ifaddr.py
diff --git a/tests/sys/netlink/test_nl_core.py b/tests/sys/netlink/test_nl_core.py
new file mode 100644
index 000000000000..7af421a929dc
--- /dev/null
+++ b/tests/sys/netlink/test_nl_core.py
@@ -0,0 +1,33 @@
+import errno
+import socket
+
+import pytest
+from atf_python.sys.net.netlink import NetlinkTestTemplate
+from atf_python.sys.net.netlink import NlConst
+from atf_python.sys.net.vnet import SingleVnetTestTemplate
+
+
+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