]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: re-enable test_macsec
authorFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 30 Oct 2022 19:27:55 +0000 (20:27 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 30 Oct 2022 19:42:11 +0000 (20:42 +0100)
The outstanding kernel panic should be already fixed in recent enough
kernels by [0]. To make the test safe to run anywhere, let's implement
a simple kernel version check and run the test only if we're running
with at least kernel 6.x. The patch might be in some 5.x kernels as
well, but let's be on the safe side and use 6.x as a baseline here
(which is currently the case for Arch and Fedora Rawhide anyway).

[0] https://lore.kernel.org/netdev/7b3fd03e1a46047e5ffe2a389fe74501f0a93206.1656519221.git.sd@queasysnail.net/T/#u

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

index d599c260707912f2c7181ed302929ed91a8da9ff..2cd7c4b3dc57883db8f96664d5ba7135306afe5a 100755 (executable)
@@ -243,6 +243,21 @@ def expectedFailureIfNetdevsimWithSRIOVIsNotAvailable():
 
     return f
 
+# pylint: disable=C0415
+def compare_kernel_version(min_kernel_version):
+    try:
+        import platform
+        from packaging import version
+    except ImportError:
+        print('Failed to import either platform or packaging module, assuming the comparison failed')
+        return False
+
+    # Get only the actual kernel version without any build/distro/arch stuff
+    # e.g. '5.18.5-200.fc36.x86_64' -> '5.18.5'
+    kver = platform.release().split('-')[0]
+
+    return version.parse(kver) >= version.parse(min_kernel_version)
+
 def udev_reload():
     check_output(*udevadm_cmd, 'control', '--reload')
 
@@ -2051,7 +2066,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         print(output)
         self.assertIn('inet6 2002:da8:1:0:1034:56ff:fe78:9abc/64 scope global dynamic', output)
 
-    @unittest.skip(reason="Causes kernel panic on recent kernels: https://bugzilla.kernel.org/show_bug.cgi?id=208315")
+    @unittest.skipUnless(compare_kernel_version("6"), reason="Causes kernel panic on unpatched kernels: https://bugzilla.kernel.org/show_bug.cgi?id=208315")
     def test_macsec(self):
         copy_network_unit('25-macsec.netdev', '25-macsec.network', '25-macsec.key',
                           '26-macsec.network', '12-dummy.netdev')