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
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
# 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
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
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