]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #22351 from mrc0mmand/TEST-56-cgroupsv1
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 2 Feb 2022 01:02:26 +0000 (10:02 +0900)
committerGitHub <noreply@github.com>
Wed, 2 Feb 2022 01:02:26 +0000 (10:02 +0900)
test: require unified cgroup hierarchy for TEST-56

test/TEST-56-EXIT-TYPE/test.sh
test/test-functions

index 0f84dca1ba66e5a1e4f9a27ce2f0b511a9ccd687..37475e817e1028a67d27cb9bdaec9290bf728203 100755 (executable)
@@ -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 "$@"
index 3ae8caed3fbfbc975450a4af395759352d27f404..d79c52c5911e524fbce64eb8331a291ccfac676a 100644 (file)
@@ -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.