6 # Random file copier to produce chains of identical files so the head
7 # and the tail cna be diff'd at then end of each iteration.
9 # Exercises creat, write and unlink for a variety of directory sizes, and
10 # checks for data corruption.
14 # config has one line per file with filename and byte size, else use
15 # the default one below.
17 #-----------------------------------------------------------------------
18 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
20 # This program is free software; you can redistribute it and/or modify it
21 # under the terms of version 2 of the GNU General Public License as
22 # published by the Free Software Foundation.
24 # This program is distributed in the hope that it would be useful, but
25 # WITHOUT ANY WARRANTY; without even the implied warranty of
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
28 # Further, this software is distributed without any warranty that it is
29 # free of the rightful claim of any third person regarding infringement
30 # or the like. Any license provided herein, whether implied or
31 # otherwise, applies only to this software file. Patent licenses, if
32 # any, provided herein do not apply to combinations of this program with
33 # other software, or any other product whatsoever.
35 # You should have received a copy of the GNU General Public License along
36 # with this program; if not, write the Free Software Foundation, Inc., 59
37 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
39 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
40 # Mountain View, CA 94043, or:
44 # For further information regarding this notice, see:
46 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
47 #-----------------------------------------------------------------------
50 owner=kenmcd@bruce.melbourne.sgi.com
53 echo "QA output created by $seq"
55 # get standard environment, filters and checks
63 trap "_cleanup; rm -f $tmp.*; exit \$status" 0 1 2 3 15
65 # real QA test starts here
71 # use the default config
73 cat <<End-of-File >$tmp.config
74 # pathname size in bytes
122 echo "Error: cannot open config \"$1\""
126 echo "Usage: run [config]"
130 ncopy=200 # number of file copies in the chain step
134 if mkdir -p $TEST_DIR/$$
138 echo "Error: cannot mkdir \"$TEST_DIR/$$\""
143 $verbose && echo -n "setup "
144 sed -e '/^#/d' $tmp.config \
145 | while read file nbytes
157 echo "Error: cannot mkdir \"$dir\""
163 if $here/src/fill $file $file $nbytes
168 echo "Error: cannot create \"$file\""
171 $verbose && echo -n "."
178 $verbose && echo -n "mark_iteration "
179 sed -e '/^#/d' $tmp.config \
180 | while read file nbytes
185 echo "Error: $file vanished!"
189 sed -e "s/ [0-9][0-9]* / $1 /" <$file >$file.tmp
191 $verbose && echo -n "."
196 # for each file, make a number of copies forming a chain like foo.0,
197 # foo.1, foo.2, ... foo.N
199 # files are chosen at random, so the lengths of the chains are different
201 # then rename foo.N to foo.last and remove all of the other files in
206 $AWK_PROG <$tmp.config '
214 for (i=0; i < '$ncopy'; i++) {
215 # choose a file at random, and add one copy to that chain
217 while (j < 0 || j >= nfile)
218 j = int(rand() * nfile)
220 printf "if [ ! -f %s ]; then echo \"%s missing!\"; exit; fi\n",file[j],file[j]
221 printf "if [ -f %s.0 ]; then echo \"%s.0 already present!\"; exit; fi\n",file[j],file[j]
222 printf "cp %s %s.0\n",file[j],file[j]
225 printf "if [ ! -f %s.%d ]; then echo \"%s.%d missing!\"; exit; fi\n",file[j],link[j]-1,file[j],link[j]-1
226 printf "if [ -f %s.%d ]; then echo \"%s.%d already present!\"; exit; fi\n",file[j],link[j],file[j],link[j]
227 printf "cp %s.%d %s.%d\n",file[j],link[j]-1,file[j],link[j]
231 # close all the chains, and remove all of the files except
232 # the head of the chain
233 for (j=0; j<nfile; j++) {
235 printf "mv %s.%d %s.last\n",file[j],link[j]-1,file[j]
236 for (i=0; i<link[j]-1; i++) {
237 printf "rm -f %s.%d\n",file[j],i
247 $verbose && echo -n "check "
248 sed -e '/^#/d' $tmp.config \
249 | while read file nbytes
254 echo "Error: $file vanished!"
260 if cmp $file $file.last >/dev/null 2>&1
262 $verbose && echo -n "."
265 echo "Error: corruption for $file ..."
266 diff -c $file $file.last
270 $verbose && echo -n "."
283 elif [ $status -eq 0 ]
285 $verbose && echo "cleanup"
301 for iter in 1 2 3 4 5
303 echo -n "iter $iter chain ... "
308 echo "Fatal error: test abandoned without changes"