Dont write to /dev/console explicitly, its bad form.
[xfstests-dev.git] / new
1 #! /bin/sh
2 #
3 #-----------------------------------------------------------------------
4 #  Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
5 #  This program is free software; you can redistribute it and/or modify
6 #  it under the terms of the GNU General Public License as published by
7 #  the Free Software Foundation; either version 2 of the License, or
8 #  (at your option) any later version.
9 #
10 #  This program is distributed in the hope that it will 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 to the Free Software
17 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18 #  USA
19 #
20 #  Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
21 #  Mountain View, CA 94043, USA, or: http://www.sgi.com
22 #-----------------------------------------------------------------------
23 #
24 #
25 # Make a new test
26 #
27
28 # generic initialization
29 iam=new
30 . ./common.rc
31
32 trap "rm -f /tmp/$$.; exit" 0 1 2 3 15
33
34 _cleanup()
35 {
36     :
37 }
38
39 if [ ! -f group ]
40 then
41     echo "Creating the group index ..."
42     cat <<'End-of-File' >group
43 # QA groups control
44 #
45 # define groups and default group owners
46 # do not start group name with a digit
47 #
48
49 # catch-all
50 #
51 other           some-user-login
52
53 # test-group association ... one line per test
54 #
55 End-of-File
56 fi
57
58 if [ ! -w group ]
59 then
60     chmod u+w group
61     echo "Warning: making the index file \"group\" writeable"
62 fi
63
64 if make
65 then
66     :
67 else
68     echo "Warning: make failed -- some tests may be missing"
69 fi
70
71 last=`grep '^[0-9][0-9]* ' group | sort | tail -1 | sed -e 's/[         ].*//'`
72 # get rid of leading 0s as can be interpreted as octal
73 last=`echo $last | sed 's/^0*//'`
74 id=`$AWK_PROG </dev/null 'BEGIN{printf "%03d\n",'$last'+1}'`
75 echo "Next test is $id"
76
77 if [ -f $id ]
78 then
79     echo "Error: test $id already exists!"
80     _cleanup
81     exit 1
82 fi
83
84 echo -n "Creating skeletal script for you to edit ..."
85
86 cat <<End-of-File >$id
87 #! /bin/sh
88 # FS QA Test No. $id
89 #
90 # what am I here for?
91 #
92 #-----------------------------------------------------------------------
93 # Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
94
95 # This program is free software; you can redistribute it and/or modify it
96 # under the terms of version 2 of the GNU General Public License as
97 # published by the Free Software Foundation.
98
99 # This program is distributed in the hope that it would be useful, but
100 # WITHOUT ANY WARRANTY; without even the implied warranty of
101 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
102
103 # Further, this software is distributed without any warranty that it is
104 # free of the rightful claim of any third person regarding infringement
105 # or the like.  Any license provided herein, whether implied or
106 # otherwise, applies only to this software file.  Patent licenses, if
107 # any, provided herein do not apply to combinations of this program with
108 # other software, or any other product whatsoever.
109
110 # You should have received a copy of the GNU General Public License along
111 # with this program; if not, write the Free Software Foundation, Inc., 59
112 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
113
114 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
115 # Mountain View, CA  94043, or:
116
117 # http://www.sgi.com 
118
119 # For further information regarding this notice, see: 
120
121 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
122 #-----------------------------------------------------------------------
123 #
124 # creator
125 owner=$USER@`_get_fqdn`
126
127 seq=\`basename \$0\`
128 echo "QA output created by \$seq"
129
130 here=\`pwd\`
131 tmp=/tmp/\$\$
132 status=1        # failure is the default!
133 trap "_cleanup; exit \\\$status" 0 1 2 3 15
134
135 _cleanup()
136 {
137     cd /
138     rm -f \$tmp.*
139 }
140
141 # get standard environment, filters and checks
142 . ./common.rc
143 . ./common.filter
144
145 # real QA test starts here
146
147 # Modify as appropriate.
148 _supported_fs xfs udf nfs
149 _supported_os IRIX Linux
150
151 # if error
152 exit
153
154 # optional stuff if your test has verbose output to help resolve problems
155 #echo
156 #echo "If failure, check \$seq.full (this) and \$seq.full.ok (reference)"
157
158 # success, all done
159 status=0
160 exit
161 End-of-File
162
163 sleep 2         # latency to read messages to this point
164 echo ""
165
166 chmod 755 $id
167 ${EDITOR-vi} $id
168
169 if [ $# -eq 0 ]
170 then
171     while true
172     do
173         echo -n "Add to group(s) [other] (? for list): "
174         read ans
175         [ -z "$ans" ] && ans=other
176         if [ "X$ans" = "X?" ]
177         then
178             $AWK_PROG <group '
179 BEGIN           { text = "# ???" }
180 /^[a-zA-z]/     { printf "%-16.16s %s\n",$1,text; text = "# ???"; next }
181 NF < 2          { next }
182                 { text = $0 }' \
183             | sort
184         else
185             break
186         fi
187     done
188 else
189     # expert mode, groups are on the command line
190     #
191     for g in $*
192     do
193         if grep "^$g[   ]" group >/dev/null
194         then
195             :
196         else
197             echo "Warning: group \"$g\" not defined in ./group"
198         fi
199     done
200     ans="$*"
201 fi
202
203 echo -n "Adding $id to group index ..."
204 echo "$id $ans" >>group
205 echo " done."
206
207 exit 0