]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: flush stream buffer and journals before/after running test
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 3 Jun 2024 08:43:43 +0000 (17:43 +0900)
committerLuca Boccassi <bluca@debian.org>
Mon, 3 Jun 2024 17:41:26 +0000 (18:41 +0100)
test/test-network/systemd-networkd-tests.py

index b294621de9889123abdfb618104ae7a43bfb5d23..64fb5fce13e3b82122275c702aeeb0acce35fa22 100755 (executable)
@@ -923,7 +923,11 @@ def udevadm_trigger(*args, action='add'):
     udevadm('trigger', '--settle', f'--action={action}', *args)
 
 def setup_common():
+    # We usually show something in each test. So, let's break line to make the title of a test and output
+    # from the test mixed. Then, flush stream buffer and journals.
     print()
+    sys.stdout.flush()
+    check_output('journalctl --sync')
 
 def tear_down_common():
     # 1. stop DHCP/RA servers
@@ -956,6 +960,10 @@ def tear_down_common():
     flush_routing_policy_rules()
     flush_routes()
 
+    # 8. flush stream buffer and journals to make not any output from the test with the next one
+    sys.stdout.flush()
+    check_output('journalctl --sync')
+
 def setUpModule():
     rm_rf(networkd_ci_temp_dir)
     cp_r(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'conf'), networkd_ci_temp_dir)
@@ -989,6 +997,10 @@ def tearDownModule():
     clear_system_units()
     restore_active_units()
 
+    # Flush stream buffer and journals before showing the test summary.
+    sys.stdout.flush()
+    check_output('journalctl --sync')
+
 class Utilities():
     # pylint: disable=no-member