Linux Test Project
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v6 02/10] controllers: Expand cgroup_lib shell library
Date: Wed, 27 Jul 2022 14:20:36 +0200	[thread overview]
Message-ID: <YuEtlIt0JXSbKRm7@pevik> (raw)
In-Reply-To: <b3e568e56f0de2421c2c2fb82968f9fd73c3fcec.1658872195.git.luke.nowakowskikrijger@canonical.com>

Hi Luke,

> v5->v6: Added $ret to capture return code and added return $ret
> 	after tst_brk calls.

>  testcases/kernel/controllers/cgroup_lib.sh | 137 ++++++++++++++++++---
...
> +# Mounts and configures the given controller
> +# USAGE: cgroup_require CONTROLLER
> +cgroup_require()
> +{
> +	local ctrl="$1"
> +	local ret
> +
> +	[ $# -eq 0 ] && tst_brk TBROK "cgroup_require: controller not defined"
> +
> +	[ ! -f /proc/cgroups ] && tst_brk TCONF "Kernel does not support control groups"
> +
> +	_cgroup_state=$(tst_cgctl require "$ctrl" $$)
> +	ret=$?
> +
> +	if [ $ret -eq 32 ]; then
> +		tst_brk TCONF "'tst_cgctl require' exited. Controller is probably not available?"
> +		return $ret
FYI I merged this part as is, but I'd personally avoid using return in TCONF:
1) return value is not anywhere used, thus plain return would be enough.
2) Keeping $? in $ret helps to avoid first TBROK ("'tst_cgctl require' exited") and
second TBROK will not be presented due $_cgroup_state being empty on error (you
print all errors to stderr.
My concern was just not to overwrite $?

Kind regards,
Petr

> +	fi
> +
> +	if [ $ret -ne 0 ]; then
> +		tst_brk TBROK "'tst_cgctl require' exited."
> +		return $ret
> +	fi
> +
> +	[ "$_cgroup_state" = "" ] && tst_brk TBROK "cgroup_require: No state was set after call to tst_cgctl require?"
> +
> +	return 0
>  }

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-07-27 12:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-26 22:13 [LTP] [PATCH v6 00/10] Expand cgroup_lib shell library Luke Nowakowski-Krijger
2022-07-26 22:13 ` [LTP] [PATCH v6 01/10] testcases/lib: Implement tst_cgctl binary Luke Nowakowski-Krijger
2022-07-26 22:13 ` [LTP] [PATCH v6 02/10] controllers: Expand cgroup_lib shell library Luke Nowakowski-Krijger
2022-07-27 12:20   ` Petr Vorel [this message]
2022-07-26 22:13 ` [LTP] [PATCH v6 03/10] controllers: Update cgroup_fj_* to use newer cgroup lib and test lib Luke Nowakowski-Krijger
2022-07-26 22:13 ` [LTP] [PATCH v6 04/10] controllers: Update memcg_control_test to newer test lib and cgroup lib Luke Nowakowski-Krijger
2022-07-26 22:13 ` [LTP] [PATCH v6 05/10] controllers: Update memcg/regression/* to new test " Luke Nowakowski-Krijger
2022-07-26 22:13 ` [LTP] [PATCH v6 06/10] controllers: Update memcg_stress_test to use newer " Luke Nowakowski-Krijger
2022-07-26 22:13 ` [LTP] [PATCH v6 07/10] controllers: update memcg/functional " Luke Nowakowski-Krijger
2022-07-26 22:13 ` [LTP] [PATCH v6 08/10] controllers: Update pids.sh " Luke Nowakowski-Krijger
2022-07-26 22:13 ` [LTP] [PATCH v6 09/10] controllers: update cpuset_regression_test.sh " Luke Nowakowski-Krijger
2022-07-26 22:13 ` [LTP] [PATCH v6 10/10] controllers: update cgroup_regression_test " Luke Nowakowski-Krijger
2022-07-27  6:34 ` [LTP] [PATCH v6 00/10] Expand cgroup_lib shell library Li Wang
2022-07-27 10:14   ` Petr Vorel
2022-07-27 12:13     ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YuEtlIt0JXSbKRm7@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=luke.nowakowskikrijger@canonical.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox