diff mbox series

[blktests] new: fix test case addition to new test group

Message ID 20220719031036.1395823-1-shinichiro.kawasaki@wdc.com (mailing list archive)
State New, archived
Headers show
Series [blktests] new: fix test case addition to new test group | expand

Commit Message

Shinichiro Kawasaki July 19, 2022, 3:10 a.m. UTC
The "new" script adds script files for a new test case to the specified
test group. However, this file addition fails when the user specifies
non-existing new test group name as the target test group. The failure
happens because the "new" script assumes the target test group directory
has at least one test case, but this is not true when a new group is
created. Fix this by checking the existence of the test cases in the
target test group.

Fixes: b1e29e775872 ("Create test name from most recently used test number")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 new | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Chaitanya Kulkarni July 19, 2022, 6:46 a.m. UTC | #1
On 7/18/22 20:10, Shin'ichiro Kawasaki wrote:
> The "new" script adds script files for a new test case to the specified
> test group. However, this file addition fails when the user specifies
> non-existing new test group name as the target test group. The failure
> happens because the "new" script assumes the target test group directory
> has at least one test case, but this is not true when a new group is
> created. Fix this by checking the existence of the test cases in the
> target test group.
> 
> Fixes: b1e29e775872 ("Create test name from most recently used test number")
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck
Johannes Thumshirn July 19, 2022, 7:32 a.m. UTC | #2
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
diff mbox series

Patch

diff --git a/new b/new
index 8f63831..e8ee5a0 100755
--- a/new
+++ b/new
@@ -98,10 +98,13 @@  EOF
 	echo "Created tests/${group}/rc"
 fi
 
+seq=0
 for test in tests/"$group"/+([0-9]); do
-	:
+	if [[ -e $test ]]; then
+		seq=${test##tests/"${group}"/+(0)}
+	fi
 done
-seq=${test##tests/"${group}"/+(0)}
+
 test_name="${group}/$(printf "%03d" $((seq + 1)))"
 
 cat << EOF > "tests/${test_name}"