4 # Random file copier to produce chains of identical files so the head
5 # and the tail can be diff'd at the end of each iteration.
7 # Exercises creat, write and unlink for a variety of directory sizes, and
8 # checks for data corruption.
12 # config has one line per file with filename and byte size, else use
13 # the default one below.
15 #-----------------------------------------------------------------------
16 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
18 # This program is free software; you can redistribute it and/or
19 # modify it under the terms of the GNU General Public License as
20 # published by the Free Software Foundation.
22 # This program is distributed in the hope that it would be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write the Free Software Foundation,
29 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #-----------------------------------------------------------------------
35 echo "QA output created by $seq"
37 # get standard environment, filters and checks
45 trap "_cleanup; rm -f $tmp.*; exit \$status" 0 1 2 3 15
47 # real QA test starts here
49 _supported_os IRIX Linux
52 verify=$here/verify_fill
56 # use the default config
58 cat <<End-of-File >$tmp.config
59 # pathname size in bytes
107 echo "Error: cannot open config \"$1\""
111 echo "Usage: run [config]"
115 ncopy=200 # number of file copies in the chain step
116 udf_fsize=20240 # number of sectors for UDF
120 if mkdir -p $testdir/$$
124 echo "Error: cannot mkdir \"$testdir/$$\""
129 $verbose && echo -n "setup "
130 sed -e '/^#/d' $tmp.config \
131 | while read file nbytes
143 echo "Error: cannot mkdir \"$dir\""
149 if $here/src/fill $file $file $nbytes
154 echo "Error: cannot create \"$file\""
157 $verbose && echo -n "."
164 $verbose && echo -n "mark_iteration "
165 sed -e '/^#/d' $tmp.config \
166 | while read file nbytes
171 echo "Error: $file vanished!"
175 sed -e "s/ [0-9][0-9]* / $1 /" <$file >$file.tmp
177 $verbose && echo -n "."
182 # for each file, make a number of copies forming a chain like foo.0,
183 # foo.1, foo.2, ... foo.N
185 # files are chosen at random, so the lengths of the chains are different
187 # then rename foo.N to foo.last and remove all of the other files in
192 $AWK_PROG -v full_file=$here/$seq.full -v verify=$verify <$tmp.config '
202 for (i=0; i < '$ncopy'; i++) {
203 # choose a file at random, and add one copy to that chain
205 while (j < 0 || j >= nfile)
206 j = int(rand() * nfile)
208 # previous should already exist and next one should not exist
209 printf "if [ ! -f %s ]; then echo \"%s missing!\"; exit; fi\n",file[j],file[j]
210 printf "if [ -f %s.0 ]; then echo \"%s.0 already present!\"; exit; fi\n",file[j],file[j]
211 printf "cp %s %s.0 || exit 1\n",file[j],file[j]
212 printf "ls -i %s.0\n", file[j] >full_file;
213 total_size += size[j]
214 printf "# total size = %d\n", total_size
217 # previous should already exist and next one should not exist
218 printf "if [ ! -f %s.%d ]; then echo \"%s.%d missing!\"; exit; fi\n",file[j],link[j]-1,file[j],link[j]-1
219 printf "if [ -f %s.%d ]; then echo \"%s.%d already present!\"; exit; fi\n",file[j],link[j],file[j],link[j]
220 printf "cp %s.%d %s.%d || exit 1\n",file[j],link[j]-1,file[j],link[j]
221 printf "ls -i %s.%d\n", file[j], link[j] >full_file;
222 total_size += size[j]
223 printf "# total size = %d\n", total_size
227 # close all the chains,
228 # if have at least one copy then move the last copy to "file[j].last"
229 # and remove all of the other files except the head of the chain
230 for (j=0; j<nfile; j++) {
232 printf "mv %s.%d %s.last\n",file[j],link[j]-1,file[j]
233 printf "ls -i %s.last\n", file[j] >full_file;
235 for (i=0; i<link[j]-1; i++) {
236 printf "rm -f %s.%d\n",file[j],i
240 | tee -a $here/$seq.full | sh
246 $verbose && echo -n "check "
247 sed -e '/^#/d' $tmp.config \
248 | while read file nbytes
250 # the file is never removed so it should exist
254 echo "Error: $file vanished!"
258 # checks that the file and its last copy are the same
261 if cmp $file $file.last >/dev/null 2>&1
263 $verbose && echo -n "."
266 echo "Error: corruption for $file ..."
267 diff -c $file $file.last
271 $verbose && echo -n "."
284 elif [ $status -eq 0 ]
286 $verbose && echo "cleanup"
294 rm -f $here/$seq.full
305 for iter in 1 2 3 4 5
307 echo -n "iter $iter chain ... "
308 echo "iter $iter" >> $here/$seq.full
313 echo "Fatal error: test abandoned without changes"