1import errno 2import socket 3 4import pytest 5from atf_python.sys.net.netlink import NetlinkTestTemplate 6from atf_python.sys.net.netlink import NlConst 7from atf_python.sys.net.vnet import SingleVnetTestTemplate 8 9 10class 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 34