From: Yu Watanabe Date: Thu, 5 Dec 2024 23:42:41 +0000 (+0900) Subject: test-network: check status of networkd after everything cleared on tear down X-Git-Tag: v257~9^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=456727b5d4aefa5c5da25985e4c718f9d481c9ff;p=thirdparty%2Fsystemd.git test-network: check status of networkd after everything cleared on tear down Otherwise, if networkd is failed, e.g. .network files that triggered the failure will remain, and the next test case will start with previous .network files. So, most subsequent test will fail. --- diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 1fd1b2290f6..000645c916e 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -929,17 +929,25 @@ def read_networkd_log(invocation_id=None, since=None): def networkd_is_failed(): return call_quiet('systemctl is-failed -q systemd-networkd.service') != 1 -def stop_networkd(show_logs=True): +def stop_networkd(show_logs=True, check_failed=True): global show_journal show_logs = show_logs and show_journal if show_logs: invocation_id = networkd_invocation_id() - check_output('systemctl stop systemd-networkd.socket') - check_output('systemctl stop systemd-networkd.service') + + if check_failed: + check_output('systemctl stop systemd-networkd.socket') + check_output('systemctl stop systemd-networkd.service') + else: + call('systemctl stop systemd-networkd.socket') + call('systemctl stop systemd-networkd.service') + if show_logs: print(read_networkd_log(invocation_id)) + # Check if networkd exits cleanly. - assert not networkd_is_failed() + if check_failed: + assert not networkd_is_failed() def start_networkd(): check_output('systemctl start systemd-networkd') @@ -1024,7 +1032,7 @@ def tear_down_common(): flush_links() # 5. stop networkd - stop_networkd() + stop_networkd(check_failed=False) # 6. remove configs clear_network_units() @@ -1041,6 +1049,9 @@ def tear_down_common(): sys.stdout.flush() check_output('journalctl --sync') + # 9. check the status of networkd + assert not networkd_is_failed() + 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)