Skip to contentSkip to conversation

new: Improvements to new script

PATCH Superseded Nirjhar Roy (IBM) 2 participants 8 messages May 13, 2025 – May 14, 2025

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover new: Improvements to new script

This series adds a couple of improvements to the "new" script.
Patch-1/3 - Adds an optional name/email id parameter prompt to the new script while creating
a new test file using the "new" file.
Patch 2/3 - Replace "status=0;exit 0" with _exit 0 in the skeleton file in "new". Patch 3/3 - Add a make command after the skeleton file is created, so that once the skeleton file is created, it automatically gets added to group.list file. This will enable the users to directly run the test without having to explicitly run make on their own.

Nirjhar Roy (IBM) (3):
new: Add a new parameter (name/emailid) in the "new" script
new: Replace "status=0; exit 0" with _exit 0
new: Run make after adding a new test file

 new | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

--
2.34.1

#1 lore raw

PATCH 1/3 new: Add a new parameter (name/emailid) in the "new" script

This patch another optional interactive prompt to enter the author name and email id for each new test file that is created using the "new" file.

The sample output looks like something like the following:

./new selftest
Next test id is 007
Append a name to the ID? Test name will be 007-$name. y,[n]:
Creating test file '007'
Add to group(s) [auto] (separate by space, ? for list): selftest quick Enter <author_name> <email-id>: Nirjhar Roy <[email protected]> Creating skeletal script for you to edit ...
done.

...
...

---
 new | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
new +4 -1
index 6b50ffed..139715bf 100755
@@ -136,6 +136,9 @@ else
 	check_groups "${new_groups[@]}" || exit 1
 fi
 
+read -p "Enter <author_name> <email-id>: " -r
+author_name="${REPLY:=YOUR NAME HERE}"
+
 echo -n "Creating skeletal script for you to edit ..."
 
 year=`date +%Y`
@@ -143,7 +146,7 @@ year=`date +%Y`
 cat <<End-of-File >$tdir/$id
 #! /bin/bash
 # SPDX-License-Identifier: GPL-2.0
-# Copyright (c) $year YOUR NAME HERE.  All Rights Reserved.
+# Copyright (c) $year $author_name.  All Rights Reserved.
 #
 # FS QA Test $id
 #
Signature · 1 line
2.34.1
#4 lore raw

PATCH 2/3 new: Replace "status=0; exit 0" with _exit 0

In reply to Nirjhar Roy (IBM)

We should now start using _exit 0 for every new test that we add.

---
 new | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
new +1 -2
index 139715bf..e55830ce 100755
@@ -176,8 +176,7 @@ exit
 #echo "If failure, check \$seqres.full (this) and \$seqres.full.ok (reference)"
 
 # success, all done
-status=0
-exit
+_exit 0
 End-of-File
 
 sleep 2		# latency to read messages to this point
Signature · 1 line
2.34.1
#6 lore raw

PATCH 3/3 new: Run make after adding a new test file

In reply to Nirjhar Roy (IBM)

Once a new test file is created, it needs to explicitly added to the group.list file in tests/<FSTYPE> directory in order for it to get run. Automate
that by running make by as a part of creation of the new test file in the "new" script.

---
 new | 8 ++++++++
 1 file changed, 8 insertions(+)
new +8 -0
index e55830ce..647763c1 100755
@@ -191,5 +191,13 @@ QA output created by $id
 Silence is golden
 End-of-File
 
+echo "Adding test $tdir/$id to the test list..."
+make >> /dev/null 2>&1 || true
+
+if ! grep -q $id $tdir/group.list; then
+	echo "$tdir/$id created but not added to the $tdir/group.list."
+	echo "Possible reason is make failure. Please ensure a clean build"
+fi
+
 echo " done."
 exit 0
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH v1 3/3] new: Run make after adding a new test file

Quoted 5 lines · Nirjhar Roy (IBM)

Once a new test file is created, it needs to explicitly added to the group.list file in tests/<FSTYPE> directory in order for it to get run. Automate
that by running make by as a part of creation of the new test file in the "new" script.

I think it's not necessary to force to do that, the users can do "make -jN" when they need :)

Quoted 28 lines
---
 new | 8 ++++++++
 1 file changed, 8 insertions(+)
new +8 -0
index e55830ce..647763c1 100755
@@ -191,5 +191,13 @@ QA output created by $id
 Silence is golden
 End-of-File
 
+echo "Adding test $tdir/$id to the test list..."
+make >> /dev/null 2>&1 || true
+
+if ! grep -q $id $tdir/group.list; then
+	echo "$tdir/$id created but not added to the $tdir/group.list."
+	echo "Possible reason is make failure. Please ensure a clean build"
+fi
+
 echo " done."
 exit 0
