diff mbox series

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

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

Commit Message

Darrick J. Wong July 20, 2021, 1:08 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 |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig July 22, 2021, 6:35 a.m. UTC | #1
Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/new b/new
index 07144399..2097a883 100755
--- a/new
+++ b/new
@@ -20,13 +20,24 @@  _cleanup()
 SRC_GROUPS=`find tests -not -path tests -type d -printf "%f "`
 usage()
 {
-    echo "Usage $0 test_dir"
+    echo "Usage $0 test_dir|test_dir_and_name"
     echo "Available dirs are: $SRC_GROUPS"
     exit
 }
 
 [ $# -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