]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-04-JOURNAL: add test case for log filtering through syslog
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 27 Jul 2025 19:52:37 +0000 (04:52 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 4 Aug 2025 15:41:22 +0000 (16:41 +0100)
For issue #38361.

(cherry picked from commit e0b5e148352955b0441e2dd134ccab1b8432bd73)

test/integration-tests/TEST-04-JOURNAL/TEST-04-JOURNAL.units/logs-filtering-syslog.py [new file with mode: 0755]
test/integration-tests/TEST-04-JOURNAL/TEST-04-JOURNAL.units/logs-filtering-syslog.service [new file with mode: 0644]
test/units/TEST-04-JOURNAL.LogFilterPatterns.sh

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 (executable)
index 0000000..e1d3ad7
--- /dev/null
@@ -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 (file)
index 0000000..02ace63
--- /dev/null
@@ -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
index 16a94bf934ea7cbf08d3912da2056d6154ca5f3c..87c78f0af590b8d9e8ff66938675a53bf3042c8f 100755 (executable)
@@ -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"