]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-04-JOURNAL: Make LogFilterPatterns= tests more robust
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 28 Apr 2024 20:52:59 +0000 (22:52 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 30 Apr 2024 16:17:13 +0000 (18:17 +0200)
Let's use oneshot services as we don't need long running services
for the tests we're doing. Let's also increase the sleeps a little
as the current values weren't sufficient when running the test locally
on my machine with mkosi.

test/testsuite-04.units/delegated-cgroup-filtering.service
test/testsuite-04.units/logs-filtering.service
test/units/delegated_cgroup_filtering_payload.sh
test/units/delegated_cgroup_filtering_payload_child.sh
test/units/testsuite-04.LogFilterPatterns.sh

index 2c4201a27b52edeed28d884d5c761fcada0105b6..a12b12ac4a647264f24c9b5ddee961a286ba0505 100644 (file)
@@ -2,7 +2,7 @@
 Description=Test service for delegated logs filtering
 
 [Service]
-Type=simple
+Type=oneshot
 ExecStart=/usr/lib/systemd/tests/testdata/units/delegated_cgroup_filtering_payload.sh
 Delegate=yes
 SyslogLevel=notice
index 6e2af9a2a148bf9534e2406c0ab3e6267b886aa8..a5aba1859c83fa996e977da83bad46fc0521338e 100644 (file)
@@ -2,5 +2,6 @@
 Description=Log filtering unit
 
 [Service]
-ExecStart=sh -c 'while true; do echo "Logging from the service, and ~more~ foo bar"; sleep .25; done'
+Type=oneshot
+ExecStart=sh -c 'echo "Logging from the service, and ~more~ foo bar" && sleep 2'
 SyslogLevel=notice
index 50d01a5d4aae256c5ba11da65967c689262cf12c..7ad486bcadd205bae8d2bfcabe818aa793773d61 100755 (executable)
@@ -2,11 +2,8 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 
 mkdir /sys/fs/cgroup/system.slice/delegated-cgroup-filtering.service/the_child
-/bin/sh /usr/lib/systemd/tests/testdata/units/delegated_cgroup_filtering_payload_child.sh &
+/bin/sh /usr/lib/systemd/tests/testdata/units/delegated_cgroup_filtering_payload_child.sh
 
-while true
-do
-       echo "parent_process: hello, world!"
-       echo "parent_process: hello, people!"
-    sleep .15
-done
+echo "parent_process: hello, world!"
+echo "parent_process: hello, people!"
+sleep .15
index b5635b58e57224162ac345cadc5d98a0d6f9c2a1..94f0d3acefc2db9121397621f05d47a05d498c8d 100755 (executable)
@@ -3,9 +3,6 @@
 
 echo $$ >/sys/fs/cgroup/system.slice/delegated-cgroup-filtering.service/the_child/cgroup.procs
 
-while true
-do
-       echo "child_process: hello, world!"
-       echo "child_process: hello, people!"
-    sleep .15
-done
+echo "child_process: hello, world!"
+echo "child_process: hello, people!"
+sleep .15
index d5d610fe02a7d187db777eb091a02d580222a7ec..dfa9652ee29ee2008943fe1ff8cd000cdcca5d4c 100755 (executable)
@@ -18,16 +18,12 @@ add_logs_filtering_override() {
 
 run_service_and_fetch_logs() {
     local unit="${1:?}"
-    local start end
+    local start
 
     start="$(date '+%Y-%m-%d %T.%6N')"
-    systemctl restart "$unit"
-    sleep .5
+    systemctl start "$unit"
     journalctl --sync
-    end="$(date '+%Y-%m-%d %T.%6N')"
-
-    journalctl -q -u "$unit" -S "$start" -U "$end" -p notice
-    systemctl stop "$unit"
+    journalctl -q -u "$unit" -S "$start" -p notice
 }
 
 if cgroupfs_supports_user_xattrs; then