45ff163ec2254794e99749ae9b70eaf7a9e4ce32
[xfstests-dev.git] / new
1 #! /bin/sh
2 #
3 #-----------------------------------------------------------------------
4 #  Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
5 #
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.
9 #
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.
14 #
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
18 #
19 #-----------------------------------------------------------------------
20 #
21 # Make a new test
22 #
23
24 # generic initialization
25 iam=new
26 . ./common.rc
27
28 trap "rm -f /tmp/$$.; exit" 0 1 2 3 15
29
30 _cleanup()
31 {
32     :
33 }
34
35 if [ ! -f group ]
36 then
37     echo "Creating the group index ..."
38     cat <<'End-of-File' >group
39 # QA groups control
40 #
41 # define groups and default group owners
42 # do not start group name with a digit
43 #
44
45 # catch-all
46 #
47 other           some-user-login
48
49 # test-group association ... one line per test
50 #
51 End-of-File
52 fi
53
54 if [ ! -w group ]
55 then
56     chmod u+w group
57     echo "Warning: making the index file \"group\" writeable"
58 fi
59
60 if make
61 then
62     :
63 else
64     echo "Warning: make failed -- some tests may be missing"
65 fi
66
67 last=`grep '^[0-9][0-9]* ' group | sort | tail -1 | sed -e 's/[         ].*//'`
68 # get rid of leading 0s as can be interpreted as octal
69 last=`echo $last | sed 's/^0*//'`
70 id=`$AWK_PROG </dev/null 'BEGIN{printf "%03d\n",'$last'+1}'`
71 echo "Next test is $id"
72
73 if [ -f $id ]
74 then
75     echo "Error: test $id already exists!"
76     _cleanup
77     exit 1
78 fi
79
80 echo -n "Creating skeletal script for you to edit ..."
81
82 cat <<End-of-File >$id
83 #! /bin/sh
84 # FS QA Test No. $id
85 #
86 # what am I here for?
87 #
88 #-----------------------------------------------------------------------
89 # Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
90 #-----------------------------------------------------------------------
91 #
92 # creator
93 owner=$USER@`_get_fqdn`
94
95 seq=\`basename \$0\`
96 echo "QA output created by \$seq"
97
98 here=\`pwd\`
99 tmp=/tmp/\$\$
100 status=1        # failure is the default!
101 trap "_cleanup; exit \\\$status" 0 1 2 3 15
102
103 _cleanup()
104 {
105     cd /
106     rm -f \$tmp.*
107 }
108
109 # get standard environment, filters and checks
110 . ./common.rc
111 . ./common.filter
112
113 # real QA test starts here
114
115 # Modify as appropriate.
116 _supported_fs generic
117 _supported_os IRIX Linux
118
119 # if error
120 exit
121
122 # optional stuff if your test has verbose output to help resolve problems
123 #echo
124 #echo "If failure, check \$seq.full (this) and \$seq.full.ok (reference)"
125
126 # success, all done
127 status=0
128 exit
129 End-of-File
130
131 sleep 2         # latency to read messages to this point
132 echo ""
133
134 chmod 755 $id
135 ${EDITOR-vi} $id
136
137 if [ $# -eq 0 ]
138 then
139     while true
140     do
141         echo -n "Add to group(s) [other] (? for list): "
142         read ans
143         [ -z "$ans" ] && ans=other
144         if [ "X$ans" = "X?" ]
145         then
146             $AWK_PROG <group '
147 BEGIN           { text = "# ???" }
148 /^[a-z]/        { printf "%-16.16s %s\n",$1,text; text = "# ???"; next }
149 NF < 2          { next }
150                 { text = $0 }' \
151             | sort
152         else
153             break
154         fi
155     done
156 else
157     # expert mode, groups are on the command line
158     #
159     for g in $*
160     do
161         if grep "^$g[   ]" group >/dev/null
162         then
163             :
164         else
165             echo "Warning: group \"$g\" not defined in ./group"
166         fi
167     done
168     ans="$*"
169 fi
170
171 echo -n "Adding $id to group index ..."
172 echo "$id $ans" >>group
173 echo " done."
174
175 exit 0