3 #-----------------------------------------------------------------------
4 # Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it would be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write the Free Software Foundation,
17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #-----------------------------------------------------------------------
24 # generic initialization
28 trap "rm -f /tmp/$$.; exit" 0 1 2 3 15
35 SRC_GROUPS=`find tests -not -path tests -type d -printf "%f "`
38 echo "Usage $0 test_dir"
39 echo "Available dirs are: $SRC_GROUPS"
47 if [ ! -f $tdir/group ]
49 echo "Creating the $tdir/group index ..."
50 cat <<'End-of-File' >$tdir/group
53 # define groups and default group owners
54 # do not start group name with a digit
61 # test-group association ... one line per test
66 if [ ! -w $tdir/group ]
69 echo "Warning: making the index file \"$tdir/group\" writeable"
76 echo "Warning: make failed -- some tests may be missing"
82 [ -f "$tdir/group" ] || usage
84 export AWK_PROG="$(type -P awk)"
85 [ "$AWK_PROG" = "" ] && { echo "awk not found"; exit; }
87 for found in `cat $tdir/group | tr - ' ' | $AWK_PROG '{ print $1 }'`
90 if [ -z "$found" ] || [ "$found" == "#" ]; then
92 elif ! echo "$found" | grep -q "^$VALID_TEST_NAME$"; then
93 # this one is for tests not named by a number
98 if [ "$id" != "$found" ];then
103 if [ $eof -eq 1 ]; then
106 id=`printf "%03d" $i`
109 echo "Next test id is $id"
111 read -p "Append a name to the ID? Test name will be $id-\$name. y,[n]: " -r
112 if [[ $REPLY = [Yy] ]]; then
113 # get the new name from user
115 while [ "$name" = "" ]; do
116 read -p "Enter the name: "
117 if [ "$REPLY" = "" ]; then
118 echo "For canceling, use ctrl+c."
119 elif echo "$id-$REPLY" | grep -q "^$VALID_TEST_NAME$"; then
120 if [ -e "$tdir/$id-$REPLY" ]; then
121 echo "File '$id-$REPLY' already exists, use another one."
127 echo "A name can contain only alphanumeric symbols and dash!"
132 # now find where to insert this name
134 for found in `tail -n +$line $tdir/group | $AWK_PROG '{ print $1 }'`; do
135 found_id=$(echo "$found" | cut -d "-" -f 1 - )
137 if [ -z "$found" ] || [ "$found" == "#" ]; then
139 elif [ $found_id -gt $id ]; then
144 if [ $eof -eq 0 ]; then
145 # If place wasn't found, let $line be the end of the file
150 echo "Creating test file '$id'"
154 echo "Error: test $id already exists!"
159 echo -n "Creating skeletal script for you to edit ..."
163 cat <<End-of-File >$tdir/$id
167 # what am I here for?
169 #-----------------------------------------------------------------------
170 # Copyright (c) $year YOUR NAME HERE. All Rights Reserved.
172 # This program is free software; you can redistribute it and/or
173 # modify it under the terms of the GNU General Public License as
174 # published by the Free Software Foundation.
176 # This program is distributed in the hope that it would be useful,
177 # but WITHOUT ANY WARRANTY; without even the implied warranty of
178 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
179 # GNU General Public License for more details.
181 # You should have received a copy of the GNU General Public License
182 # along with this program; if not, write the Free Software Foundation,
183 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
184 #-----------------------------------------------------------------------
188 seqres=\$RESULT_DIR/\$seq
189 echo "QA output created by \$seq"
193 status=1 # failure is the default!
194 trap "_cleanup; exit \\\$status" 0 1 2 3 15
202 # get standard environment, filters and checks
206 # remove previous \$seqres.full before test
209 # real QA test starts here
211 # Modify as appropriate.
212 _supported_fs generic
219 # optional stuff if your test has verbose output to help resolve problems
221 #echo "If failure, check \$seqres.full (this) and \$seqres.full.ok (reference)"
228 sleep 2 # latency to read messages to this point
232 ${EDITOR-vi} $tdir/$id
234 # Create default .out file
235 cat <<End-of-File >$tdir/$id.out
236 QA output created by $id
245 echo -n "Add to group(s) [other] (separate by space, ? for list): "
247 [ -z "$ans" ] && ans=other
248 if [ "X$ans" = "X?" ]
250 for d in $SRC_GROUPS; do
251 l=$(sed -n < tests/$d/group \
254 -e 's;\(^[0-9][0-9][0-9]\)\(.*$\);\2;p')
257 lst=`for word in $grpl; do echo $word; done | sort| uniq `
260 # only allow lower cases, spaces, digits and underscore in group
261 inval=`echo $ans | tr -d '[:lower:][:space:][:digit:]_'`
262 if [ "$inval" != "" ]; then
263 echo "Invalid characters in group(s): $inval"
264 echo "Only lower cases, digits and underscore are allowed in groups, separated by space"
267 # remove redundant spaces/tabs
268 ans=`echo "$ans" | sed 's/\s\+/ /g'`
274 # expert mode, groups are on the command line
278 if grep "^$g[ ]" $tdir/group >/dev/null
282 echo "Warning: group \"$g\" not defined in $tdir/group"
288 echo -n "Adding $id to group index ..."
289 head -n $(($line-1)) $tdir/group > /tmp/$$.group
290 echo "$id $ans" >> /tmp/$$.group
291 tail -n +$((line)) $tdir/group >> /tmp/$$.group
292 mv /tmp/$$.group $tdir/group