]> www.infradead.org Git - users/hch/blktests.git/commitdiff
Create test name from most recently used test number
authorJon Derrick <jonathan.derrick@intel.com>
Tue, 24 Aug 2021 18:46:42 +0000 (12:46 -0600)
committerOmar Sandoval <osandov@osandov.com>
Thu, 26 Aug 2021 16:57:17 +0000 (09:57 -0700)
The 'new' script can inadvertently use a test name that was removed, ex
nvme/001, which may create confusion if identically-named tests exist
among different versions. Instead, generate a test name at the numerical
tail end of the test group.

Signed-off-by: Jon Derrick <jonathan.derrick@linux.dev>
new

diff --git a/new b/new
index 280cfb79ca24253bc420fc5fb18fcc91b2fce269..51ec2c419556e9cd13b2a5cacd37717917680a3e 100755 (executable)
--- a/new
+++ b/new
@@ -96,13 +96,11 @@ EOF
        echo "Created tests/${group}/rc"
 fi
 
-for ((i = 1; ; i++)); do
-       seq="$(printf "%03d" "$i")"
-       test_name="${group}/${seq}"
-       if [[ ! -e tests/${test_name} ]]; then
-               break
-       fi
+for test in tests/"$group"/+([0-9]); do
+       :
 done
+seq=${test##tests/$group/+(0)}
+test_name="${group}/$(printf "%03d" $((seq + 1)))"
 
 cat << EOF > "tests/${test_name}"
 #!/bin/bash