fix _require_scratch test for extN, resierfs, gfs2, and btrfs
[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 year=`date +%Y`
83
84 cat <<End-of-File >$id
85 #! /bin/sh
86 # FS QA Test No. $id
87 #
88 # what am I here for?
89 #
90 #-----------------------------------------------------------------------
91 # Copyright (c) $year YOUR NAME HERE.  All Rights Reserved.
92 #
93 # This program is free software; you can redistribute it and/or
94 # modify it under the terms of the GNU General Public License as
95 # published by the Free Software Foundation.
96 #
97 # This program is distributed in the hope that it would be useful,
98 # but WITHOUT ANY WARRANTY; without even the implied warranty of
99 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
100 # GNU General Public License for more details.
101 #
102 # You should have received a copy of the GNU General Public License
103 # along with this program; if not, write the Free Software Foundation,
104 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
105 #-----------------------------------------------------------------------
106 #
107 # creator
108 owner=$USER@`_get_fqdn`
109
110 seq=\`basename \$0\`
111 echo "QA output created by \$seq"
112
113 here=\`pwd\`
114 tmp=/tmp/\$\$
115 status=1        # failure is the default!
116 trap "_cleanup; exit \\\$status" 0 1 2 3 15
117
118 _cleanup()
119 {
120     cd /
121     rm -f \$tmp.*
122 }
123
124 # get standard environment, filters and checks
125 . ./common.rc
126 . ./common.filter
127
128 # real QA test starts here
129
130 # Modify as appropriate.
131 _supported_fs generic
132 _supported_os IRIX Linux
133
134 # if error
135 exit
136
137 # optional stuff if your test has verbose output to help resolve problems
138 #echo
139 #echo "If failure, check \$seq.full (this) and \$seq.full.ok (reference)"
140
141 # success, all done
142 status=0
143 exit
144 End-of-File
145
146 sleep 2         # latency to read messages to this point
147 echo ""
148
149 chmod 755 $id
150 ${EDITOR-vi} $id
151
152 if [ $# -eq 0 ]
153 then
154     while true
155     do
156         echo -n "Add to group(s) [other] (? for list): "
157         read ans
158         [ -z "$ans" ] && ans=other
159         if [ "X$ans" = "X?" ]
160         then
161             $AWK_PROG <group '
162 BEGIN           { text = "# ???" }
163 /^[a-z]/        { printf "%-16.16s %s\n",$1,text; text = "# ???"; next }
164 NF < 2          { next }
165                 { text = $0 }' \
166             | sort
167         else
168             break
169         fi
170     done
171 else
172     # expert mode, groups are on the command line
173     #
174     for g in $*
175     do
176         if grep "^$g[   ]" group >/dev/null
177         then
178             :
179         else
180             echo "Warning: group \"$g\" not defined in ./group"
181         fi
182     done
183     ans="$*"
184 fi
185
186 echo -n "Adding $id to group index ..."
187 echo "$id $ans" >>group
188 echo " done."
189
190 exit 0