pv 955274, rv bnaujok - add 1sec delay between file creation and changing its
[xfstests-dev.git] / 065
1 #! /bin/sh
2 # FS QA Test No. 065
3 #
4 # Testing incremental dumps and cumulative restores with
5 # "adding, deleting, renaming, linking, and unlinking files and
6 #  directories".
7 # Do different operations for each level.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2000, 2002 Silicon Graphics, Inc.  All Rights Reserved.
11 #-----------------------------------------------------------------------
12 #
13 # creator
14 owner=tes@sgi.com
15
16 seq=`basename $0`
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1        # failure is the default!
22 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
23
24 # get standard environment, filters and checks
25 . ./common.rc
26 . ./common.filter
27 . ./common.dump
28
29 #
30 # list recursively the directory
31 #
32 # e.g. lstat output: src/lstat64 31056 -rwxr-xr-x 38403,0
33 # Don't print out sizes of directories - which can vary - overwrite with XXX.
34 #
35 _list_dir()
36 {
37     __dir=$1
38     find $__dir  -exec $here/src/lstat64 -t {} \; |\
39     sed -e 's/.*dumpdir/dumpdir/' -e '/^dumpdir /d' |\
40     sed -e 's/.*restoredir/restoredir/' -e '/^restoredir /d' |\
41     egrep -v 'housekeeping|dirattr|dirextattr|namreg|state|tree' |\
42     awk '$3 ~ /^d/ { $2 = "XXX" } {print}' |\
43     LC_COLLATE=POSIX sort
44
45
46 # real QA test starts here
47 _supported_fs xfs
48 _supported_os IRIX Linux
49
50 #
51 # too much hassle to get output matching with quotas turned on
52 # so don't run it
53 #
54 umount $SCRATCH_DEV 2>/dev/null
55 _scratch_mount
56 $here/src/feature -U $SCRATCH_DEV && \
57         _notrun "UQuota enabled, test needs controlled xfsdump output"
58 $here/src/feature -G $SCRATCH_DEV && \
59         _notrun "GQuota enabled, test needs controlled xfsdump output"
60 $here/src/feature -P $SCRATCH_DEV && \
61         _notrun "PQuota enabled, test needs controlled xfsdump output"
62 umount $SCRATCH_DEV
63
64 #
65 # adding      - touch/echo, mkdir
66 # deleting    - rm, rmdir
67 # renaming    - mv
68 # linking     - ln
69 # unlinking   - rm
70 # files and directories
71 #
72
73 _wipe_fs
74 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
75 cd $dump_dir
76
77 echo "Do the incremental dumps"
78 i=0
79 num_dumps=8 # do some extra to ensure nothing changes
80 while [ $i -le $num_dumps ]; do
81     cd $dump_dir
82     case $i in
83         0)
84             # adding
85             echo 'add0' >addedfile0
86             echo 'add1' >addedfile1
87             echo 'add2' >addedfile2
88             echo 'add3' >addedfile3
89             mkdir addeddir1
90             mkdir addeddir2
91             mkdir addeddir3
92             mkdir addeddir4
93             echo 'add4' >addeddir3/addedfile4
94             echo 'add5' >addeddir4/addedfile5
95             ;;
96         1)
97             # deleting
98             rm addedfile2
99             rmdir addeddir2
100             rm -rf addeddir3
101             ;;
102         2)
103             # renaming
104             mv addedfile1 addedfile2 # rename to previous existing file
105             mv addeddir4/addedfile5 addeddir4/addedfile4
106             mv addeddir4 addeddir6
107             mv addeddir1 addeddir2 # rename to previous existing dir
108             ;;
109         3)
110             # linking
111             ln addedfile0 linkfile0
112             ln addedfile0 linkfile0_1  # have a 2nd link to file
113             ln addedfile2 linkfile2
114             ln addeddir6/addedfile4 linkfile64
115             ;;
116         4)
117             # unlinking
118             rm linkfile0  # remove a link
119             rm addedfile2 # remove original link
120             rm linkfile64  # remove link
121             rm addeddir6/addedfile4 # remove last link
122             ;;
123         5)  # link first - then onto 6)
124             rm -rf *
125             echo 'add6' >addedfile6
126             ln addedfile6 linkfile6_1
127             ln addedfile6 linkfile6_2
128             ln addedfile6 linkfile6_3
129             ;;
130         6)  # then move the inode that the links point to
131             mv addedfile6 addedfile6_mv
132             rm linkfile6_1
133             rm linkfile6_2
134             rm linkfile6_3
135             ln addedfile6_mv linkfile6_mv_1
136             ln addedfile6_mv linkfile6_mv_2
137             ln addedfile6_mv linkfile6_mv_3
138             ;;
139     esac
140     cd $here
141     sleep 2
142     _stable_fs
143
144     echo "Listing of what files we have at level $i:"
145     _list_dir $dump_dir | tee $tmp.ls.$i
146
147     dump_file=$tmp.df.level$i
148     _do_dump_file -l $i
149     i=`expr $i + 1`
150 done
151
152 echo "Look at what files are contained in the inc. dump"
153 i=0
154 while [ $i -le $num_dumps ]; do
155     echo ""
156     echo "restoring from df.level$i"
157     dump_file=$tmp.df.level$i
158     _do_restore_toc
159     i=`expr $i + 1`
160 done
161
162 echo "Do the cumulative restores"
163 i=0
164 while [ $i -le $num_dumps ]; do
165     dump_file=$tmp.df.level$i
166     echo ""
167     echo "restoring from df.level$i"
168     _do_restore_file_cum -l $i
169     echo "list restore_dir"
170     _list_dir $restore_dir | _check_quota_file | tee $tmp.restorals.$i
171     i=`expr $i + 1`
172 done
173
174 echo ""
175 echo "Do the ls comparison"
176 i=0
177 while [ $i -le $num_dumps ]; do
178     echo "Comparing ls of FS with restored FS at level $i"
179     diff -s $tmp.ls.$i $tmp.restorals.$i | sed "s#$tmp#TMP#g"
180     echo ""
181     i=`expr $i + 1`
182 done
183
184
185 # success, all done
186 status=0
187 exit