diff mbox series

[1/1] new: allow users to specify a new test id

Message ID 162561726493.543346.17291318180978776290.stgit@locust (mailing list archive)
State New, archived
Headers show
Series fstests: fixes for test control code | expand

Commit Message

Darrick J. Wong July 7, 2021, 12:21 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Alter the ./new script so that one can set the test id explicitly.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 new |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Eryu Guan July 18, 2021, 1:57 p.m. UTC | #1
On Tue, Jul 06, 2021 at 05:21:04PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Alter the ./new script so that one can set the test id explicitly.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Looks good to me. Mind updating the usage info as well?

Thanks,
Eryu

> ---
>  new |   14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/new b/new
> index 07144399..51111f08 100755
> --- a/new
> +++ b/new
> @@ -26,7 +26,18 @@ usage()
>  }
>  
>  [ $# -eq 0 ] && usage
> -tdir=tests/$1
> +
> +if echo "$1" | grep -q '/'; then
> +	if [ -e "tests/$1" ]; then
> +		echo "$1: test already exists."
> +		exit 1
> +	fi
> +	tdir="tests/$(echo "$1" | cut -d '/' -f 1)"
> +	id="$(echo "$1" | cut -d '/' -f 2)"
> +else
> +	tdir=tests/$1
> +	id="$(basename "$(./tools/nextid "$1")")"
> +fi
>  
>  i=0
>  line=0
> @@ -36,7 +47,6 @@ eof=1
>  export AWK_PROG="$(type -P awk)"
>  [ "$AWK_PROG" = "" ] && { echo "awk not found"; exit; }
>  
> -id="$(basename "$(./tools/nextid "$1")")"
>  echo "Next test id is $id"
>  shift
>
Darrick J. Wong July 18, 2021, 4:23 p.m. UTC | #2
On Sun, Jul 18, 2021 at 09:57:14PM +0800, Eryu Guan wrote:
> On Tue, Jul 06, 2021 at 05:21:04PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > Alter the ./new script so that one can set the test id explicitly.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> 
> Looks good to me. Mind updating the usage info as well?

Will do and resubmit.  Thanks for reviewing the rest of the patches. :)

--D

> 
> Thanks,
> Eryu
> 
> > ---
> >  new |   14 ++++++++++++--
> >  1 file changed, 12 insertions(+), 2 deletions(-)
> > 
> > 
> > diff --git a/new b/new
> > index 07144399..51111f08 100755
> > --- a/new
> > +++ b/new
> > @@ -26,7 +26,18 @@ usage()
> >  }
> >  
> >  [ $# -eq 0 ] && usage
> > -tdir=tests/$1
> > +
> > +if echo "$1" | grep -q '/'; then
> > +	if [ -e "tests/$1" ]; then
> > +		echo "$1: test already exists."
> > +		exit 1
> > +	fi
> > +	tdir="tests/$(echo "$1" | cut -d '/' -f 1)"
> > +	id="$(echo "$1" | cut -d '/' -f 2)"
> > +else
> > +	tdir=tests/$1
> > +	id="$(basename "$(./tools/nextid "$1")")"
> > +fi
> >  
> >  i=0
> >  line=0
> > @@ -36,7 +47,6 @@ eof=1
> >  export AWK_PROG="$(type -P awk)"
> >  [ "$AWK_PROG" = "" ] && { echo "awk not found"; exit; }
> >  
> > -id="$(basename "$(./tools/nextid "$1")")"
> >  echo "Next test id is $id"
> >  shift
> >
diff mbox series

Patch

diff --git a/new b/new
index 07144399..51111f08 100755
--- a/new
+++ b/new
@@ -26,7 +26,18 @@  usage()
 }
 
 [ $# -eq 0 ] && usage
-tdir=tests/$1
+
+if echo "$1" | grep -q '/'; then
+	if [ -e "tests/$1" ]; then
+		echo "$1: test already exists."
+		exit 1
+	fi
+	tdir="tests/$(echo "$1" | cut -d '/' -f 1)"
+	id="$(echo "$1" | cut -d '/' -f 2)"
+else
+	tdir=tests/$1
+	id="$(basename "$(./tools/nextid "$1")")"
+fi
 
 i=0
 line=0
@@ -36,7 +47,6 @@  eof=1
 export AWK_PROG="$(type -P awk)"
 [ "$AWK_PROG" = "" ] && { echo "awk not found"; exit; }
 
-id="$(basename "$(./tools/nextid "$1")")"
 echo "Next test id is $id"
 shift