From f723740871bd3eb89d16a526a1ff77c04bb3787a Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Tue, 1 Feb 2022 20:18:29 +0100 Subject: [PATCH 1/2] test: introduce `get_cgroup_hierarchy() helper which returns the host's cgroup hierarchy (unified, hybrid, or legacy). --- test/test-functions | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test-functions b/test/test-functions index 3ae8caed3fb..d79c52c5911 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. From e2620820188428de7086f5e8ac41305177f70954 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Tue, 1 Feb 2022 20:25:00 +0100 Subject: [PATCH 2/2] test: require unified cgroup hierarchy for TEST-56 since cgroup empty notifications are unreliable in legacy cgroups. See: systemd/systemd#22320 Complements: systemd/systemd#22344 --- test/TEST-56-EXIT-TYPE/test.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/TEST-56-EXIT-TYPE/test.sh b/test/TEST-56-EXIT-TYPE/test.sh index 0f84dca1ba6..37475e817e1 100755 --- a/test/TEST-56-EXIT-TYPE/test.sh +++ b/test/TEST-56-EXIT-TYPE/test.sh @@ -6,4 +6,9 @@ TEST_DESCRIPTION="test ExitType=cgroup" # shellcheck source=test/test-functions . "${TEST_BASE_DIR:?}/test-functions" +if [[ "$(get_cgroup_hierarchy)" != unified ]]; then + echo "This test requires unified cgroup hierarchy, skipping..." + exit 0 +fi + do_test "$@"