#!/bin/bash
## kola:
##   # Check to make sure we are running cgroups v2
##   exclusive: false
##   description: Verify the system supports cgroupsv2.
##   # Abuse creationDate here since we are introducing
##   # the test running on RHCOS and don't want hard failures
##   # there if the test needs to be adjusted.
##   creationDate: 2026-04-16

set -xeuo pipefail

# shellcheck disable=SC1091
. "$KOLA_EXT_DATA/commonlib.sh"

# make sure the system is on cgroups v2
has_cgroup_karg=1
grep -q systemd.unified_cgroup_hierarchy /proc/cmdline || has_cgroup_karg=0
sys_fs_cgroup_source=$(findmnt -no SOURCE /sys/fs/cgroup)
if [ $has_cgroup_karg == 1 ]; then
    fatal "found systemd.unified_cgroup_hierarchy=0"
fi
if [[ $sys_fs_cgroup_source != cgroup2 ]]; then
    fatal "/sys/fs/cgroup is not cgroup2"
fi
