All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Make ./new work for non-root user
@ 2018-05-24 18:30 Jan Kara
  2018-05-25  1:30 ` Dave Chinner
  2018-05-29  1:39 ` Dave Chinner
  0 siblings, 2 replies; 7+ messages in thread
From: Jan Kara @ 2018-05-24 18:30 UTC (permalink / raw)
  To: fstests; +Cc: Jan Kara

Currently 'new' script sources common/config which tries to find mkfs
and fails if not found (which is likely for non-root user). This is
inconvenient as development usually does not happen as root. In fact the
vast majority of setup in common/config and common/rc is not necessary
for 'new'. Split out the necessary bits into new common/config-base and
use it in 'new'. Cleanup common/rc and common/config now that it's only
used from 'check'.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 check              | 16 +++++-----------
 common/config      | 16 ++--------------
 common/config-base | 21 +++++++++++++++++++++
 common/rc          | 27 ++-------------------------
 new                |  2 +-
 5 files changed, 31 insertions(+), 51 deletions(-)
 create mode 100644 common/config-base

diff --git a/check b/check
index 96198ac4714e..4c6e8285bc16 100755
--- a/check
+++ b/check
@@ -331,10 +331,11 @@ while [ $# -gt 0 ]; do
 	shift
 done
 
-# we need common/config, source it after processing args, overlay needs FSTYP
-# set before sourcing common/config
-if ! . ./common/config; then
-	echo "$iam: failed to source common/config"
+# we need common/rc, that also sources common/config. We need to source it
+# after processing args, overlay needs FSTYP set before sourcing common/config
+if ! . ./common/rc
+then
+	echo "check: failed to source common/rc"
 	exit 1
 fi
 
@@ -374,13 +375,6 @@ elif [ -z "$GROUP_LIST" ]; then
 	GROUP_LIST="auto"
 fi
 
-# we need common/rc
-if ! . ./common/rc
-then
-    echo "check: failed to source common/rc"
-    exit 1
-fi
-
 if [ `id -u` -ne 0 ]
 then
     echo "check: QA must be run as root"
diff --git a/common/config b/common/config
index af360cefc804..fa07a6799824 100644
--- a/common/config
+++ b/common/config
@@ -47,6 +47,8 @@
 #   validity or mountedness.
 #
 
+. common/config-base
+
 # all tests should use a common language setting to prevent golden
 # output mismatches.
 export LANG=C
@@ -88,12 +90,6 @@ export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
 
 export RECREATE_TEST_DEV=false
 
-# $1 = prog to look for
-set_prog_path()
-{
-	type -P $1
-}
-
 # Handle mkfs.$fstyp which does (or does not) require -f to overwrite
 set_mkfs_prog_path_with_opts()
 {
@@ -132,9 +128,6 @@ export FSSTRESS_PROG="./ltp/fsstress"
 export PERL_PROG="`set_prog_path perl`"
 [ "$PERL_PROG" = "" ] && _fatal "perl not found"
 
-export AWK_PROG="`set_prog_path awk`"
-[ "$AWK_PROG" = "" ] && _fatal "awk not found"
-
 export SED_PROG="`set_prog_path sed`"
 [ "$SED_PROG" = "" ] && _fatal "sed not found"
 
@@ -271,11 +264,6 @@ fi
 rm -f /tmp/crc_check.img
 export XFS_MKFS_HAS_NO_META_SUPPORT
 
-# new doesn't need config file parsed, we can stop here
-if [ "$iam" == "new" ]; then
-	return 0
-fi
-
 _mount_opts()
 {
 	case $FSTYP in
diff --git a/common/config-base b/common/config-base
new file mode 100644
index 000000000000..5d8a858160af
--- /dev/null
+++ b/common/config-base
@@ -0,0 +1,21 @@
+##/bin/bash
+
+# Valid test names start with 3 digits "NNN":
+#  "[0-9]\{3\}"
+# followed by an optional "-":
+#  "-\?"
+# followed by an optional combination of alphanumeric and "-" chars:
+#  "[[:alnum:]-]*"
+# e.g. 999-the-mark-of-fstests
+#
+VALID_TEST_ID="[0-9]\{3\}"
+VALID_TEST_NAME="$VALID_TEST_ID-\?[[:alnum:]-]*"
+
+# $1 = prog to look for
+set_prog_path()
+{
+	type -P $1
+}
+
+export AWK_PROG="`set_prog_path awk`"
+[ "$AWK_PROG" = "" ] && _fatal "awk not found"
diff --git a/common/rc b/common/rc
index ffe5323603eb..7368e2e12988 100644
--- a/common/rc
+++ b/common/rc
@@ -20,18 +20,9 @@
 #  Mountain View, CA 94043, USA, or: http://www.sgi.com
 #-----------------------------------------------------------------------
 
-BC=$(which bc 2> /dev/null) || BC=
+. common/config
 
-# Valid test names start with 3 digits "NNN":
-#  "[0-9]\{3\}"
-# followed by an optional "-":
-#  "-\?"
-# followed by an optional combination of alphanumeric and "-" chars:
-#  "[[:alnum:]-]*"
-# e.g. 999-the-mark-of-fstests
-#
-VALID_TEST_ID="[0-9]\{3\}"
-VALID_TEST_NAME="$VALID_TEST_ID-\?[[:alnum:]-]*"
+BC=$(which bc 2> /dev/null) || BC=
 
 # Some tests are not relevant or functional when testing XFS realtime
 # subvolumes along with the rtinherit=1 mkfs option.  In these cases,
@@ -110,16 +101,6 @@ _ls_l()
 	ls -l $* | sed "s/\(^[-rwxdlbcpsStT]*\)\. /\1 /" | grep -v 'lost+found'
 }
 
-# we need common/config
-if [ "$iam" != "check" ]
-then
-    if ! . ./common/config
-        then
-        echo "$iam: failed to source common/config"
-        exit 1
-    fi
-fi
-
 _dump_err()
 {
     _err_msg="$*"
@@ -3560,10 +3541,6 @@ _disable_dmesg_check()
 
 init_rc()
 {
-	if [ "$iam" == new ]
-	then
-		return
-	fi
 	# make some further configuration checks here
 	if [ "$TEST_DEV" = ""  ]
 	then
diff --git a/new b/new
index 4eacccd3bf8b..2b322b2fdfb3 100755
--- a/new
+++ b/new
@@ -23,7 +23,7 @@
 
 # generic initialization
 iam=new
-. ./common/rc
+. ./common/config-base
 
 trap "rm -f /tmp/$$.; exit" 0 1 2 3 15
 
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] Make ./new work for non-root user
  2018-05-24 18:30 [PATCH] Make ./new work for non-root user Jan Kara
@ 2018-05-25  1:30 ` Dave Chinner
  2018-05-28  9:37   ` Jan Kara
  2018-05-29  1:39 ` Dave Chinner
  1 sibling, 1 reply; 7+ messages in thread
From: Dave Chinner @ 2018-05-25  1:30 UTC (permalink / raw)
  To: Jan Kara; +Cc: fstests

On Thu, May 24, 2018 at 08:30:55PM +0200, Jan Kara wrote:
> Currently 'new' script sources common/config which tries to find mkfs
> and fails if not found (which is likely for non-root user). This is
> inconvenient as development usually does not happen as root. In fact the
> vast majority of setup in common/config and common/rc is not necessary
> for 'new'. Split out the necessary bits into new common/config-base and
> use it in 'new'. Cleanup common/rc and common/config now that it's only
> used from 'check'.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>
....
> --- a/common/rc
> +++ b/common/rc
> @@ -20,18 +20,9 @@
>  #  Mountain View, CA 94043, USA, or: http://www.sgi.com
>  #-----------------------------------------------------------------------
>  
> -BC=$(which bc 2> /dev/null) || BC=
> +. common/config

Doesn't this means we now include common/config in every test setup
routine, even though the environment it sets up is inherited from
the check function.

If so, that's going to add significantly to the individual test
startup time (which already takes a significant fraction of a
second) and this happens hundreds of times over an auto run instead
of only once when we start the test run. It seems wrong to be doing
this over and over again unecessarily....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Make ./new work for non-root user
  2018-05-25  1:30 ` Dave Chinner
@ 2018-05-28  9:37   ` Jan Kara
  2018-05-29  1:16     ` Dave Chinner
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Kara @ 2018-05-28  9:37 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Jan Kara, fstests

On Fri 25-05-18 11:30:34, Dave Chinner wrote:
> On Thu, May 24, 2018 at 08:30:55PM +0200, Jan Kara wrote:
> > Currently 'new' script sources common/config which tries to find mkfs
> > and fails if not found (which is likely for non-root user). This is
> > inconvenient as development usually does not happen as root. In fact the
> > vast majority of setup in common/config and common/rc is not necessary
> > for 'new'. Split out the necessary bits into new common/config-base and
> > use it in 'new'. Cleanup common/rc and common/config now that it's only
> > used from 'check'.
> > 
> > Signed-off-by: Jan Kara <jack@suse.cz>
> ....
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -20,18 +20,9 @@
> >  #  Mountain View, CA 94043, USA, or: http://www.sgi.com
> >  #-----------------------------------------------------------------------
> >  
> > -BC=$(which bc 2> /dev/null) || BC=
> > +. common/config
> 
> Doesn't this means we now include common/config in every test setup
> routine, even though the environment it sets up is inherited from
> the check function.

What you describe was happening already in the past AFAICT. The test gets
executed as "./$seq" so only exported variables are inherited.  Thus 'iam'
variable is not set when executing the test and therefore common/rc was
already including common/config. Also including common/config in each test
is even required to get functions declared there. Am I missing something?

> If so, that's going to add significantly to the individual test
> startup time (which already takes a significant fraction of a
> second) and this happens hundreds of times over an auto run instead
> of only once when we start the test run. It seems wrong to be doing
> this over and over again unecessarily....

I agree but it's not a new problem introduced by my patch. I've just kept
the current status and tried to make the initialization less confusing.

								Honza

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Make ./new work for non-root user
  2018-05-28  9:37   ` Jan Kara
@ 2018-05-29  1:16     ` Dave Chinner
  0 siblings, 0 replies; 7+ messages in thread
From: Dave Chinner @ 2018-05-29  1:16 UTC (permalink / raw)
  To: Jan Kara; +Cc: fstests

On Mon, May 28, 2018 at 11:37:58AM +0200, Jan Kara wrote:
> On Fri 25-05-18 11:30:34, Dave Chinner wrote:
> > On Thu, May 24, 2018 at 08:30:55PM +0200, Jan Kara wrote:
> > > Currently 'new' script sources common/config which tries to find mkfs
> > > and fails if not found (which is likely for non-root user). This is
> > > inconvenient as development usually does not happen as root. In fact the
> > > vast majority of setup in common/config and common/rc is not necessary
> > > for 'new'. Split out the necessary bits into new common/config-base and
> > > use it in 'new'. Cleanup common/rc and common/config now that it's only
> > > used from 'check'.
> > > 
> > > Signed-off-by: Jan Kara <jack@suse.cz>
> > ....
> > > --- a/common/rc
> > > +++ b/common/rc
> > > @@ -20,18 +20,9 @@
> > >  #  Mountain View, CA 94043, USA, or: http://www.sgi.com
> > >  #-----------------------------------------------------------------------
> > >  
> > > -BC=$(which bc 2> /dev/null) || BC=
> > > +. common/config
> > 
> > Doesn't this means we now include common/config in every test setup
> > routine, even though the environment it sets up is inherited from
> > the check function.
> 
> What you describe was happening already in the past AFAICT. The test gets
> executed as "./$seq" so only exported variables are inherited.  Thus 'iam'
> variable is not set when executing the test and therefore common/rc was
> already including common/config. Also including common/config in each test
> is even required to get functions declared there. Am I missing something?

No, I just read the code incorrectly. The way common/config gets
included is a maze of twisty passages - I'll go back and look at the
patch again...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Make ./new work for non-root user
  2018-05-24 18:30 [PATCH] Make ./new work for non-root user Jan Kara
  2018-05-25  1:30 ` Dave Chinner
@ 2018-05-29  1:39 ` Dave Chinner
  2018-05-29  2:01   ` Dave Chinner
  2018-05-29 16:36   ` Jan Kara
  1 sibling, 2 replies; 7+ messages in thread
From: Dave Chinner @ 2018-05-29  1:39 UTC (permalink / raw)
  To: Jan Kara; +Cc: fstests

Second go....

On Thu, May 24, 2018 at 08:30:55PM +0200, Jan Kara wrote:
> Currently 'new' script sources common/config which tries to find mkfs
> and fails if not found (which is likely for non-root user). This is
> inconvenient as development usually does not happen as root. In fact the
> vast majority of setup in common/config and common/rc is not necessary
> for 'new'. Split out the necessary bits into new common/config-base and
> use it in 'new'. Cleanup common/rc and common/config now that it's only
> used from 'check'.

FWIW, common/config is also called from setup.

> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>  check              | 16 +++++-----------
>  common/config      | 16 ++--------------
>  common/config-base | 21 +++++++++++++++++++++
>  common/rc          | 27 ++-------------------------
>  new                |  2 +-
>  5 files changed, 31 insertions(+), 51 deletions(-)
>  create mode 100644 common/config-base
> 
> diff --git a/check b/check
> index 96198ac4714e..4c6e8285bc16 100755
> --- a/check
> +++ b/check
> @@ -331,10 +331,11 @@ while [ $# -gt 0 ]; do
>  	shift
>  done
>  
> -# we need common/config, source it after processing args, overlay needs FSTYP
> -# set before sourcing common/config
> -if ! . ./common/config; then
> -	echo "$iam: failed to source common/config"
> +# we need common/rc, that also sources common/config. We need to source it
> +# after processing args, overlay needs FSTYP set before sourcing common/config
> +if ! . ./common/rc
> +then
> +	echo "check: failed to source common/rc"
>  	exit 1
>  fi

Can we keep the existing formatting of "if foo ; then", please?

> diff --git a/common/config b/common/config
> index af360cefc804..fa07a6799824 100644
> --- a/common/config
> +++ b/common/config
> @@ -47,6 +47,8 @@
>  #   validity or mountedness.
>  #
>  
> +. common/config-base
> +
>  # all tests should use a common language setting to prevent golden
>  # output mismatches.
>  export LANG=C
> @@ -88,12 +90,6 @@ export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
>  
>  export RECREATE_TEST_DEV=false
>  
> -# $1 = prog to look for
> -set_prog_path()
> -{
> -	type -P $1
> -}

Can we just get rid of set_prog_path() and replace it with direct
calls to $(type -P foo) as an initial patch? This goes away at that
point, because new can then just use a locally coded version....

> --- /dev/null
> +++ b/common/config-base
> @@ -0,0 +1,21 @@
> +##/bin/bash
> +
> +# Valid test names start with 3 digits "NNN":
> +#  "[0-9]\{3\}"
> +# followed by an optional "-":
> +#  "-\?"
> +# followed by an optional combination of alphanumeric and "-" chars:
> +#  "[[:alnum:]-]*"
> +# e.g. 999-the-mark-of-fstests
> +#
> +VALID_TEST_ID="[0-9]\{3\}"
> +VALID_TEST_NAME="$VALID_TEST_ID-\?[[:alnum:]-]*"

This, then, is really the only thing shared between check and new,
right? So perhaps rename the file to common/test_names so it doesn't
get confused with stuff to do with configuration?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Make ./new work for non-root user
  2018-05-29  1:39 ` Dave Chinner
@ 2018-05-29  2:01   ` Dave Chinner
  2018-05-29 16:36   ` Jan Kara
  1 sibling, 0 replies; 7+ messages in thread
From: Dave Chinner @ 2018-05-29  2:01 UTC (permalink / raw)
  To: Jan Kara; +Cc: fstests

On Tue, May 29, 2018 at 11:39:14AM +1000, Dave Chinner wrote:
> Second go....
> 
> On Thu, May 24, 2018 at 08:30:55PM +0200, Jan Kara wrote:
> > Currently 'new' script sources common/config which tries to find mkfs
> > and fails if not found (which is likely for non-root user). This is
> > inconvenient as development usually does not happen as root. In fact the
> > vast majority of setup in common/config and common/rc is not necessary
> > for 'new'. Split out the necessary bits into new common/config-base and
> > use it in 'new'. Cleanup common/rc and common/config now that it's only
> > used from 'check'.
> 
> FWIW, common/config is also called from setup.
.....
> > @@ -88,12 +90,6 @@ export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
> >  
> >  export RECREATE_TEST_DEV=false
> >  
> > -# $1 = prog to look for
> > -set_prog_path()
> > -{
> > -	type -P $1
> > -}
> 
> Can we just get rid of set_prog_path() and replace it with direct
> calls to $(type -P foo) as an initial patch? This goes away at that
> point, because new can then just use a locally coded version....

Something like this?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

fstests: get rid of set_prog_path

From: Dave Chinner <dchinner@redhat.com>

It's just a one line wrapper that adds complexity, remove it. Move
the couple of calls in tests to common/config, but leave the xfsdump
setup in place and just convert it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 common/config   | 170 +++++++++++++++++++++++++++-----------------------------
 common/dump     |   6 +-
 tests/btrfs/085 |   2 -
 tests/xfs/446   |   1 -
 4 files changed, 86 insertions(+), 93 deletions(-)

diff --git a/common/config b/common/config
index 1cf402eee1dc..ef774b8d552b 100644
--- a/common/config
+++ b/common/config
@@ -88,17 +88,11 @@ export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
 
 export RECREATE_TEST_DEV=false
 
-# $1 = prog to look for
-set_prog_path()
-{
-	type -P $1
-}
-
 # Handle mkfs.$fstyp which does (or does not) require -f to overwrite
 set_mkfs_prog_path_with_opts()
 {
 	local fstyp=$1
-	local p=`set_prog_path mkfs.$fstyp`
+	local p=$(type -P mkfs.$fstyp)
 
 	# Note: mkfs.f2fs doesn't support the --help option yet, but it doesn't
 	# matter since it also prints the help when an invalid option is given.
@@ -117,105 +111,106 @@ _fatal()
     exit 1
 }
 
-export MKFS_PROG="`set_prog_path mkfs`"
+export MKFS_PROG=$(type -P mkfs)
 [ "$MKFS_PROG" = "" ] && _fatal "mkfs not found"
 
-export MOUNT_PROG="`set_prog_path mount`"
+export MOUNT_PROG=$(type -P mount)
 [ "$MOUNT_PROG" = "" ] && _fatal "mount not found"
 
-export UMOUNT_PROG="`set_prog_path umount`"
+export UMOUNT_PROG=$(type -P umount)
 [ "$UMOUNT_PROG" = "" ] && _fatal "umount not found"
 
 export FSSTRESS_PROG="./ltp/fsstress"
 [ ! -x $FSSTRESS_PROG ] && _fatal "fsstress not found or executable"
 
-export PERL_PROG="`set_prog_path perl`"
+export PERL_PROG=$(type -P perl)
 [ "$PERL_PROG" = "" ] && _fatal "perl not found"
 
-export AWK_PROG="`set_prog_path awk`"
+export AWK_PROG=$(type -P awk)
 [ "$AWK_PROG" = "" ] && _fatal "awk not found"
 
-export SED_PROG="`set_prog_path sed`"
+export SED_PROG=$(type -P sed)
 [ "$SED_PROG" = "" ] && _fatal "sed not found"
 
-export BC_PROG="`set_prog_path bc`"
+export BC_PROG=$(type -P bc)
 [ "$BC_PROG" = "" ] && _fatal "bc not found"
 
 export PS_ALL_FLAGS="-ef"
 
-export DF_PROG="`set_prog_path df`"
+export DF_PROG=$(type -P df)
 [ "$DF_PROG" = "" ] && _fatal "df not found"
 [ "$HOSTOS" = "Linux" ] && export DF_PROG="$DF_PROG -T -P"
 
-export XFS_IO_PROG="`set_prog_path xfs_io`"
+export XFS_IO_PROG=$(type -P xfs_io)
 [ "$XFS_IO_PROG" = "" ] && _fatal "xfs_io not found"
 
-export XFS_LOGPRINT_PROG="`set_prog_path xfs_logprint`"
-export XFS_REPAIR_PROG="`set_prog_path xfs_repair`"
-export XFS_DB_PROG="`set_prog_path xfs_db`"
-export XFS_GROWFS_PROG=`set_prog_path xfs_growfs`
-export XFS_SPACEMAN_PROG="`set_prog_path xfs_spaceman`"
-export XFS_SCRUB_PROG="`set_prog_path xfs_scrub`"
-export XFS_PARALLEL_REPAIR_PROG="`set_prog_path xfs_prepair`"
-export XFS_PARALLEL_REPAIR64_PROG="`set_prog_path xfs_prepair64`"
-export __XFSDUMP_PROG="`set_prog_path xfsdump`"
+export XFS_LOGPRINT_PROG=$(type -P xfs_logprint)
+export XFS_REPAIR_PROG=$(type -P xfs_repair)
+export XFS_DB_PROG=$(type -P xfs_db)
+export XFS_GROWFS_PROG=$(type -P xfs_growfs)
+export XFS_SPACEMAN_PROG=$(type -P xfs_spaceman)
+export XFS_SCRUB_PROG=$(type -P xfs_scrub)
+export XFS_PARALLEL_REPAIR_PROG=$(type -P xfs_prepair)
+export XFS_PARALLEL_REPAIR64_PROG=$(type -P xfs_prepair64)
+export __XFSDUMP_PROG=$(type -P xfsdump)
 if [ -n "$__XFSDUMP_PROG" ]; then
 	export XFSDUMP_PROG="$__XFSDUMP_PROG -e"
 else
 	export XFSDUMP_PROG=""
 fi
-export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
-export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
-export GETFATTR_PROG="`set_prog_path getfattr`"
-export SETFATTR_PROG="`set_prog_path setfattr`"
-export CHACL_PROG="`set_prog_path chacl`"
-export ATTR_PROG="`set_prog_path attr`"
-export QUOTA_PROG="`set_prog_path quota`"
-export XFS_QUOTA_PROG="`set_prog_path xfs_quota`"
-export KILLALL_PROG="`set_prog_path killall`"
-export INDENT_PROG="`set_prog_path indent`"
-export XFS_COPY_PROG="`set_prog_path xfs_copy`"
-export FSTRIM_PROG="`set_prog_path fstrim`"
-export DUMPE2FS_PROG="`set_prog_path dumpe2fs`"
-export FIO_PROG="`set_prog_path fio`"
-export FILEFRAG_PROG="`set_prog_path filefrag`"
-export E4DEFRAG_PROG="`set_prog_path e4defrag`"
-export LOGGER_PROG="`set_prog_path logger`"
-export DBENCH_PROG="`set_prog_path dbench`"
-export DMSETUP_PROG="`set_prog_path dmsetup`"
-export WIPEFS_PROG="`set_prog_path wipefs`"
-export DUMP_PROG="`set_prog_path dump`"
-export RESTORE_PROG="`set_prog_path restore`"
-export LVM_PROG="`set_prog_path lvm`"
-export CHATTR_PROG="`set_prog_path chattr`"
-export DEBUGFS_PROG="`set_prog_path debugfs`"
-export UUIDGEN_PROG="`set_prog_path uuidgen`"
-export GETRICHACL_PROG="`set_prog_path getrichacl`"
-export SETRICHACL_PROG="`set_prog_path setrichacl`"
-export KEYCTL_PROG="`set_prog_path keyctl`"
-export XZ_PROG="`set_prog_path xz`"
-export FLOCK_PROG="`set_prog_path flock`"
-export LDD_PROG="`set_prog_path ldd`"
-export TIMEOUT_PROG="`set_prog_path timeout`"
-export MAN_PROG="`set_prog_path man`"
-export NFS4_SETFACL_PROG="`set_prog_path nfs4_setfacl`"
-export NFS4_GETFACL_PROG="`set_prog_path nfs4_getfacl`"
-export UBIUPDATEVOL_PROG="`set_prog_path ubiupdatevol`"
-export THIN_CHECK_PROG="$(set_prog_path thin_check)"
-export PYTHON2_PROG="`set_prog_path python2`"
-export SQLITE3_PROG="`set_prog_path sqlite3`"
-export TIMEOUT_PROG="`set_prog_path timeout`"
-export SETCAP_PROG="`set_prog_path setcap`"
-export GETCAP_PROG="`set_prog_path getcap`"
+export XFSRESTORE_PROG=$(type -P xfsrestore)
+export XFSINVUTIL_PROG=$(type -P xfsinvutil)
+export GETFATTR_PROG=$(type -P getfattr)
+export SETFATTR_PROG=$(type -P setfattr)
+export CHACL_PROG=$(type -P chacl)
+export ATTR_PROG=$(type -P attr)
+export QUOTA_PROG=$(type -P quota)
+export XFS_QUOTA_PROG=$(type -P xfs_quota)
+export KILLALL_PROG=$(type -P killall)
+export INDENT_PROG=$(type -P indent)
+export XFS_COPY_PROG=$(type -P xfs_copy)
+export FSTRIM_PROG=$(type -P fstrim)
+export DUMPE2FS_PROG=$(type -P dumpe2fs)
+export FIO_PROG=$(type -P fio)
+export FILEFRAG_PROG=$(type -P filefrag)
+export E4DEFRAG_PROG=$(type -P e4defrag)
+export LOGGER_PROG=$(type -P logger)
+export DBENCH_PROG=$(type -P dbench)
+export DMSETUP_PROG=$(type -P dmsetup)
+export WIPEFS_PROG=$(type -P wipefs)
+export DUMP_PROG=$(type -P dump)
+export RESTORE_PROG=$(type -P restore)
+export LVM_PROG=$(type -P lvm)
+export CHATTR_PROG=$(type -P chattr)
+export DEBUGFS_PROG=$(type -P debugfs)
+export UUIDGEN_PROG=$(type -P uuidgen)
+export GETRICHACL_PROG=$(type -P getrichacl)
+export SETRICHACL_PROG=$(type -P setrichacl)
+export KEYCTL_PROG=$(type -P keyctl)
+export XZ_PROG=$(type -P xz)
+export FLOCK_PROG=$(type -P flock)
+export LDD_PROG=$(type -P ldd)
+export TIMEOUT_PROG=$(type -P timeout)
+export MAN_PROG=$(type -P man)
+export NFS4_SETFACL_PROG=$(type -P nfs4_setfacl)
+export NFS4_GETFACL_PROG=$(type -P nfs4_getfacl)
+export UBIUPDATEVOL_PROG=$(type -P ubiupdatevol)
+export THIN_CHECK_PROG=$(type -P thin_check)
+export PYTHON2_PROG=$(type -P python2)
+export SQLITE3_PROG=$(type -P sqlite3)
+export TIMEOUT_PROG=$(type -P timeout)
+export SETCAP_PROG=$(type -P setcap)
+export GETCAP_PROG=$(type -P getcap)
+export CHECKBASHISMS_PROG=$(type -P checkbashisms)
 
 # use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
 # newer systems have udevadm command but older systems like RHEL5 don't.
 # But if neither one is available, just set it to "sleep 1" to wait for lv to
 # be settled
-UDEV_SETTLE_PROG="`set_prog_path udevadm`"
+UDEV_SETTLE_PROG=$(type -P udevadm)
 if [ "$UDEV_SETTLE_PROG" == "" ]; then
 	# try udevsettle command
-	UDEV_SETTLE_PROG="`set_prog_path udevsettle`"
+	UDEV_SETTLE_PROG=$(type -P udevsettle)
 else
 	# udevadm is available, add 'settle' as subcommand
 	UDEV_SETTLE_PROG="$UDEV_SETTLE_PROG settle"
@@ -228,23 +223,24 @@ export UDEV_SETTLE_PROG
 
 case "$HOSTOS" in
     Linux)
-        export MKFS_XFS_PROG="`set_prog_path mkfs.xfs`"
-        export MKFS_EXT4_PROG="`set_prog_path mkfs.ext4`"
-        export MKFS_UDF_PROG="`set_prog_path mkudffs`"
-        export MKFS_BTRFS_PROG="`set_mkfs_prog_path_with_opts btrfs`"
-        export MKFS_F2FS_PROG="`set_mkfs_prog_path_with_opts f2fs`"
-        export DUMP_F2FS_PROG="`set_prog_path dump.f2fs`"
-        export BTRFS_UTIL_PROG="`set_prog_path btrfs`"
-        export BTRFS_SHOW_SUPER_PROG="`set_prog_path btrfs-show-super`"
-	export BTRFS_CONVERT_PROG="`set_prog_path btrfs-convert`"
-        export XFS_FSR_PROG="`set_prog_path xfs_fsr`"
-        export MKFS_NFS_PROG="false"
-        export MKFS_CIFS_PROG="false"
-        export MKFS_OVERLAY_PROG="false"
-        export MKFS_REISER4_PROG="`set_prog_path mkfs.reiser4`"
-	export E2FSCK_PROG="`set_prog_path e2fsck`"
-	export TUNE2FS_PROG="`set_prog_path tune2fs`"
-	export FSCK_OVERLAY_PROG="`set_prog_path fsck.overlay`"
+	export MKFS_XFS_PROG=$(type -P mkfs.xfs)
+	export MKFS_EXT4_PROG=$(type -P mkfs.ext4)
+	export MKFS_UDF_PROG=$(type -P mkudffs)
+	export MKFS_BTRFS_PROG=$(type -P btrfs)
+	export MKFS_F2FS_PROG=$(type -P f2fs)
+	export DUMP_F2FS_PROG=$(type -P dump.f2fs)
+	export BTRFS_UTIL_PROG=$(type -P btrfs)
+	export BTRFS_SHOW_SUPER_PROG=$(type -P btrfs-show-super)
+	export BTRFS_CONVERT_PROG=$(type -P btrfs-convert)
+	export BTRFS_DEBUG_TREE_PROG=$(type -P btrfs-debug-tree)
+	export XFS_FSR_PROG=$(type -P xfs_fsr)
+	export MKFS_NFS_PROG="false"
+	export MKFS_CIFS_PROG="false"
+	export MKFS_OVERLAY_PROG="false"
+	export MKFS_REISER4_PROG=$(type -P mkfs.reiser4)
+	export E2FSCK_PROG=$(type -P e2fsck)
+	export TUNE2FS_PROG=$(type -P tune2fs)
+	export FSCK_OVERLAY_PROG=$(type -P fsck.overlay)
         ;;
 esac
 
diff --git a/common/dump b/common/dump
index 7b9c10a25414..8a0ba1096d6a 100644
--- a/common/dump
+++ b/common/dump
@@ -29,10 +29,10 @@ if [ -n "$DEBUGDUMP" ]; then
 
 	# Use dump/restore in qa directory (copy them here) for debugging
 	export PATH="$here:$PATH"
-	export __XFSDUMP_PROG="`set_prog_path xfsdump`"
+	export __XFSDUMP_PROG=$(type -P xfsdump)
 	export XFSDUMP_PROG="$__XFSDUMP_PROG -e"
-	export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
-	export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
+	export XFSRESTORE_PROG=$(type -P xfsrestore)
+	export XFSINVUTIL_PROG=$(type -P xfsinvutil)
 	[ -x $here/xfsdump ]    && echo "Using xfstests' xfsdump for debug"
 	[ -x $here/xfsrestore ] && echo "Using xfstests' xfsrestore for debug"
 	[ -x $here/xfsinvutil ] && echo "Using xfstests' xfsinvutil for debug"
diff --git a/tests/btrfs/085 b/tests/btrfs/085
index 804899724cba..a1edc28341da 100755
--- a/tests/btrfs/085
+++ b/tests/btrfs/085
@@ -55,8 +55,6 @@ _supported_fs btrfs
 _supported_os Linux
 _require_scratch
 _require_dm_target flakey
-
-BTRFS_DEBUG_TREE_PROG="`set_prog_path btrfs-debug-tree`"
 _require_command "$BTRFS_DEBUG_TREE_PROG" btrfs-debug-tree
 
 rm -f $seqres.full
diff --git a/tests/xfs/446 b/tests/xfs/446
index 752c6a7de827..ac74723f471f 100755
--- a/tests/xfs/446
+++ b/tests/xfs/446
@@ -37,7 +37,6 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 # real QA test starts here
 _supported_fs xfs
 _supported_os Linux
-export CHECKBASHISMS_PROG="`set_prog_path checkbashisms`"
 _require_command "$CHECKBASHISMS_PROG" checkbashisms
 
 test -z "$WORKAREA" && _notrun "Can't find xfsprogs source"

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] Make ./new work for non-root user
  2018-05-29  1:39 ` Dave Chinner
  2018-05-29  2:01   ` Dave Chinner
@ 2018-05-29 16:36   ` Jan Kara
  1 sibling, 0 replies; 7+ messages in thread
From: Jan Kara @ 2018-05-29 16:36 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Jan Kara, fstests

On Tue 29-05-18 11:39:14, Dave Chinner wrote:
> On Thu, May 24, 2018 at 08:30:55PM +0200, Jan Kara wrote:
> > Currently 'new' script sources common/config which tries to find mkfs
> > and fails if not found (which is likely for non-root user). This is
> > inconvenient as development usually does not happen as root. In fact the
> > vast majority of setup in common/config and common/rc is not necessary
> > for 'new'. Split out the necessary bits into new common/config-base and
> > use it in 'new'. Cleanup common/rc and common/config now that it's only
> > used from 'check'.
> 
> FWIW, common/config is also called from setup.

Fixed up.

> > diff --git a/check b/check
> > index 96198ac4714e..4c6e8285bc16 100755
> > --- a/check
> > +++ b/check
> > @@ -331,10 +331,11 @@ while [ $# -gt 0 ]; do
> >  	shift
> >  done
> >  
> > -# we need common/config, source it after processing args, overlay needs FSTYP
> > -# set before sourcing common/config
> > -if ! . ./common/config; then
> > -	echo "$iam: failed to source common/config"
> > +# we need common/rc, that also sources common/config. We need to source it
> > +# after processing args, overlay needs FSTYP set before sourcing common/config
> > +if ! . ./common/rc
> > +then
> > +	echo "check: failed to source common/rc"
> >  	exit 1
> >  fi
> 
> Can we keep the existing formatting of "if foo ; then", please?

Will do.

> > diff --git a/common/config b/common/config
> > index af360cefc804..fa07a6799824 100644
> > --- a/common/config
> > +++ b/common/config
> > @@ -47,6 +47,8 @@
> >  #   validity or mountedness.
> >  #
> >  
> > +. common/config-base
> > +
> >  # all tests should use a common language setting to prevent golden
> >  # output mismatches.
> >  export LANG=C
> > @@ -88,12 +90,6 @@ export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
> >  
> >  export RECREATE_TEST_DEV=false
> >  
> > -# $1 = prog to look for
> > -set_prog_path()
> > -{
> > -	type -P $1
> > -}
> 
> Can we just get rid of set_prog_path() and replace it with direct
> calls to $(type -P foo) as an initial patch? This goes away at that
> point, because new can then just use a locally coded version....

I've added your patch to the series. Thanks!

> > --- /dev/null
> > +++ b/common/config-base
> > @@ -0,0 +1,21 @@
> > +##/bin/bash
> > +
> > +# Valid test names start with 3 digits "NNN":
> > +#  "[0-9]\{3\}"
> > +# followed by an optional "-":
> > +#  "-\?"
> > +# followed by an optional combination of alphanumeric and "-" chars:
> > +#  "[[:alnum:]-]*"
> > +# e.g. 999-the-mark-of-fstests
> > +#
> > +VALID_TEST_ID="[0-9]\{3\}"
> > +VALID_TEST_NAME="$VALID_TEST_ID-\?[[:alnum:]-]*"
> 
> This, then, is really the only thing shared between check and new,
> right? So perhaps rename the file to common/test_names so it doesn't
> get confused with stuff to do with configuration?

OK, there's also the AWK_PROG thing but I've decided to just have that
directly in 'new'. There's not much to break there.

Thanks for review!

								Honza

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-05-29 16:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-24 18:30 [PATCH] Make ./new work for non-root user Jan Kara
2018-05-25  1:30 ` Dave Chinner
2018-05-28  9:37   ` Jan Kara
2018-05-29  1:16     ` Dave Chinner
2018-05-29  1:39 ` Dave Chinner
2018-05-29  2:01   ` Dave Chinner
2018-05-29 16:36   ` Jan Kara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.