aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2024-07-18 20:36:55 +0000
committerKristof Provost <kp@FreeBSD.org>2024-08-22 19:01:33 +0000
commit09d61b28a00a0645087859ca124c17499c6941e1 (patch)
tree523d712e348ce416988dad4f744c030d2d6ce8c3
parent145f5005aea398e88333a3d86d288bac811920b2 (diff)
downloadsrc-09d61b28a00a0645087859ca124c17499c6941e1.tar.gz
src-09d61b28a00a0645087859ca124c17499c6941e1.zip
vnet tests: verify that we can load if_epair and if_bridge
We're going to start running many of the vnet tests in nested jails (so they can run in parallel). That means the tests won't be able to load kernel modules, which we commonly do for if_epair and if_bridge. Just assume that all vnet tests need this, because so many of them do that we don't want to manually annotate all of them. This is essentially a no-op on non-nested tests. Do the same for the python test framework. While here also have pflog_init actually call pft_init. While having pflog loaded implies we have pf too pft_init also checks for vimage support, and now for if_epair. Reviewed by: markj MFC after: 1 month Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D46039 (cherry picked from commit ae8d58814089308028046ac80aeeb9cbb784bd0a)
-rw-r--r--tests/atf_python/sys/net/vnet.py6
-rw-r--r--tests/sys/common/vnet.subr21
-rw-r--r--tests/sys/netpfil/pf/utils.subr2
3 files changed, 29 insertions, 0 deletions
diff --git a/tests/atf_python/sys/net/vnet.py b/tests/atf_python/sys/net/vnet.py
index 8942e6839b35..7af63aa2b0c3 100644
--- a/tests/atf_python/sys/net/vnet.py
+++ b/tests/atf_python/sys/net/vnet.py
@@ -335,6 +335,10 @@ class VnetTestTemplate(BaseTest):
NEED_ROOT: bool = True
TOPOLOGY = {}
+ def _require_default_modules(self):
+ libc.kldload("if_epair.ko")
+ self.require_module("if_epair")
+
def _get_vnet_handler(self, vnet_alias: str):
handler_name = "{}_handler".format(vnet_alias)
return getattr(self, handler_name, None)
@@ -452,6 +456,8 @@ class VnetTestTemplate(BaseTest):
def setup_method(self, _method):
"""Sets up all the required topology and handlers for the given test"""
super().setup_method(_method)
+ self._require_default_modules()
+
# TestIP6Output.test_output6_pktinfo[ipandif]
topology_id = get_topology_id(self.test_id)
topology = self.TOPOLOGY
diff --git a/tests/sys/common/vnet.subr b/tests/sys/common/vnet.subr
index 0f7dec0dc6f1..ee498cda64f3 100644
--- a/tests/sys/common/vnet.subr
+++ b/tests/sys/common/vnet.subr
@@ -11,11 +11,32 @@ unlist_interface()
sed -i "" /^$1\$/d created_interfaces.lst
}
+_vnet_check_req()
+{
+ type=$1
+
+ if kldstat -q -n if_${type}.ko; then
+ return
+ fi
+
+ if ! kldload -n -q if_${type}; then
+ atf_skip "if_${type}.ko is required to run this test."
+ return
+ fi
+}
+
vnet_init()
{
if [ "`sysctl -i -n kern.features.vimage`" != 1 ]; then
atf_skip "This test requires VIMAGE"
fi
+
+ # Check if we can create if_epair or if_bridge interfaces.
+ # We may be running in a jail already, unable to load modules.
+ # If so, skip this test because it very likely (but not certainly)
+ # wants at least one of those
+ _vnet_check_req epair
+ _vnet_check_req bridge
}
vnet_mkepair()
diff --git a/tests/sys/netpfil/pf/utils.subr b/tests/sys/netpfil/pf/utils.subr
index 74ed07984601..8b463ca15fb3 100644
--- a/tests/sys/netpfil/pf/utils.subr
+++ b/tests/sys/netpfil/pf/utils.subr
@@ -83,6 +83,8 @@ pfsynct_init()
pflog_init()
{
+ pft_init
+
if ! kldstat -q -m pflog; then
atf_skip "This test requires pflog"
fi