xfstests: test speculative preallocation reclaim on ENOSPC/EDQUOT
[xfstests-dev.git] / new
1 #! /bin/bash
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/bash
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
108 seq=\`basename \$0\`
109 seqres=\$RESULT_DIR/\$seq
110 echo "QA output created by \$seq"
111
112 here=\`pwd\`
113 tmp=/tmp/\$\$
114 status=1        # failure is the default!
115 trap "_cleanup; exit \\\$status" 0 1 2 3 15
116
117 _cleanup()
118 {
119     cd /
120     rm -f \$tmp.*
121 }
122
123 # get standard environment, filters and checks
124 . ./common/rc
125 . ./common/filter
126
127 # real QA test starts here
128
129 # Modify as appropriate.
130 _supported_fs generic
131 _supported_os IRIX Linux
132
133 # if error
134 exit
135
136 # optional stuff if your test has verbose output to help resolve problems
137 #echo
138 #echo "If failure, check \$seqres.full (this) and \$seqres.full.ok (reference)"
139
140 # success, all done
141 status=0
142 exit
143 End-of-File
144
145 sleep 2         # latency to read messages to this point
146 echo ""
147
148 chmod 755 $id
149 ${EDITOR-vi} $id
150
151 if [ $# -eq 0 ]
152 then
153     while true
154     do
155         echo -n "Add to group(s) [other] (? for list): "
156         read ans
157         [ -z "$ans" ] && ans=other
158         if [ "X$ans" = "X?" ]
159         then
160             $AWK_PROG <group '
161 BEGIN           { text = "# ???" }
162 /^[a-z]/        { printf "%-16.16s %s\n",$1,text; text = "# ???"; next }
163 NF < 2          { next }
164                 { text = $0 }' \
165             | sort
166         else
167             break
168         fi
169     done
170 else
171     # expert mode, groups are on the command line
172     #
173     for g in $*
174     do
175         if grep "^$g[   ]" group >/dev/null
176         then
177             :
178         else
179             echo "Warning: group \"$g\" not defined in ./group"
180         fi
181     done
182     ans="$*"
183 fi
184
185 echo -n "Adding $id to group index ..."
186 echo "$id $ans" >>group
187 echo " done."
188
189 exit 0