From e678a7cc9ca62a9daf45eb3e77fd066a05c32dba Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 15 Jul 2019 10:25:21 +0200 Subject: [PATCH] common/cgroup2: better error message if cgroup2 fs is not mounted Improve the _require_cgroup2 helper to print a more useful message if the cgroup2 fs is not mounted. Signed-off-by: Christoph Hellwig Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- common/cgroup2 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/cgroup2 b/common/cgroup2 index f89825e2c..8833c9c83 100644 --- a/common/cgroup2 +++ b/common/cgroup2 @@ -4,9 +4,14 @@ export CGROUP2_PATH="${CGROUP2_PATH:-/sys/fs/cgroup}" _require_cgroup2() { + if [ `findmnt -d backward -n -o FSTYPE -f ${CGROUP2_PATH}` != "cgroup2" ]; then + _notrun "cgroup2 not mounted on ${CGROUP2_PATH}" + fi + if [ ! -f "${CGROUP2_PATH}/cgroup.subtree_control" ]; then _notrun "Test requires cgroup2 enabled" fi + if [[ ! $(cat ${CGROUP2_PATH}/cgroup.controllers) =~ $1 ]]; then _notrun "Cgroup2 doesn't support $1 controller $1" fi -- 2.51.0