summaryrefslogtreecommitdiff
path: root/test/test-network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-08-20 20:35:18 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-08-20 20:35:18 +0900
commit5bd2a7c580e502a6c0a1e0f1279dba4b2008e707 (patch)
tree8befa70419ca43994b10c37744f47111a7e1cbac /test/test-network
parent0f27758ae98f633885b124e79a6df67c4c538aa6 (diff)
downloadsystemd-5bd2a7c580e502a6c0a1e0f1279dba4b2008e707.tar.gz
test-network: add helper functions for reading logs of networkd
Diffstat (limited to 'test/test-network')
-rwxr-xr-xtest/test-network/systemd-networkd-tests.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py
index 3c1b3e0c1c..d6625be9ff 100755
--- a/test/test-network/systemd-networkd-tests.py
+++ b/test/test-network/systemd-networkd-tests.py
@@ -593,23 +593,31 @@ def stop_isc_dhcpd():
stop_by_pid_file(isc_dhcpd_pid_file)
rm_f(isc_dhcpd_lease_file)
+def networkd_invocation_id():
+ return check_output('systemctl show --value -p InvocationID systemd-networkd.service')
+
+def read_networkd_log(invocation_id=None):
+ if not invocation_id:
+ invocation_id = networkd_invocation_id()
+ return check_output('journalctl _SYSTEMD_INVOCATION_ID=' + invocation_id)
+
def stop_networkd(show_logs=True):
if show_logs:
- invocation_id = check_output('systemctl show systemd-networkd.service -p InvocationID --value')
+ invocation_id = networkd_invocation_id()
check_output('systemctl stop systemd-networkd.socket')
check_output('systemctl stop systemd-networkd.service')
if show_logs:
- print(check_output('journalctl _SYSTEMD_INVOCATION_ID=' + invocation_id))
+ print(read_networkd_log(invocation_id))
def start_networkd():
check_output('systemctl start systemd-networkd')
def restart_networkd(show_logs=True):
if show_logs:
- invocation_id = check_output('systemctl show systemd-networkd.service -p InvocationID --value')
+ invocation_id = networkd_invocation_id()
check_output('systemctl restart systemd-networkd.service')
if show_logs:
- print(check_output('journalctl _SYSTEMD_INVOCATION_ID=' + invocation_id))
+ print(read_networkd_log(invocation_id))
def networkd_pid():
return int(check_output('systemctl show --value -p MainPID systemd-networkd.service'))