diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2022-02-01 20:18:29 +0100 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2022-02-01 22:13:45 +0100 |
commit | f723740871bd3eb89d16a526a1ff77c04bb3787a (patch) | |
tree | 43787b322620898c5c16dd9d4a6b2c83ba7dd734 /test/test-functions | |
parent | bab29f2ab791f1d0b82c883a0f1bfa16112088f3 (diff) | |
download | systemd-f723740871bd3eb89d16a526a1ff77c04bb3787a.tar.gz |
test: introduce `get_cgroup_hierarchy() helper
which returns the host's cgroup hierarchy (unified, hybrid, or legacy).
Diffstat (limited to 'test/test-functions')
-rw-r--r-- | test/test-functions | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test-functions b/test/test-functions index 3ae8caed3f..d79c52c591 100644 --- a/test/test-functions +++ b/test/test-functions @@ -2010,6 +2010,24 @@ import_initdir() { export initdir } +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 + ;; + *) + dfatal "Failed to determine host's cgroup hierarchy" + exit 1 + esac +} + ## @brief Converts numeric logging level to the first letter of level name. # # @param lvl Numeric logging level in range from 1 to 6. |