Re: [PATCH 2/2] Configure custom layers via environment variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 15, 2020 at 03:01:34PM +0300, Amir Goldstein wrote:
> The following environment variables are supported:
> 
>  UNIONMOUNT_BASEDIR  - base dir for --samefs (default: /base)
>  UNIONMOUNT_UPPERDIR - upper layer root path (default: /upper)
>  UNIONMOUNT_LOWERDIR - lower layer root path (default: /lower)
>  UNIONMOUNT_MNTPOINT - mount point for tests (default: /mnt)
> 
> User provided paths for base/lower/upper should point at a pre-mounted
> filesystem, whereas tmpfs instances will be created on default paths.
> 
> This is going to be used for running unionmount tests from xfstests.

Hi Amir,

I don't understand this testsuite code. So I will ask.

What's base dir?

So these options will allow me to specify lower directory, upper directory
and overlay mount point. User can specify these and testsuite will
mount overlay accordingly?

What about overlay mount options. Should there be one option for that too.

Assuming workdir is automatically determined.

Vivek

> 
> Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
> ---
>  README      | 11 +++++++++++
>  run         |  3 ++-
>  settings.py | 51 ++++++++++++++++++++++++++++++---------------------
>  3 files changed, 43 insertions(+), 22 deletions(-)
> 
> diff --git a/README b/README
> index c352878..616135f 100644
> --- a/README
> +++ b/README
> @@ -47,5 +47,16 @@ To run these tests:
>  	./run --ov --fuse=<subfs-type>
>  
>  
> +The following environment variables are supported:
> +
> +     UNIONMOUNT_BASEDIR  - base dir for --samefs (default: /base)
> +     UNIONMOUNT_UPPERDIR - upper layer root path (default: /upper)
> +     UNIONMOUNT_LOWERDIR - lower layer root path (default: /lower)
> +     UNIONMOUNT_MNTPOINT - mount point for tests (default: /mnt)
> +
> +     User provided paths for base/lower/upper should point at a pre-mounted
> +     filesystem, whereas tmpfs instances will be created on default paths.
> +
> +
>  For more advanced overlayfs test options and more examples, see:
>       https://github.com/amir73il/overlayfs/wiki/Overlayfs-testing
> diff --git a/run b/run
> index e6262b8..60d5d0d 100755
> --- a/run
> +++ b/run
> @@ -20,10 +20,11 @@ def show_format(why):
>      print("\t", sys.argv[0], "--<fsop> <file> [<args>*] [-aLlv] [-R <content>] [-B] [-E <err>]")
>      sys.exit(2)
>  
> +cfg = config(sys.argv[0])
> +
>  if len(sys.argv) < 2:
>      show_format("Insufficient arguments")
>  
> -cfg = config(sys.argv[0])
>  args = sys.argv[1:]
>  
>  ###############################################################################
> diff --git a/settings.py b/settings.py
> index ced9cae..f065494 100644
> --- a/settings.py
> +++ b/settings.py
> @@ -20,15 +20,27 @@ along with this program; if not, write to the Free Software
>  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
>  """
>  
> +import os
> +
>  class config:
>      def __init__(self, progname):
>          self.__progname = progname
>          self.__testing_overlayfs = False
>          self.__testing_none = False
> -        self.__base_mntroot = None
> -        self.__lower_mntroot = None
> -        self.__upper_mntroot = None
> -        self.__union_mntroot = None
> +        self.__base_mntroot = os.getenv('UNIONMOUNT_BASEDIR')
> +        self.__lower_mntroot = os.getenv('UNIONMOUNT_LOWERDIR')
> +        self.__upper_mntroot = os.getenv('UNIONMOUNT_UPPERDIR')
> +        self.__union_mntroot = os.getenv('UNIONMOUNT_MNTPOINT')
> +        print("Environment variables:")
> +        if self.__base_mntroot:
> +            print("UNIONMOUNT_BASEDIR=" + self.__base_mntroot)
> +        if self.__lower_mntroot:
> +            print("UNIONMOUNT_LOWERDIR=" + self.__lower_mntroot)
> +        if self.__upper_mntroot:
> +            print("UNIONMOUNT_UPPERDIR=" + self.__upper_mntroot)
> +        if self.__union_mntroot:
> +            print("UNIONMOUNT_MNTPOINT=" + self.__union_mntroot)
> +        print()
>          self.__verbose = False
>          self.__verify = False
>          self.__maxfs = 0
> @@ -50,49 +62,46 @@ class config:
>          return self.__testing_overlayfs
>  
>      def set_testing_none(self):
> -        self.__lower_mntroot = "/lower"
> -        self.__union_mntroot = "/mnt"
>          self.__testing_none = True
>  
>      def set_testing_overlayfs(self):
> -        self.__base_mntroot = "/base"
> -        self.__lower_mntroot = "/lower"
> -        self.__upper_mntroot = "/upper"
> -        self.__union_mntroot = "/mnt"
>          self.__testing_overlayfs = True
>  
>      # base dir is mounted only for --ov --samefs
> +    # A user provided base dir should already be mounted
>      def should_mount_base(self):
> -        return self.testing_overlayfs() and self.is_samefs()
> +        return self.__base_mntroot is None and self.testing_overlayfs() and self.is_samefs()
>      def base_mntroot(self):
> -        return self.__base_mntroot
> +        return self.__base_mntroot or "/base"
>      # lower dir is mounted ro for --ov (without --samefs) ...
>      def should_mount_lower_ro(self):
> -        return self.testing_overlayfs() and not self.is_samefs()
> +        return self.__lower_mntroot is None and self.testing_overlayfs() and not self.is_samefs()
>      # ... and mounted rw for --no
> +    # A user provided lower dir should already be mounted
>      def should_mount_lower_rw(self):
> -        return self.testing_none()
> +        return self.__lower_mntroot is None and self.testing_none()
>      def should_mount_lower(self):
>          return self.should_mount_lower_ro() or self.should_mount_lower_rw()
>      def set_lower_mntroot(self, path):
>          self.__lower_mntroot = path
>      def lower_mntroot(self):
> -        return self.__lower_mntroot
> +        return self.__lower_mntroot or "/lower"
>      # upper dir is mounted for --ov (without --samefs)
> +    # A user provided upper dir should already be mounted
>      def should_mount_upper(self):
> -        return self.testing_overlayfs() and not self.is_samefs()
> +        return self.__upper_mntroot is None and self.testing_overlayfs() and not self.is_samefs()
>      def set_upper_mntroot(self, path):
>          self.__upper_mntroot = path
>      def upper_mntroot(self):
> -        return self.__upper_mntroot
> +        return self.__upper_mntroot or "/upper"
>      def union_mntroot(self):
> -        return self.__union_mntroot
> +        return self.__union_mntroot or "/mnt"
>      def lowerdir(self):
> -        return self.__lower_mntroot + "/a"
> +        return self.lower_mntroot() + "/a"
>      def lowerimg(self):
> -        return self.__lower_mntroot + "/a.img"
> +        return self.lower_mntroot() + "/a.img"
>      def testdir(self):
> -        return self.__union_mntroot + "/a"
> +        return self.union_mntroot() + "/a"
>  
>      def set_verbose(self, to=True):
>          self.__verbose = to
> -- 
> 2.17.1
> 




[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux