]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/TEST-19-DELEGATE/testsuite.sh
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / test / TEST-19-DELEGATE / testsuite.sh
CommitLineData
b961baf1
LP
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
4set -ex
5set -o pipefail
6
dd202b88
LP
7if 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
b961baf1 12
dd202b88 13 systemd-run --wait --unit=test1.service -p "DynamicUser=1" -p "Delegate=memory pids" \
43738e00 14 grep -q memory /sys/fs/cgroup/system.slice/test1.service/cgroup.controllers
b961baf1 15
dd202b88 16 systemd-run --wait --unit=test2.service -p "DynamicUser=1" -p "Delegate=memory pids" \
43738e00
LP
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
dd202b88 35else
4e1dfa45 36 echo "Skipping TEST-19-DELEGATE, as the kernel doesn't actually support cgroup v2" >&2
dd202b88 37fi
b961baf1
LP
38
39echo OK > /testok
40
41exit 0