build: Allow alphanumeric test name suffixes

To allow test names to be more descriptive, allow a suffix to be
added to the numeric name of the test.  e.g. a test can be named
"tests/generic/001-some-descriptive-name".

Name suffixes are limited to alphanumeric characters and dash - the
name is always prefixed with an unique id for easy identification
of a specific test. Hence we can still use shorthand forms such as
"generic/001" when referring to a test and be clearly understood.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Jan Tulak
2015-04-02 09:23:10 +11:00
committed by Dave Chinner
parent 856ff26884
commit 03c633bff6
4 changed files with 70 additions and 11 deletions
+7 -1
View File
@@ -202,10 +202,16 @@ Test script environment:
- When calling getfacl in a test, pass the "-n" argument so - When calling getfacl in a test, pass the "-n" argument so
that numeric rather than symbolic identifiers are used in that numeric rather than symbolic identifiers are used in
the output. the output.
- When creating a new test, it is possible to enter a custom name
for the file. Filenames are in form NNN-custom-name, where NNN
is automatically added by the ./new script as an unique ID,
and "custom-name" is the optional string entered into a prompt
in the ./new script. It can contain only alphanumeric characters
and dash. Note the "NNN-" part is added automatically.
Verified output: Verified output:
Each test script has a numerical name, e.g. 007, and an associated Each test script has a name, e.g. 007, and an associated
verified output, e.g. 007.out. verified output, e.g. 007.out.
It is important that the verified output is deterministic, and It is important that the verified output is deterministic, and
+4 -5
View File
@@ -58,7 +58,6 @@ then
exit 1 exit 1
fi fi
SUPPORTED_TESTS="[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]"
SRC_GROUPS="generic shared" SRC_GROUPS="generic shared"
export SRC_DIR="tests" export SRC_DIR="tests"
@@ -96,21 +95,21 @@ get_group_list()
l=$(sed -n < $SRC_DIR/$d/group \ l=$(sed -n < $SRC_DIR/$d/group \
-e 's/#.*//' \ -e 's/#.*//' \
-e 's/$/ /' \ -e 's/$/ /' \
-e "s;\(^[0-9][0-9][0-9]\).* $grp .*;$SRC_DIR/$d/\1;p") -e "s;^\($VALID_TEST_NAME\).* $grp .*;$SRC_DIR/$d/\1;p")
grpl="$grpl $l" grpl="$grpl $l"
done done
echo $grpl echo $grpl
} }
# find all tests, excluding files that are test metadata such as group files. # Find all tests, excluding files that are test metadata such as group files.
# This assumes that tests are defined purely by alphanumeric filenames with no # It matches test names against $VALID_TEST_NAME defined in common/rc
# ".xyz" extensions in the name.
get_all_tests() get_all_tests()
{ {
touch $tmp.list touch $tmp.list
for d in $SRC_GROUPS $FSTYP; do for d in $SRC_GROUPS $FSTYP; do
ls $SRC_DIR/$d/* | \ ls $SRC_DIR/$d/* | \
grep -v "\..*" | \ grep -v "\..*" | \
grep "^$SRC_DIR/$d/$VALID_TEST_NAME"| \
grep -v "group\|Makefile" >> $tmp.list 2>/dev/null grep -v "group\|Makefile" >> $tmp.list 2>/dev/null
done done
} }
+10
View File
@@ -22,6 +22,16 @@
BC=$(which bc 2> /dev/null) || BC= BC=$(which bc 2> /dev/null) || BC=
# Valid test names start with 3 digits "NNN":
# "[0-9]\{3\}"
# followed by an optional "-":
# "-\?"
# followed by an optional combination of alphanumeric and "-" chars:
# "[[:alnum:]-]*"
# e.g. 999-the-mark-of-fstests
#
VALID_TEST_NAME="[0-9]\{3\}-\?[[:alnum:]-]*"
_require_math() _require_math()
{ {
if [ -z "$BC" ]; then if [ -z "$BC" ]; then
+49 -5
View File
@@ -81,11 +81,14 @@ line=0
eof=1 eof=1
[ -f "$tdir/group" ] || usage [ -f "$tdir/group" ] || usage
for found in `cat $tdir/group | $AWK_PROG '{ print $1 }'` for found in `cat $tdir/group | tr - ' ' | $AWK_PROG '{ print $1 }'`
do do
line=$((line+1)) line=$((line+1))
if [ -z "$found" ] || [ "$found" == "#" ];then if [ -z "$found" ] || [ "$found" == "#" ]; then
continue continue
elif ! echo "$found" | grep -q "^$VALID_TEST_NAME$"; then
# this one is for tests not named by a number
continue
fi fi
i=$((i+1)) i=$((i+1))
id=`printf "%03d" $i` id=`printf "%03d" $i`
@@ -100,7 +103,48 @@ if [ $eof -eq 1 ]; then
id=`printf "%03d" $i` id=`printf "%03d" $i`
fi fi
echo "Next test is $id" echo "Next test id is $id"
read -p "Append a name to the ID? Test name will be $id-\$name. y,[n]: " -r
if [[ $REPLY = [Yy] ]]; then
# get the new name from user
name=""
while [ "$name" = "" ]; do
read -p "Enter the name: "
if [ "$REPLY" = "" ]; then
echo "For canceling, use ctrl+c."
elif echo "$id-$REPLY" | grep -q "^$VALID_TEST_NAME$"; then
if [ -e "$tdir/$id-$REPLY" ]; then
echo "File '$id-$REPLY' already exists, use another one."
echo
else
name="$REPLY"
fi
else
echo "A name can contain only alphanumeric symbols and dash!"
echo
fi
done
# now find where to insert this name
eof=1
for found in `tail -n +$line $tdir/group | $AWK_PROG '{ print $1 }'`; do
found_id=$(echo "$found" | cut -d "-" -f 1 - )
line=$((line+1))
if [ -z "$found" ] || [ "$found" == "#" ]; then
continue
elif [ $found_id -gt $id ]; then
eof=0
break
fi
done
if [ $eof -eq 0 ]; then
# If place wasn't found, let $line be the end of the file
line=$((line-1))
fi
id="$id-$name"
fi
echo "Creating test file '$id'"
if [ -f $tdir/$id ] if [ -f $tdir/$id ]
then then
@@ -115,7 +159,7 @@ year=`date +%Y`
cat <<End-of-File >$tdir/$id cat <<End-of-File >$tdir/$id
#! /bin/bash #! /bin/bash
# FS QA Test No. $id # FS QA Test $id
# #
# what am I here for? # what am I here for?
# #