[LTP] [PATCH v3 08/16] controllers: Expand cgroup_lib shell library

Richard Palethorpe rpalethorpe@suse.de
Mon Mar 7 12:39:26 CET 2022


Hello,

>> +
>> +# Mounts and configures the given controller
>> +# USAGE: cgroup_require CONTROLLER
>> +cgroup_require()
>> +{
>> +	local ctrl="$1"
>> +	local exists
>> +
>> +	[ $# -eq 0 ] && tst_brk TBROK "cgroup_require: controller not defined"
>> +
>> +	[ ! -f /proc/cgroups ] && tst_brk TCONF "Kernel does not support
>> control groups"
>
> The tst_cgroup lib can handle this. Also is it guaranteed that
> /proc/cgroups exists if cgroups are enabled?
>
>> +
>> +	exists=$(grep -w $ctrl /proc/cgroups | awk '{ print $4 }')
>> +	[ "$exists" != "1" ] && tst_brk TCONF "cgroup_require:
>> Controller not available or not enabled"
>
> For some reason this fails on my VM where no cgroups are mounted
> already. Also it's redundant because tst_cgroup should handle it.
>
>> +
>> +	_cgroup_state=$(tst_cgctl require "$ctrl" $$)
>> +
>> +	[ "$_cgroup_state" = "" ] && tst_brk TBROK "cgroup_require: No
>state was set after call. Controller '$ctrl' maybe does not exist?"

Perhaps we can just check the return status of tst_cgctl and exit the
script if it is >0?

>> +
>> +	return 0
>>  }


-- 
Thank you,
Richard.


More information about the ltp mailing list