From: Matteo Croce Date: Thu, 22 May 2025 03:41:49 +0000 (+0200) Subject: networkd: print a meaningful error on failure X-Git-Tag: v258-rc1~526 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6288739eaf70f32409626c85c4fde172e8f47e09;p=thirdparty%2Fsystemd.git networkd: print a meaningful error on failure test_keep_configuration_on_restart() works, but the error printed is misleading because self.assertNotEmpty() doesn't exist. Add a working assert statement so, when the unmanaged interface is altered, the test fails with a meaningful error, like: ### ip monitor dev unmanaged0 BEGIN 222:33::/64 proto kernel metric 256 pref medium FAIL [...] Traceback (most recent call last): File "/work/src/test/test-network/systemd-networkd-tests.py", line 5085, in test_keep_configuration_on_restart self.assertEqual(line, '') AssertionError: '222:33::/64 proto kernel metric 256 pref medium' != '' - 222:33::/64 proto kernel metric 256 pref medium While at it, strip the trailing newline so we can print easily the string (and in future build more a robust regexp which uses the $ token) --- diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index cd65c9adaf6..898603d60ca 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -5058,7 +5058,8 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): # Read the `ip monitor` output looking for network changes logfile.seek(0) for line in logfile: - print(line, end="") + line = line.rstrip() + print(line) # Check if a link went down self.assertNotRegex(line, 'dummy98: .* state DOWN') # Check if an address was removed @@ -5077,9 +5078,10 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): # Read the `ip monitor` output looking for network changes logfile_unmanaged.seek(0) for line in logfile_unmanaged: - print(line, end="") + line = line.rstrip() + print(line) # Check if something happened - self.assertNotEmpty(line) + self.assertEqual(line, '') print('### ip monitor dev unmanaged0 END')