common/cgroup2: better error message if cgroup2 fs is not mounted
authorChristoph Hellwig <hch@lst.de>
Mon, 15 Jul 2019 08:25:21 +0000 (10:25 +0200)
committerEryu Guan <guaneryu@gmail.com>
Sun, 21 Jul 2019 13:27:30 +0000 (21:27 +0800)
Improve the _require_cgroup2 helper to print a more useful message
if the cgroup2 fs is not mounted.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/cgroup2

index f89825e2c0157dcd04dc040c9e6289cf3c246c7a..8833c9c83f949a47abb4239254236821b1b9d586 100644 (file)
@@ -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