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

Luke Nowakowski-Krijger luke.nowakowskikrijger@canonical.com
Wed Mar 16 22:46:32 CET 2022


Hi Richard and Li,

On Wed, Mar 16, 2022 at 2:46 AM Li Wang <liwang@redhat.com> wrote:

> Richard Palethorpe <rpalethorpe@suse.de> wrote:
>
>
>
>> >> +
>> >> +    _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?
>>
>
> That should be work, but we need to check the _cgrou_state
> at other places because many shell APIs require getting Cgroup
> info, I guess this does not make things more easily if check the
> return value only one time.
>
>
>
An idea I had to make the failure of tst_cgctl more graceful when there is
a tst_brk and when it exits is to check the return of tst_cgctl and
basically just mirror the error with a better message. E.g.

tst_cgroup.c:702: TCONF: IO controller found on V2 root, skipping blkio
mount that would unmount IO controller
cgroup_fj_function 1 TCONF: cgroup_require: tst_cgtl require exited

Something that would look like this:
_cgroup_state=$(tst_cgctl require "$ctrl" $$)

_cgroup_check_return "$?" "cgroup_require: tst_cgctl require exited"

[ "$_cgroup_state" = "" ] && tst_brk TBROK "cgroup_require: No state was
set after call to tst_cgctl require?"

Where in _cgroup_check_return we would do the appropriate tst_brk for the
return and then return a nice message (not exactly sure what it should be
but it should be obvious that one error is caused by the other). Because if
there was an error in tst_cgroup we would definitely want to break the test
because the _cgroup_state was most likely not set. Then it would fall
through to checking the _cgroup_state if everything looked good per normal
which now should never happen if tst_cgctl returned a non error.

Let me know what you think :)

-- 
> Regards,
> Li Wang
>

Thanks,
- Luke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20220316/43501d18/attachment-0001.htm>


More information about the ltp mailing list