]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/TEST-19-DELEGATE/testsuite.sh
fdfab950b125ee1889e19a4621eb5078e3213ca2
[thirdparty/systemd.git] / test / TEST-19-DELEGATE / testsuite.sh
1 #!/bin/bash
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4 set -ex
5 set -o pipefail
6
7 if grep -q cgroup2 /proc/filesystems ; then
8 systemd-run --wait --unit=test0.service -p "DynamicUser=1" -p "Delegate=" \
9 test -w /sys/fs/cgroup/system.slice/test0.service/ -a \
10 -w /sys/fs/cgroup/system.slice/test0.service/cgroup.procs -a \
11 -w /sys/fs/cgroup/system.slice/test0.service/cgroup.subtree_control
12
13 systemd-run --wait --unit=test1.service -p "DynamicUser=1" -p "Delegate=memory pids" \
14 grep -q memory /sys/fs/cgroup/system.slice/test1.service/cgroup.controllers
15
16 systemd-run --wait --unit=test2.service -p "DynamicUser=1" -p "Delegate=memory pids" \
17 grep -q pids /sys/fs/cgroup/system.slice/test2.service/cgroup.controllers
18
19 # "io" is not among the controllers enabled by default for all units, verify that
20 grep -qv io /sys/fs/cgroup/system.slice/cgroup.controllers
21
22 # Run a service with "io" enabled, and verify it works
23 systemd-run --wait --unit=test3.service -p "IOAccounting=yes" -p "Slice=system-foo-bar-baz.slice" \
24 grep -q io /sys/fs/cgroup/system.slice/system-foo.slice/system-foo-bar.slice/system-foo-bar-baz.slice/test3.service/cgroup.controllers
25
26 # We want to check if "io" is removed again from the controllers
27 # list. However, PID 1 (rightfully) does this asynchronously. In order
28 # to force synchronization on this, let's start a short-lived service
29 # which requires PID 1 to refresh the cgroup tree, so that we can
30 # verify that this all works.
31 systemd-run --wait --unit=test4.service true
32
33 # And now check again, "io" should have vanished
34 grep -qv io /sys/fs/cgroup/system.slice/cgroup.controllers
35 else
36 echo "Skipping TEST-19-DELEGATE, as the kernel doesn't actually support cgroup v2" >&2
37 fi
38
39 echo OK > /testok
40
41 exit 0