]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: also check if networkd built with BTF support before BPF test
authorLuca Boccassi <luca.boccassi@gmail.com>
Mon, 25 May 2026 15:54:48 +0000 (16:54 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 25 May 2026 17:13:51 +0000 (18:13 +0100)
SUSE does not provide a vmlinux.h so the package is not built with
CO-RE support, hence the test fails. This was previously masked
by the fact that python3-packaging was never installed, so the
test always skipped everywhere as it could not detect the kernel
version.

Follow-up for c310106c15ea83913e2765dcb0d7c81d83f08a0e

test/test-network/systemd-networkd-tests.py

index cc556793519ee6e16e1481982f086a1e90ba3067..c07fb7a478cd2ca5f13a49c5214319cd3d194dec 100755 (executable)
@@ -245,6 +245,22 @@ def compare_kernel_version(min_kernel_version):
     return version.parse(kver) >= version.parse(min_kernel_version)
 
 
+def networkd_has_sysctl_monitor_bpf():
+    """Check whether systemd-networkd was built with ENABLE_SYSCTL_BPF support."""
+    if not networkd_bin:
+        return False
+    try:
+        output = subprocess.run(
+            [networkd_bin, '--version'],
+            capture_output=True,
+            text=True,
+            check=False,
+        ).stdout
+    except (OSError, subprocess.SubprocessError):
+        return False
+    return '+BTF' in output.split()
+
+
 def copy_network_unit(*units, copy_dropins=True):
     """
     Copy networkd unit files into the testbed.
@@ -11053,6 +11069,10 @@ class NetworkdSysctlTest(unittest.TestCase, Utilities):
         compare_kernel_version('6.12'),
         reason='On kernels <= 6.12, bpf_current_task_under_cgroup() is not available for program types BPF_PROG_TYPE_CGROUP_SYSCTL',
     )
+    @unittest.skipUnless(
+        networkd_has_sysctl_monitor_bpf(),
+        reason='systemd-networkd was built without ENABLE_SYSCTL_BPF support (HAVE_VMLINUX_H=0)',
+    )
     def test_sysctl_monitor(self):
         copy_network_unit('12-dummy.network', '12-dummy.netdev', '12-dummy.link')
         start_networkd()