public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <petr.vorel@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH]  cgroup_regression_test.sh: fixed test_5
Date: Wed, 5 Dec 2018 19:16:41 +0100	[thread overview]
Message-ID: <20181205181640.GA11567@x230> (raw)
In-Reply-To: <20181121134021.52225-1-cristian.marussi@arm.com>

Hi Cristian,

Thanks for your patch.

...
> Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
> ---
>  .../cgroup/cgroup_regression_test.sh          | 51 +++++++++++++------

...
> +	# Accounting here for the fact that the chosen subsystems could
> +	# have been already previously mounted at boot time: in such a
> +	# case we must skip the initial co-mount step (which would
> +	# fail anyway) and properly re-organize the $tst_mntpoint and
> +	# $failing_subsys params to be used in the following expected-to-fail
> +	# mount action.
> +	already_mounted_subsys=none
Better would be, to be as local (defined at top, I know there are other
variables without local) and empty:
It's a bit long variable name, how about simple mounted (or mounted_subs)?
local mounted

> +	mount | grep cgroup | grep -q $subsys1 && already_mounted_subsys=$subsys1
> +	mount | grep cgroup | grep -q $subsys2 && already_mounted_subsys=$subsys2
> +        if [ "x$already_mounted_subsys" == "xnone" ]; then
'==' is a bashism, use simple '='. When empty as default, then check would be:
if [ -z "$mounted" ]; then

> +		tst_mntpoint=cgroup
> +		failing_subsys=$subsys1
> +		mount -t cgroup -o $subsys1,$subsys2 xxx $tst_mntpoint/
> +		if [ $? -ne 0 ]; then
> +			tst_resm TFAIL "mount $subsys1 and $subsys2 failed"
> +			failed=1
> +			return
> +		fi
> +	else
> +		# Use the pre-esistent mountpoint as $tst_mntpoint and use a
> +		# co-mount with $failing_subsys: this way the 2nd mount will
> +		# also fail (as expected) in this 'mirrored' configuration.
> +		tst_mntpoint=$(mount | grep cgroup | grep $already_mounted_subsys | cut -d ' ' -f 3)
Maybe use awk, when it's used before?
> +		failing_subsys=$subsys1,$subsys2
>  	fi

> -	# This 2nd mount should fail
> -	mount -t cgroup -o $subsys1 xxx cgroup/ 2> /dev/null
> +	# This 2nd mount has been properly configured to fail
> +	mount -t cgroup -o $failing_subsys xxx $tst_mntpoint/ 2> /dev/null
>  	if [ $? -eq 0 ]; then
> -		tst_resm TFAIL "mount $subsys1 should fail"
> -		umount cgroup/
> +		tst_resm TFAIL "mount $failing_subsys should fail"
> +		# Do NOT unmount pre-existent mountpoints...
> +	        [[ "x$already_mounted_subsys" == "xnone" ]] && umount $tst_mntpoint
Also == here, here also with double square brackets, which are also bashism (use
single brackets).


...
>  	check_kernel_bug
>  	if [ $? -eq 1 ]; then
> @@ -296,8 +316,9 @@ test_5()
>  	# clean up
>  	/bin/kill -SIGTERM $! > /dev/null
>  	wait $!
> -	rmdir cgroup/0
> -	umount cgroup/
> +	rmdir $tst_mntpoint/0
> +	# Do NOT unmount pre-existent mountpoints...
> +	[[ "x$already_mounted_subsys" == "xnone" ]] && umount $tst_mntpoint
And the same here.

+ as with many tests, this tests needs rewrite into new API and cleanup.


Kind regards,
Petr

  parent reply	other threads:[~2018-12-05 18:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 13:40 [LTP] [PATCH] cgroup_regression_test.sh: fixed test_5 Cristian Marussi
2018-12-03  8:51 ` Cristian Marussi
2018-12-03 17:43   ` Cristian Marussi
2018-12-05 18:16 ` Petr Vorel [this message]
2018-12-05 18:41   ` Cristian Marussi
2018-12-05 20:28     ` 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=20181205181640.GA11567@x230 \
    --to=petr.vorel@gmail.com \
    --cc=ltp@lists.linux.it \
    /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