From: Frantisek Sumsal Date: Sun, 30 Oct 2022 19:27:55 +0000 (+0100) Subject: test-network: re-enable test_macsec X-Git-Tag: v252~10^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b3de9d7bdacdd3219b69bb16e8b326d6393a258d;p=thirdparty%2Fsystemd.git test-network: re-enable test_macsec 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 --- diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index d599c260707..2cd7c4b3dc5 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -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')