QA updates for testing xfs_copy
[xfstests-dev.git] / new
1 #! /bin/sh
2 #
3 # Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
4
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of version 2 of the GNU General Public License as
7 # published by the Free Software Foundation.
8
9 # This program is distributed in the hope that it would be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 # Further, this software is distributed without any warranty that it is
14 # free of the rightful claim of any third person regarding infringement
15 # or the like.  Any license provided herein, whether implied or
16 # otherwise, applies only to this software file.  Patent licenses, if
17 # any, provided herein do not apply to combinations of this program with
18 # other software, or any other product whatsoever.
19
20 # You should have received a copy of the GNU General Public License along
21 # with this program; if not, write the Free Software Foundation, Inc., 59
22 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
23
24 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
25 # Mountain View, CA  94043, or:
26
27 # http://www.sgi.com 
28
29 # For further information regarding this notice, see: 
30
31 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #
33 #
34 # Make a new test
35 #
36
37 # generic initialization
38 iam=new
39 . ./common.rc
40
41 trap "rm -f /tmp/$$.; exit" 0 1 2 3 15
42
43 _cleanup()
44 {
45     :
46 }
47
48 if [ ! -f group ]
49 then
50     echo "Creating the group index ..."
51     cat <<'End-of-File' >group
52 # QA groups control
53 #
54 # define groups and default group owners
55 # do not start group name with a digit
56 #
57
58 # catch-all
59 #
60 other           some-user-login
61
62 # test-group association ... one line per test
63 #
64 End-of-File
65 fi
66
67 if [ ! -w group ]
68 then
69     chmod u+w group
70     echo "Warning: making the index file \"group\" writeable"
71 fi
72
73 if make
74 then
75     :
76 else
77     echo "Warning: make failed -- some tests may be missing"
78 fi
79
80 last=`grep '^[0-9][0-9]* ' group | sort | tail -1 | sed -e 's/[         ].*//'`
81 # get rid of leading 0s as can be interpreted as octal
82 last=`echo $last | sed 's/^0*//'`
83 id=`$AWK_PROG </dev/null 'BEGIN{printf "%03d\n",'$last'+1}'`
84 echo "Next test is $id"
85
86 if [ -f $id ]
87 then
88     echo "Error: test $id already exists!"
89     _cleanup
90     exit 1
91 fi
92
93 echo -n "Creating skeletal script for you to edit ..."
94
95 cat <<End-of-File | sed -e '/rcsId/s//Id: 1.1 /' >$id
96 #! /bin/sh
97 # XFS QA Test No. $id
98 # \$rcsId\$
99 #
100 # what am I here for?
101 #
102 #-----------------------------------------------------------------------
103 # Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
104
105 # This program is free software; you can redistribute it and/or modify it
106 # under the terms of version 2 of the GNU General Public License as
107 # published by the Free Software Foundation.
108
109 # This program is distributed in the hope that it would be useful, but
110 # WITHOUT ANY WARRANTY; without even the implied warranty of
111 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
112
113 # Further, this software is distributed without any warranty that it is
114 # free of the rightful claim of any third person regarding infringement
115 # or the like.  Any license provided herein, whether implied or
116 # otherwise, applies only to this software file.  Patent licenses, if
117 # any, provided herein do not apply to combinations of this program with
118 # other software, or any other product whatsoever.
119
120 # You should have received a copy of the GNU General Public License along
121 # with this program; if not, write the Free Software Foundation, Inc., 59
122 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
123
124 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
125 # Mountain View, CA  94043, or:
126
127 # http://www.sgi.com 
128
129 # For further information regarding this notice, see: 
130
131 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
132 #-----------------------------------------------------------------------
133 #
134 # creator
135 owner=$USER@`_get_fqdn`
136
137 seq=\`basename \$0\`
138 echo "QA output created by \$seq"
139
140 here=\`pwd\`
141 tmp=/tmp/\$\$
142 status=1        # failure is the default!
143 trap "rm -f \$tmp.*; exit \\\$status" 0 1 2 3 15
144
145 # get standard environment, filters and checks
146 . ./common.rc
147 . ./common.filter
148
149 # real QA test starts here
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