From: Michal Koutný Date: Fri, 4 Oct 2024 18:40:51 +0000 (+0200) Subject: test: Add test for per-device cgroup properties X-Git-Tag: v257-rc1~313^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F34408%2Fhead;p=thirdparty%2Fsystemd.git test: Add test for per-device cgroup properties Reported in #34126 --- diff --git a/test/units/TEST-19-CGROUP.keyed-properties.sh b/test/units/TEST-19-CGROUP.keyed-properties.sh new file mode 100755 index 00000000000..cadefe26d5f --- /dev/null +++ b/test/units/TEST-19-CGROUP.keyed-properties.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -ex +set -o pipefail + +# shellcheck source=test/units/test-control.sh +. "$(dirname "$0")"/test-control.sh +# shellcheck source=test/units/util.sh +. "$(dirname "$0")"/util.sh + +if [[ "$(get_cgroup_hierarchy)" != unified ]]; then + echo "Skipping $0 as we're not running with the unified cgroup hierarchy" + exit 0 +fi + +testcase_iodevice_dbus () { + # Test that per-device properties are applied in configured order even for different devices (because + # they may resolve to same underlying device in the end + # Note: if device does not exist cgroup attribute write fails but systemd should still track the + # configured properties + systemd-run --unit=test0.service \ + --property="IOAccounting=yes" \ + sleep inf + + systemctl set-property test0.service \ + IOReadBandwidthMax="/dev/sda1 1M" \ + IOReadBandwidthMax="/dev/sda2 2M" \ + IOReadBandwidthMax="/dev/sda3 4M" + + local output + output=$(mktemp) + trap 'rm -f "$output"' RETURN + systemctl show -P IOReadBandwidthMax test0.service >"$output" + diff -u "$output" - </run/systemd/system/test1.service <"$output" + diff -u "$output" - <