2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
8 # generic initialization
12 trap "rm -f /tmp/$$.; exit" 0 1 2 3 15
19 SRC_GROUPS=`find tests -not -path tests -type d -printf "%f "`
22 echo "Usage $0 test_dir"
23 echo "Available dirs are: $SRC_GROUPS"
31 if [ ! -f $tdir/group ]
33 echo "Creating the $tdir/group index ..."
34 cat <<'End-of-File' >$tdir/group
37 # define groups and default group owners
38 # do not start group name with a digit
45 # test-group association ... one line per test
50 if [ ! -w $tdir/group ]
53 echo "Warning: making the index file \"$tdir/group\" writeable"
60 echo "Warning: make failed -- some tests may be missing"
66 [ -f "$tdir/group" ] || usage
68 export AWK_PROG="$(type -P awk)"
69 [ "$AWK_PROG" = "" ] && { echo "awk not found"; exit; }
71 for found in `cat $tdir/group | tr - ' ' | $AWK_PROG '{ print $1 }'`
74 if [ -z "$found" ] || [ "$found" == "#" ]; then
76 elif ! echo "$found" | grep -q "^$VALID_TEST_NAME$"; then
77 # this one is for tests not named by a number
82 if [ "$id" != "$found" ];then
87 if [ $eof -eq 1 ]; then
93 echo "Next test id is $id"
95 read -p "Append a name to the ID? Test name will be $id-\$name. y,[n]: " -r
96 if [[ $REPLY = [Yy] ]]; then
97 # get the new name from user
99 while [ "$name" = "" ]; do
100 read -p "Enter the name: "
101 if [ "$REPLY" = "" ]; then
102 echo "For canceling, use ctrl+c."
103 elif echo "$id-$REPLY" | grep -q "^$VALID_TEST_NAME$"; then
104 if [ -e "$tdir/$id-$REPLY" ]; then
105 echo "File '$id-$REPLY' already exists, use another one."
111 echo "A name can contain only alphanumeric symbols and dash!"
116 # now find where to insert this name
118 for found in `tail -n +$line $tdir/group | $AWK_PROG '{ print $1 }'`; do
119 found_id=$(echo "$found" | cut -d "-" -f 1 - )
121 if [ -z "$found" ] || [ "$found" == "#" ]; then
123 elif [ $found_id -gt $id ]; then
128 if [ $eof -eq 0 ]; then
129 # If place wasn't found, let $line be the end of the file
134 echo "Creating test file '$id'"
138 echo "Error: test $id already exists!"
143 echo -n "Creating skeletal script for you to edit ..."
147 cat <<End-of-File >$tdir/$id
149 # SPDX-License-Identifier: GPL-2.0
150 # Copyright (c) $year YOUR NAME HERE. All Rights Reserved.
154 # what am I here for?
157 seqres=\$RESULT_DIR/\$seq
158 echo "QA output created by \$seq"
162 status=1 # failure is the default!
163 trap "_cleanup; exit \\\$status" 0 1 2 3 15
171 # get standard environment, filters and checks
175 # remove previous \$seqres.full before test
178 # real QA test starts here
180 # Modify as appropriate.
181 _supported_fs generic
187 # optional stuff if your test has verbose output to help resolve problems
189 #echo "If failure, check \$seqres.full (this) and \$seqres.full.ok (reference)"
196 sleep 2 # latency to read messages to this point
200 ${EDITOR-vi} $tdir/$id
202 # Create default .out file
203 cat <<End-of-File >$tdir/$id.out
204 QA output created by $id
213 echo -n "Add to group(s) [other] (separate by space, ? for list): "
215 [ -z "$ans" ] && ans=other
216 if [ "X$ans" = "X?" ]
218 for d in $SRC_GROUPS; do
219 l=$(sed -n < tests/$d/group \
222 -e 's;\(^[0-9][0-9][0-9]\)\(.*$\);\2;p')
225 lst=`for word in $grpl; do echo $word; done | sort| uniq `
228 # only allow lower cases, spaces, digits and underscore in group
229 inval=`echo $ans | tr -d '[:lower:][:space:][:digit:]_'`
230 if [ "$inval" != "" ]; then
231 echo "Invalid characters in group(s): $inval"
232 echo "Only lower cases, digits and underscore are allowed in groups, separated by space"
235 # remove redundant spaces/tabs
236 ans=`echo "$ans" | sed 's/\s\+/ /g'`
242 # expert mode, groups are on the command line
246 if grep "^$g[ ]" $tdir/group >/dev/null
250 echo "Warning: group \"$g\" not defined in $tdir/group"
256 echo -n "Adding $id to group index ..."
257 head -n $(($line-1)) $tdir/group > /tmp/$$.group
258 echo "$id $ans" >> /tmp/$$.group
259 tail -n +$((line)) $tdir/group >> /tmp/$$.group
260 mv /tmp/$$.group $tdir/group