]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: show PID and Invocation ID of networkd
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 3 Jun 2024 08:49:26 +0000 (17:49 +0900)
committerLuca Boccassi <bluca@debian.org>
Mon, 3 Jun 2024 17:41:26 +0000 (18:41 +0100)
Then, we can easily find relevant journal entry on failure.
This is especially useful when the test is running with --no-journal.

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

index 64fb5fce13e3b82122275c702aeeb0acce35fa22..a0ca54c7906a1c690b2b20eb4ebbae4f9629fbe5 100755 (executable)
@@ -845,6 +845,9 @@ def radvd_check_config(config_file):
 def networkd_invocation_id():
     return check_output('systemctl show --value -p InvocationID systemd-networkd.service')
 
+def networkd_pid():
+    return check_output('systemctl show --value -p MainPID systemd-networkd.service')
+
 def read_networkd_log(invocation_id=None, since=None):
     if not invocation_id:
         invocation_id = networkd_invocation_id()
@@ -876,6 +879,9 @@ def stop_networkd(show_logs=True):
 
 def start_networkd():
     check_output('systemctl start systemd-networkd')
+    invocation_id = networkd_invocation_id()
+    pid = networkd_pid()
+    print(f'Started systemd-networkd.service: PID={pid}, Invocation ID={invocation_id}')
 
 def restart_networkd(show_logs=True):
     global show_journal
@@ -886,6 +892,10 @@ def restart_networkd(show_logs=True):
     if show_logs:
         print(read_networkd_log(invocation_id))
 
+    invocation_id = networkd_invocation_id()
+    pid = networkd_pid()
+    print(f'Restarted systemd-networkd.service: PID={pid}, Invocation ID={invocation_id}')
+
 def networkd_pid():
     return int(check_output('systemctl show --value -p MainPID systemd-networkd.service'))