Signature · 1 line
2.34.1
Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH v1 2/3] new: Replace "status=0; exit 0" with _exit 0

In reply to Nirjhar Roy (IBM)
Quoted 13 lines · Nirjhar Roy (IBM)

We should now start using _exit 0 for every new test that we add.

---
 new | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
new +0 -0
index 139715bf..e55830ce 100755

new exit · line 179

Quoted 6 lines
new +1 -2
@@ -176,8 +176,7 @@ exit
 #echo "If failure, check \$seqres.full (this) and \$seqres.full.ok (reference)"
 
 # success, all done
-status=0
-exit
+_exit 0

Hmm, this makes sense after we have:

744623644 common: Move exit related functions to a common/exit

Quoted 7 lines
new +0 -0
 End-of-File
 
 sleep 2		# latency to read messages to this point
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v1 1/3] new: Add a new parameter (name/emailid) in the "new" script

In reply to Nirjhar Roy (IBM)
Quoted 28 lines · Nirjhar Roy (IBM)

This patch another optional interactive prompt to enter the author name and email id for each new test file that is created using the "new" file.

The sample output looks like something like the following:

./new selftest
Next test id is 007
Append a name to the ID? Test name will be 007-$name. y,[n]:
Creating test file '007'
Add to group(s) [auto] (separate by space, ? for list): selftest quick Enter <author_name> <email-id>: Nirjhar Roy <[email protected]> Creating skeletal script for you to edit ...
done.

...
...

---
 new | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
new +0 -0
index 6b50ffed..139715bf 100755

new else · line 139

Quoted 4 lines
new +1 -0
@@ -136,6 +136,9 @@ else
 	check_groups "${new_groups[@]}" || exit 1
 fi
 
+read -p "Enter <author_name> <email-id>: " -r

I think most of "YOUR NAME HERE" are the name of company, e.g. "Oracle, Inc", "Red Hat, Inc". Some authors just write their names, e.g. "Filipe Manana", "Chao Yu"...

So I think the "<email-id>" hint isn't necessary. If someone need that, he can write it with his name together.

Thanks,
Zorro

Quoted 18 lines
new +3 -1
+author_name="${REPLY:=YOUR NAME HERE}"
+
 echo -n "Creating skeletal script for you to edit ..."
 
 year=`date +%Y`
@@ -143,7 +146,7 @@ year=`date +%Y`
 cat <<End-of-File >$tdir/$id
 #! /bin/bash
 # SPDX-License-Identifier: GPL-2.0
-# Copyright (c) $year YOUR NAME HERE.  All Rights Reserved.
+# Copyright (c) $year $author_name.  All Rights Reserved.
 #
 # FS QA Test $id
 #
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v1 1/3] new: Add a new parameter (name/emailid) in the "new" script

Quoted 32 lines · Zorro Lang
Quoted 31 lines · Nirjhar Roy (IBM)

This patch another optional interactive prompt to enter the author name and email id for each new test file that is created using the "new" file.

The sample output looks like something like the following:

./new selftest
Next test id is 007
Append a name to the ID? Test name will be 007-$name. y,[n]:
Creating test file '007'
Add to group(s) [auto] (separate by space, ? for list): selftest quick Enter <author_name> <email-id>: Nirjhar Roy <[email protected]> Creating skeletal script for you to edit ...
done.

...
...

---
  new | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
new +0 -0
index 6b50ffed..139715bf 100755
@@ -136,6 +136,9 @@ else
  	check_groups "${new_groups[@]}" || exit 1
  fi
 
Quoted 7 lines

new else · line 139

Quoted 1 line
new +1 -0
+read -p "Enter <author_name> <email-id>: " -r

I think most of "YOUR NAME HERE" are the name of company, e.g. "Oracle, Inc", "Red Hat, Inc". Some authors just write their names, e.g. "Filipe Manana", "Chao Yu"...

So I think the "<email-id>" hint isn't necessary. If someone need that, he can write it with his name together.

Okay, I can change it to in V2:

read -p "Enter <author_name> " -r

Does this look good?

--NR

Quoted 22 lines

Thanks,
Zorro

Quoted 18 lines
new +3 -1
+author_name="${REPLY:=YOUR NAME HERE}"
+
  echo -n "Creating skeletal script for you to edit ..."
 
  year=`date +%Y`
@@ -143,7 +146,7 @@ year=`date +%Y`
  cat <<End-of-File >$tdir/$id
  #! /bin/bash
  # SPDX-License-Identifier: GPL-2.0
-# Copyright (c) $year YOUR NAME HERE.  All Rights Reserved.
+# Copyright (c) $year $author_name.  All Rights Reserved.
  #
  # FS QA Test $id
  #
Signature · 1 line
2.34.1
Signature · 3 lines
Nirjhar Roy
Linux Kernel Developer
IBM, Bangalore