def test(config):
    result = consts.TEST_PASSED
    cause = None

    mount_list = Cgroup.get_cgroup_mounts(config, expand_v2_mounts=True)

    # cgroup v2 mounts won't show up unless '-a' is specified
    lssubsys_list = Cgroup.lssubsys(config, ls_all=True)

    for mount in mount_list:
        if mount.controller == 'name=systemd' or mount.controller == 'systemd':
            continue

        found = False
        for lsmount in lssubsys_list.splitlines():
            if ',' in lsmount:
                for ctrl in lsmount.split(','):
                    if ctrl == mount.controller:
                        found = True
                        break

            if lsmount == mount.controller:
                found = True
                break

            if lsmount == 'blkio' and mount.controller == 'io':
                found = True
                break

        if not found:
            result = consts.TEST_FAILED
            cause = ('Failed to find {} in lssubsys list'
                     ''.format(mount.controller))
            return result, cause

    ret = Cgroup.lssubsys(config, cghelp=True)
    if 'Usage:' not in ret:
        result = consts.TEST_FAILED
        cause = 'Failed to print help text'
        return result, cause

    return result, cause
def prereqs(config):
    result = consts.TEST_PASSED
    cause = None

    v2_cnt = 0
    mount_list = Cgroup.get_cgroup_mounts(config)

    for mount in mount_list:
        if mount.version == CgroupVersion.CGROUP_V2:
            v2_cnt += 1

    if v2_cnt > 1:
        # There is a bug in lscgroup - see issue #50 - where it doesn't
        # properly list the enabled controllers for a cgroup v2 cgroup.
        # Skip this test because of this
        result = consts.TEST_SKIPPED
        cause = 'See Github Issue #50 - lscgroup lists controllers...'
        return result, cause

    return result, cause