From e0b5e148352955b0441e2dd134ccab1b8432bd73 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 28 Jul 2025 04:52:37 +0900 Subject: [PATCH] TEST-04-JOURNAL: add test case for log filtering through syslog For issue #38361. --- .../TEST-04-JOURNAL.units/logs-filtering-syslog.py | 14 ++++++++++++++ .../logs-filtering-syslog.service | 8 ++++++++ test/units/TEST-04-JOURNAL.LogFilterPatterns.sh | 1 + 3 files changed, 23 insertions(+) create mode 100755 test/integration-tests/TEST-04-JOURNAL/TEST-04-JOURNAL.units/logs-filtering-syslog.py create mode 100644 test/integration-tests/TEST-04-JOURNAL/TEST-04-JOURNAL.units/logs-filtering-syslog.service diff --git a/test/integration-tests/TEST-04-JOURNAL/TEST-04-JOURNAL.units/logs-filtering-syslog.py b/test/integration-tests/TEST-04-JOURNAL/TEST-04-JOURNAL.units/logs-filtering-syslog.py new file mode 100755 index 00000000000..e1d3ad7c116 --- /dev/null +++ b/test/integration-tests/TEST-04-JOURNAL/TEST-04-JOURNAL.units/logs-filtering-syslog.py @@ -0,0 +1,14 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +import subprocess +import syslog + +if __name__ == '__main__': + syslog.openlog(ident="logs-filtering", logoption=syslog.LOG_PID) + syslog.syslog(syslog.LOG_NOTICE, "Logging from the service, and ~more~ foo bar") + + subprocess.check_output( + ['journalctl', '--sync'], + stdin=subprocess.DEVNULL, + text=True) diff --git a/test/integration-tests/TEST-04-JOURNAL/TEST-04-JOURNAL.units/logs-filtering-syslog.service b/test/integration-tests/TEST-04-JOURNAL/TEST-04-JOURNAL.units/logs-filtering-syslog.service new file mode 100644 index 00000000000..02ace637088 --- /dev/null +++ b/test/integration-tests/TEST-04-JOURNAL/TEST-04-JOURNAL.units/logs-filtering-syslog.service @@ -0,0 +1,8 @@ +[Unit] +Description=Log filtering unit + +[Service] +Type=oneshot +ExecStart=/usr/lib/systemd/tests/testdata/TEST-04-JOURNAL.units/logs-filtering-syslog.py +SyslogLevel=notice +LogLevelMax=info diff --git a/test/units/TEST-04-JOURNAL.LogFilterPatterns.sh b/test/units/TEST-04-JOURNAL.LogFilterPatterns.sh index 16a94bf934e..87c78f0af59 100755 --- a/test/units/TEST-04-JOURNAL.LogFilterPatterns.sh +++ b/test/units/TEST-04-JOURNAL.LogFilterPatterns.sh @@ -119,6 +119,7 @@ test_delegate() { } test_service logs-filtering.service +test_service logs-filtering-syslog.service test_delegate delegated-cgroup-filtering.service systemctl log-level "$SAVED_LOG_LEVEL" -- 2.47.3