Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F143365579
D37708.id114171.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D37708.id114171.diff
View Options
diff --git a/tests/atf_python/Makefile b/tests/atf_python/Makefile
--- a/tests/atf_python/Makefile
+++ b/tests/atf_python/Makefile
@@ -2,7 +2,7 @@
.PATH: ${.CURDIR}
-FILES= __init__.py atf_pytest.py
+FILES= __init__.py atf_pytest.py utils.py
SUBDIR= sys
.include <bsd.own.mk>
diff --git a/tests/atf_python/sys/net/tools.py b/tests/atf_python/sys/net/tools.py
--- a/tests/atf_python/sys/net/tools.py
+++ b/tests/atf_python/sys/net/tools.py
@@ -1,13 +1,6 @@
#!/usr/local/bin/python3
import json
import os
-import socket
-import time
-from ctypes import cdll
-from ctypes import get_errno
-from ctypes.util import find_library
-from typing import List
-from typing import Optional
class ToolsHelper(object):
diff --git a/tests/atf_python/sys/net/vnet.py b/tests/atf_python/sys/net/vnet.py
--- a/tests/atf_python/sys/net/vnet.py
+++ b/tests/atf_python/sys/net/vnet.py
@@ -5,17 +5,14 @@
import socket
import sys
import time
-from ctypes import cdll
-from ctypes import get_errno
-from ctypes.util import find_library
from multiprocessing import Pipe
from multiprocessing import Process
from typing import Dict
from typing import List
from typing import NamedTuple
-from typing import Optional
from atf_python.sys.net.tools import ToolsHelper
+from atf_python.utils import libc, BaseTest
def run_cmd(cmd: str, verbose=True) -> str:
@@ -145,7 +142,7 @@
def __init__(self, test_name: str):
self.test_name = test_name
- test_id = convert_test_name(test_name)
+ self.test_id = convert_test_name(test_name)
self.file_name = self.INTERFACES_FNAME
def _register_iface(self, iface_name: str):
@@ -204,13 +201,9 @@
@staticmethod
def attach_jid(jid: int):
- _path: Optional[str] = find_library("c")
- if _path is None:
- raise Exception("libc not found")
- path: str = _path
- libc = cdll.LoadLibrary(path)
- if libc.jail_attach(jid) != 0:
- raise Exception("jail_attach() failed: errno {}".format(get_errno()))
+ error_code = libc.jail_attach(jid)
+ if error_code != 0:
+ raise Exception("jail_attach() failed: errno {}".format(error_code))
def attach(self):
self.attach_jid(self.jid)
@@ -290,7 +283,7 @@
vnet_aliases: List[str]
-class VnetTestTemplate(object):
+class VnetTestTemplate(BaseTest):
TOPOLOGY = {}
def _get_vnet_handler(self, vnet_alias: str):
@@ -395,6 +388,7 @@
# 'test_ip6_output.py::TestIP6Output::test_output6_pktinfo[ipandif] (setup)'
test_id = os.environ.get("PYTEST_CURRENT_TEST").split(" ")[0]
test_name = test_id.split("::")[-1]
+ self.check_constraints()
topology = self.TOPOLOGY
# First, setup kernel objects - interfaces & vnets
obj_map = self.setup_topology(topology, test_name)
diff --git a/tests/atf_python/utils.py b/tests/atf_python/utils.py
new file mode 100644
--- /dev/null
+++ b/tests/atf_python/utils.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+import os
+from ctypes import CDLL
+from ctypes import get_errno
+from ctypes.util import find_library
+from typing import List
+from typing import Optional
+
+import pytest
+
+
+class LibCWrapper(object):
+ def __init__(self):
+ path: Optional[str] = find_library("c")
+ if path is None:
+ raise RuntimeError("libc not found")
+ self._libc = CDLL(path, use_errno=True)
+
+ def modfind(self, mod_name: str) -> int:
+ if self._libc.modfind(bytes(mod_name, encoding="ascii")) == -1:
+ return get_errno()
+ return 0
+
+ def jail_attach(self, jid: int) -> int:
+ if self._libc.jail_attach(jid) != 0:
+ return get_errno()
+ return 0
+
+
+libc = LibCWrapper()
+
+
+class BaseTest(object):
+ REQUIRED_MODULES: List[str] = []
+
+ def _check_modules(self):
+ for mod_name in self.REQUIRED_MODULES:
+ error_code = libc.modfind(mod_name)
+ if error_code != 0:
+ err_str = os.strerror(error_code)
+ pytest.skip(
+ "kernel module '{}' not available: {}".format(mod_name, err_str)
+ )
+
+ def check_constraints(self):
+ self._check_modules()
diff --git a/tests/sys/Makefile b/tests/sys/Makefile
--- a/tests/sys/Makefile
+++ b/tests/sys/Makefile
@@ -24,6 +24,7 @@
TESTS_SUBDIRS+= netinet
TESTS_SUBDIRS+= netinet6
TESTS_SUBDIRS+= netipsec
+TESTS_SUBDIRS+= netlink
TESTS_SUBDIRS+= netmap
TESTS_SUBDIRS+= netpfil
TESTS_SUBDIRS+= opencrypto
diff --git a/tests/sys/netlink/test_rtnl_iface.py b/tests/sys/netlink/test_rtnl_iface.py
--- a/tests/sys/netlink/test_rtnl_iface.py
+++ b/tests/sys/netlink/test_rtnl_iface.py
@@ -22,6 +22,8 @@
class TestRtNlIface(SingleVnetTestTemplate):
+ REQUIRED_MODULES = ["netlink"]
+
def setup_method(self, method):
super().setup_method(method)
self.helper = NlHelper()
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 30, 11:33 AM (11 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28099901
Default Alt Text
D37708.id114171.diff (4 KB)
Attached To
Mode
D37708: netlink: connect netlink tests to the build
Attached
Detach File
Event Timeline
Log In to Comment