From: Frantisek Sumsal Date: Tue, 16 May 2023 17:11:51 +0000 (+0200) Subject: test: introduce get_cgroup_hierarchy() X-Git-Tag: v254-rc1~459^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ff1c6fcde1699637eb328c069ecc693688b4639;p=thirdparty%2Fsystemd.git test: introduce get_cgroup_hierarchy() --- diff --git a/test/units/util.sh b/test/units/util.sh index 00b8c5e3930..4e214251cc6 100755 --- a/test/units/util.sh +++ b/test/units/util.sh @@ -56,3 +56,21 @@ assert_rc() {( rc=$? assert_eq "$rc" "$exp" )} + +get_cgroup_hierarchy() { + case "$(stat -c '%T' -f /sys/fs/cgroup)" in + cgroup2fs) + echo "unified" + ;; + tmpfs) + if [[ -d /sys/fs/cgroup/unified && "$(stat -c '%T' -f /sys/fs/cgroup/unified)" == cgroup2fs ]]; then + echo "hybrid" + else + echo "legacy" + fi + ;; + *) + echo >&2 "Failed to determine host's cgroup hierarchy" + exit 1 + esac +}