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 modify it
19 # under the terms of version 2 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, but
23 # WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26 # Further, this software is distributed without any warranty that it is
27 # free of the rightful claim of any third person regarding infringement
28 # or the like. Any license provided herein, whether implied or
29 # otherwise, applies only to this software file. Patent licenses, if
30 # any, provided herein do not apply to combinations of this program with
31 # other software, or any other product whatsoever.
33 # You should have received a copy of the GNU General Public License along
34 # with this program; if not, write the Free Software Foundation, Inc., 59
35 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
37 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
38 # Mountain View, CA 94043, or:
42 # For further information regarding this notice, see:
44 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
45 #-----------------------------------------------------------------------
51 echo "QA output created by $seq"
53 # get standard environment, filters and checks
61 trap "_cleanup; rm -f $tmp.*; exit \$status" 0 1 2 3 15
63 # real QA test starts here
64 _supported_fs xfs udf nfs
65 _supported_os IRIX Linux
68 verify=$here/verify_fill
72 # use the default config
74 cat <<End-of-File >$tmp.config
75 # pathname size in bytes
123 echo "Error: cannot open config \"$1\""
127 echo "Usage: run [config]"
131 ncopy=200 # number of file copies in the chain step
132 udf_fsize=20240 # number of sectors for UDF
136 if mkdir -p $testdir/$$
140 echo "Error: cannot mkdir \"$testdir/$$\""
145 $verbose && echo -n "setup "
146 sed -e '/^#/d' $tmp.config \
147 | while read file nbytes
159 echo "Error: cannot mkdir \"$dir\""
165 if $here/src/fill $file $file $nbytes
170 echo "Error: cannot create \"$file\""
173 $verbose && echo -n "."
180 $verbose && echo -n "mark_iteration "
181 sed -e '/^#/d' $tmp.config \
182 | while read file nbytes
187 echo "Error: $file vanished!"
191 sed -e "s/ [0-9][0-9]* / $1 /" <$file >$file.tmp
193 $verbose && echo -n "."
198 # for each file, make a number of copies forming a chain like foo.0,
199 # foo.1, foo.2, ... foo.N
201 # files are chosen at random, so the lengths of the chains are different
203 # then rename foo.N to foo.last and remove all of the other files in
208 $AWK_PROG -v full_file=$here/$seq.full -v verify=$verify <$tmp.config '
218 for (i=0; i < '$ncopy'; i++) {
219 # choose a file at random, and add one copy to that chain
221 while (j < 0 || j >= nfile)
222 j = int(rand() * nfile)
224 # previous should already exist and next one should not exist
225 printf "if [ ! -f %s ]; then echo \"%s missing!\"; exit; fi\n",file[j],file[j]
226 printf "if [ -f %s.0 ]; then echo \"%s.0 already present!\"; exit; fi\n",file[j],file[j]
227 printf "cp %s %s.0 || exit 1\n",file[j],file[j]
228 printf "ls -i %s.0\n", file[j] >full_file;
229 total_size += size[j]
230 printf "# total size = %d\n", total_size
233 # previous should already exist and next one should not exist
234 printf "if [ ! -f %s.%d ]; then echo \"%s.%d missing!\"; exit; fi\n",file[j],link[j]-1,file[j],link[j]-1
235 printf "if [ -f %s.%d ]; then echo \"%s.%d already present!\"; exit; fi\n",file[j],link[j],file[j],link[j]
236 printf "cp %s.%d %s.%d || exit 1\n",file[j],link[j]-1,file[j],link[j]
237 printf "ls -i %s.%d\n", file[j], link[j] >full_file;
238 total_size += size[j]
239 printf "# total size = %d\n", total_size
243 # close all the chains,
244 # if have at least one copy then move the last copy to "file[j].last"
245 # and remove all of the other files except the head of the chain
246 for (j=0; j<nfile; j++) {
248 printf "mv %s.%d %s.last\n",file[j],link[j]-1,file[j]
249 printf "ls -i %s.last\n", file[j] >full_file;
251 for (i=0; i<link[j]-1; i++) {
252 printf "rm -f %s.%d\n",file[j],i
256 | tee -a $here/$seq.full | sh
262 $verbose && echo -n "check "
263 sed -e '/^#/d' $tmp.config \
264 | while read file nbytes
266 # the file is never removed so it should exist
270 echo "Error: $file vanished!"
274 # checks that the file and its last copy are the same
277 if cmp $file $file.last >/dev/null 2>&1
279 $verbose && echo -n "."
282 echo "Error: corruption for $file ..."
283 diff -c $file $file.last
287 $verbose && echo -n "."
300 elif [ $status -eq 0 ]
302 $verbose && echo "cleanup"
310 rm -f $here/$seq.full
321 for iter in 1 2 3 4 5
323 echo -n "iter $iter chain ... "
324 echo "iter $iter" >> $here/$seq.full
329 echo "Fatal error: test abandoned without changes"