]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
check: Allow partial test names
authorJan Tulak <jtulak@redhat.com>
Tue, 4 Aug 2015 04:10:49 +0000 (14:10 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 4 Aug 2015 04:10:49 +0000 (14:10 +1000)
When running ./check and calling a test with a name, id is enough
to find the test (names added in 03c633bf).

If the full test path is tests/xfs/123-foo-bar, then all these
invocations should work, as long as the given part of the test name
is valid and the three-digits id is here.

./check xfs/123-foo-bar
./check xfs/123-foo
./check xfs/123

Always use full test name in results.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
check
common/rc

diff --git a/check b/check
index 4307a330224b314fb2404eeff35d9aa13aae0082..aca4a1c92a40e5cdfc4e319e289084dfbbd90cb4 100755 (executable)
--- a/check
+++ b/check
@@ -533,14 +533,27 @@ for section in $HOST_OPTIONS_SECTIONS; do
 
            echo -n "$seqnum"
 
-           if $showme
-           then
-               echo
-               continue
-           elif [ ! -f $seq ]
-           then
-               echo " - no such test?"
-           else
+               if $showme; then
+                       echo
+                       continue
+               elif [ ! -f $seq ]; then
+                       # Try to get full name in case the user supplied only seq id
+                       # and the test has a name. A bit of hassle to find really
+                       # the test and not its sample output or helping files.
+                       bname=$(basename $seq)
+                       full_seq=$(find $(dirname $seq) -name $bname* -executable |
+                               awk '(NR == 1 || length < length(shortest)) { shortest = $0 }\
+                                       END { print shortest }')
+                       if [ -f $full_seq ] \
+                               && [ x$(echo $bname | grep -o "^$VALID_TEST_ID") != x ]; then
+                               seq=$full_seq
+                               seqnum=${full_seq#*/}
+                       fi
+               fi
+
+               if [ ! -f $seq ]; then
+                       echo " - no such test?"
+               else
                # really going to try and run this one
                #
                rm -f $seqres.out.bad
index 601dbbfbe744063860e4e81e0639139e48dae228..1dcebf91fc6668b51aaf8f92f0a0ff7ee77d4a06 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -30,7 +30,8 @@ BC=$(which bc 2> /dev/null) || BC=
 #  "[[:alnum:]-]*"
 # e.g. 999-the-mark-of-fstests
 #
-VALID_TEST_NAME="[0-9]\{3\}-\?[[:alnum:]-]*"
+VALID_TEST_ID="[0-9]\{3\}"
+VALID_TEST_NAME="$VALID_TEST_ID-\?[[:alnum:]-]*"
 
 _require_math()
 {