public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Eryu Guan <eguan@redhat.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	linux-unionfs@vger.kernel.org, fstests@vger.kernel.org
Subject: Re: [PATCH v3 1/5] fstests: implement require of multiple overlayfs features
Date: Mon, 29 Jan 2018 22:33:07 +0800	[thread overview]
Message-ID: <20180129143307.GV18267@eguan.usersys.redhat.com> (raw)
In-Reply-To: <1517131356-8048-2-git-send-email-amir73il@gmail.com>

On Sun, Jan 28, 2018 at 11:22:32AM +0200, Amir Goldstein wrote:
> Some overlayfs features must be checked together, because they cannot
> be enabled without a dependent feature (e.g. nfs_export and index).
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  common/overlay | 23 ++++++++++++++++++++---
>  common/rc      | 15 +++++++++------
>  2 files changed, 29 insertions(+), 9 deletions(-)
> 
> diff --git a/common/overlay b/common/overlay
> index 1da4ab1..38fe994 100644
> --- a/common/overlay
> +++ b/common/overlay
> @@ -138,9 +138,6 @@ _require_scratch_overlay_feature()
>  	[ "$default" = Y ] || [ "$default" = N ] || \
>  		_notrun "feature '${feature}' not supported by ${FSTYP}"
>  
> -	_scratch_mkfs > /dev/null 2>&1
> -	_scratch_mount -o ${feature}=on || \
> -		_notrun "${FSTYP} feature '${feature}' cannot be enabled on ${SCRATCH_DEV}"

So _require_scratch_overlay_feature can't be used by any test directly
now and should only be called by _require_scratch_overlay_features.

IMHO, the name _require_scratch_overlay_feature becomes misleading after
this change, it implies it can be called by tests directly. I'd rename
it to a more proper name (which I can't think of any..) with double
underscores at the beginning to imply it's kind of "static", e.g. the
internal helpers like "__populate_create_dir" in common/populate.

Another way to go is just open-code this in
_require_scratch_overlay_features().

>  	# Check options to be sure. For example, Overlayfs will fallback to
>  	# index=off if underlying fs does not support file handles.
>  	# Overlayfs only displays mount option if it differs from the default.
> @@ -149,5 +146,25 @@ _require_scratch_overlay_feature()
>  	  ( [ "$default" = Y ] && ! _fs_options $SCRATCH_DEV | grep -q "${feature}=off" )) && \
>  	    touch $SCRATCH_MNT/foo 2>/dev/null ) || \
>  	        _notrun "${FSTYP} feature '${feature}' cannot be enabled on ${SCRATCH_DEV}"
> +}
> +
> +# Require a set of overlayfs features
> +_require_scratch_overlay_features()
> +{
> +	local features=( $* )
> +	local opts="rw"
> +
> +	for feature in ${features[*]}; do
> +		opts+=",${feature}=on"
> +	done
> +
> +	_scratch_mkfs > /dev/null 2>&1
> +	_scratch_mount -o $opts || \
> +		_notrun "overlay options '$opts' cannot be enabled on ${SCRATCH_DEV}"
> +
> +	for feature in ${features[*]}; do
> +		_require_scratch_overlay_feature ${feature}
> +	done
> +
>  	_scratch_unmount
>  }
> diff --git a/common/rc b/common/rc
> index 77a4eb4..3b81061 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -3658,22 +3658,25 @@ _get_fs_sysfs_attr()
>  	cat /sys/fs/${FSTYP}/${dname}/${attr}
>  }
>  
> -# Generic test for specific filesystem feature.
> +# Generic test for specific filesystem features.
>  # Currently only implemented to test overlayfs features.
> -_require_scratch_feature()
> +_require_scratch_features()
>  {
> -	local feature=$1
> -
>  	case "$FSTYP" in
>  	overlay)
> -		_require_scratch_overlay_feature ${feature}
> +		_require_scratch_overlay_features $*
>  		;;
>  	*)
> -		_fail "Test for feature '${feature}' of ${FSTYP} is not implemented"
> +		_fail "Test for features '$*' of ${FSTYP} is not implemented"
>  		;;
>  	esac
>  }
>  
> +_require_scratch_feature()
> +{
> +	_require_scratch_features $1
> +}
> +

Hmm, I don't think this is necessary. Just drop all the plural variants
and teach _require_scratch_overlay_feature to accept & test multiple
features, and add some good comments.

Thanks,
Eryu

>  init_rc
>  
>  ################################################################################
> -- 
> 2.7.4
> 

  reply	other threads:[~2018-01-29 14:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-28  9:22 [PATCH v3 0/5] Overlayfs exportfs tests Amir Goldstein
2018-01-28  9:22 ` [PATCH v3 1/5] fstests: implement require of multiple overlayfs features Amir Goldstein
2018-01-29 14:33   ` Eryu Guan [this message]
2018-01-29 17:06     ` Amir Goldstein
2018-01-30  4:52       ` Eryu Guan
2018-01-28  9:22 ` [PATCH v3 2/5] overlay: test encode/decode overlay file handles Amir Goldstein
2018-01-29 14:39   ` Eryu Guan
2018-01-29 17:23     ` Amir Goldstein
2018-01-30  4:54       ` Eryu Guan
2018-01-28  9:22 ` [PATCH v3 3/5] overlay: test encode/decode of non-samefs " Amir Goldstein
2018-01-28  9:22 ` [PATCH v3 4/5] overlay: test encode/decode overlay file handles with renames Amir Goldstein
2018-01-28  9:22 ` [PATCH v3 5/5] overlay: test encode/decode of non-samefs " Amir Goldstein
2018-01-28 10:59 ` [PATCH v3 0/5] Overlayfs exportfs tests Eryu Guan

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=20180129143307.GV18267@eguan.usersys.redhat.com \
    --to=eguan@redhat.com \
    --cc=amir73il@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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