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 seqres=$RESULT_DIR/$seq
36 seqres=$RESULT_DIR/$seq
37 seqres=$RESULT_DIR/$seq
38 echo "QA output created by $seq"
40 # get standard environment, filters and checks
48 trap "_cleanup; rm -f $tmp.*; exit \$status" 0 1 2 3 15
50 # real QA test starts here
52 _supported_os IRIX Linux
55 verify=$here/verify_fill
59 # use the default config
61 cat <<End-of-File >$tmp.config
62 # pathname size in bytes
110 echo "Error: cannot open config \"$1\""
114 echo "Usage: run [config]"
118 ncopy=200 # number of file copies in the chain step
119 udf_fsize=20240 # number of sectors for UDF
123 if mkdir -p $testdir/$$
127 echo "Error: cannot mkdir \"$testdir/$$\""
132 $verbose && echo -n "setup "
133 sed -e '/^#/d' $tmp.config \
134 | while read file nbytes
146 echo "Error: cannot mkdir \"$dir\""
152 if $here/src/fill $file $file $nbytes
157 echo "Error: cannot create \"$file\""
160 $verbose && echo -n "."
167 $verbose && echo -n "mark_iteration "
168 sed -e '/^#/d' $tmp.config \
169 | while read file nbytes
174 echo "Error: $file vanished!"
178 sed -e "s/ [0-9][0-9]* / $1 /" <$file >$file.tmp
180 $verbose && echo -n "."
185 # for each file, make a number of copies forming a chain like foo.0,
186 # foo.1, foo.2, ... foo.N
188 # files are chosen at random, so the lengths of the chains are different
190 # then rename foo.N to foo.last and remove all of the other files in
195 $AWK_PROG -v full_file=$here/$seqres.full -v verify=$verify <$tmp.config '
205 for (i=0; i < '$ncopy'; i++) {
206 # choose a file at random, and add one copy to that chain
208 while (j < 0 || j >= nfile)
209 j = int(rand() * nfile)
211 # previous should already exist and next one should not exist
212 printf "if [ ! -f %s ]; then echo \"%s missing!\"; exit; fi\n",file[j],file[j]
213 printf "if [ -f %s.0 ]; then echo \"%s.0 already present!\"; exit; fi\n",file[j],file[j]
214 printf "cp %s %s.0 || exit 1\n",file[j],file[j]
215 printf "ls -i %s.0\n", file[j] >full_file;
216 total_size += size[j]
217 printf "# total size = %d\n", total_size
220 # previous should already exist and next one should not exist
221 printf "if [ ! -f %s.%d ]; then echo \"%s.%d missing!\"; exit; fi\n",file[j],link[j]-1,file[j],link[j]-1
222 printf "if [ -f %s.%d ]; then echo \"%s.%d already present!\"; exit; fi\n",file[j],link[j],file[j],link[j]
223 printf "cp %s.%d %s.%d || exit 1\n",file[j],link[j]-1,file[j],link[j]
224 printf "ls -i %s.%d\n", file[j], link[j] >full_file;
225 total_size += size[j]
226 printf "# total size = %d\n", total_size
230 # close all the chains,
231 # if have at least one copy then move the last copy to "file[j].last"
232 # and remove all of the other files except 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 printf "ls -i %s.last\n", file[j] >full_file;
238 for (i=0; i<link[j]-1; i++) {
239 printf "rm -f %s.%d\n",file[j],i
243 | tee -a $here/$seqres.full | sh
249 $verbose && echo -n "check "
250 sed -e '/^#/d' $tmp.config \
251 | while read file nbytes
253 # the file is never removed so it should exist
257 echo "Error: $file vanished!"
261 # checks that the file and its last copy are the same
264 if cmp $file $file.last >/dev/null 2>&1
266 $verbose && echo -n "."
269 echo "Error: corruption for $file ..."
270 diff -c $file $file.last
274 $verbose && echo -n "."
287 elif [ $status -eq 0 ]
289 $verbose && echo "cleanup"
297 rm -f $here/$seqres.full
308 for iter in 1 2 3 4 5
310 echo -n "iter $iter chain ... "
311 echo "iter $iter" >> $here/$seqres.full
316 echo "Fatal error: test abandoned without changes"