fstests: update 'new' script

- Update script to support new test cheme tests/$fs_type/$TEST_IDX
- Try to use first unused ID

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Dmitry Monakhov
2014-11-10 18:01:10 +11:00
committed by Dave Chinner
parent 181ba03728
commit fd730cff44
+62 -23
View File
@@ -32,10 +32,22 @@ _cleanup()
: :
} }
if [ ! -f group ] SRC_GROUPS=`find tests -not -path tests -type d -printf "%f "`
usage()
{
echo "Usage $0 test_dir"
echo "Available dirs are: $SRC_GROUPS"
exit
}
[ $# -eq 0 ] && usage
tdir=tests/$1
shift
if [ ! -f $tdir/group ]
then then
echo "Creating the group index ..." echo "Creating the $tdir/group index ..."
cat <<'End-of-File' >group cat <<'End-of-File' >$tdir/group
# QA groups control # QA groups control
# #
# define groups and default group owners # define groups and default group owners
@@ -51,10 +63,10 @@ other some-user-login
End-of-File End-of-File
fi fi
if [ ! -w group ] if [ ! -w $tdir/group ]
then then
chmod u+w group chmod u+w $tdir/group
echo "Warning: making the index file \"group\" writeable" echo "Warning: making the index file \"$tdir/group\" writeable"
fi fi
if make if make
@@ -64,13 +76,33 @@ else
echo "Warning: make failed -- some tests may be missing" echo "Warning: make failed -- some tests may be missing"
fi fi
last=`grep '^[0-9][0-9]* ' group | sort | tail -1 | sed -e 's/[ ].*//'` i=0
# get rid of leading 0s as can be interpreted as octal line=0
last=`echo $last | sed 's/^0*//'` eof=1
id=`$AWK_PROG </dev/null 'BEGIN{printf "%03d\n",'$last'+1}'` [ -f "$tdir/group" ] || usage
for found in `cat $tdir/group | $AWK_PROG '{ print $1 }'`
do
line=$((line+1))
if [ -z "$found" ] || [ "$found" == "#" ];then
continue
fi
i=$((i+1))
id=`printf "%03d" $i`
if [ "$id" != "$found" ];then
eof=0
break
fi
done
if [ $eof -eq 1 ]; then
line=$((line+1))
i=$((i+1))
id=`printf "%03d" $i`
fi
echo "Next test is $id" echo "Next test is $id"
if [ -f $id ] if [ -f $tdir/$id ]
then then
echo "Error: test $id already exists!" echo "Error: test $id already exists!"
_cleanup _cleanup
@@ -81,7 +113,7 @@ echo -n "Creating skeletal script for you to edit ..."
year=`date +%Y` year=`date +%Y`
cat <<End-of-File >$id cat <<End-of-File >$tdir/$id
#! /bin/bash #! /bin/bash
# FS QA Test No. $id # FS QA Test No. $id
# #
@@ -146,11 +178,12 @@ End-of-File
sleep 2 # latency to read messages to this point sleep 2 # latency to read messages to this point
echo "" echo ""
chmod 755 $id chmod 755 $tdir/$id
${EDITOR-vi} $id ${EDITOR-vi} $tdir/$id
if [ $# -eq 0 ] if [ $# -eq 0 ]
then then
while true while true
do do
echo -n "Add to group(s) [other] (? for list): " echo -n "Add to group(s) [other] (? for list): "
@@ -158,12 +191,15 @@ then
[ -z "$ans" ] && ans=other [ -z "$ans" ] && ans=other
if [ "X$ans" = "X?" ] if [ "X$ans" = "X?" ]
then then
$AWK_PROG <group ' for d in $SRC_GROUPS; do
BEGIN { text = "# ???" } l=$(sed -n < tests/$d/group \
/^[a-z]/ { printf "%-16.16s %s\n",$1,text; text = "# ???"; next } -e 's/#.*//' \
NF < 2 { next } -e 's/$/ /' \
{ text = $0 }' \ -e 's;\(^[0-9][0-9][0-9]\)\(.*$\);\2;p')
| sort grpl="$grpl $l"
done
lst=`for word in $grpl; do echo $word; done | sort| uniq `
echo $lst
else else
break break
fi fi
@@ -173,18 +209,21 @@ else
# #
for g in $* for g in $*
do do
if grep "^$g[ ]" group >/dev/null if grep "^$g[ ]" $tdir/group >/dev/null
then then
: :
else else
echo "Warning: group \"$g\" not defined in ./group" echo "Warning: group \"$g\" not defined in $tdir/group"
fi fi
done done
ans="$*" ans="$*"
fi fi
echo -n "Adding $id to group index ..." echo -n "Adding $id to group index ..."
echo "$id $ans" >>group head -n $(($line-1)) $tdir/group > /tmp/$$.group
echo "$id $ans" >> /tmp/$$.group
tail -n +$((line)) $tdir/group >> /tmp/$$.group
mv /tmp/$$.group $tdir/group
echo " done." echo " done."
exit 0 exit 0