xfstests: move generic tests out of top level dir
[xfstests-dev.git] / 065
1 #! /bin/bash
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 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
35
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
39 . ./common.dump
40
41 #
42 # list recursively the directory
43 #
44 # e.g. lstat output: src/lstat64 31056 -rwxr-xr-x 38403,0
45 # Don't print out sizes of directories - which can vary - overwrite with XXX.
46 #
47 _list_dir()
48 {
49     __dir=$1
50     find $__dir  -exec $here/src/lstat64 -t {} \; |\
51     sed -e 's/.*dumpdir/dumpdir/' -e '/^dumpdir /d' |\
52     sed -e 's/.*restoredir/restoredir/' -e '/^restoredir /d' |\
53     egrep -v 'housekeeping|dirattr|dirextattr|namreg|state|tree' |\
54     awk '$3 ~ /^d/ { $2 = "XXX" } {print}' |\
55     LC_COLLATE=POSIX sort
56
57
58 # real QA test starts here
59 _supported_fs xfs
60 _supported_os IRIX Linux
61
62 #
63 # too much hassle to get output matching with quotas turned on
64 # so don't run it
65 #
66 umount $SCRATCH_DEV 2>/dev/null
67 _scratch_mount
68 $here/src/feature -U $SCRATCH_DEV && \
69         _notrun "UQuota enabled, test needs controlled xfsdump output"
70 $here/src/feature -G $SCRATCH_DEV && \
71         _notrun "GQuota enabled, test needs controlled xfsdump output"
72 $here/src/feature -P $SCRATCH_DEV && \
73         _notrun "PQuota enabled, test needs controlled xfsdump output"
74 umount $SCRATCH_DEV
75
76 #
77 # adding      - touch/echo, mkdir
78 # deleting    - rm, rmdir
79 # renaming    - mv
80 # linking     - ln
81 # unlinking   - rm
82 # files and directories
83 #
84
85 _wipe_fs
86 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
87 cd $dump_dir
88
89 echo "Do the incremental dumps"
90 i=0
91 num_dumps=8 # do some extra to ensure nothing changes
92 while [ $i -le $num_dumps ]; do
93     cd $dump_dir
94     case $i in
95         0)
96             # adding
97             echo 'add0' >addedfile0
98             echo 'add1' >addedfile1
99             echo 'add2' >addedfile2
100             echo 'add3' >addedfile3
101             mkdir addeddir1
102             mkdir addeddir2
103             mkdir addeddir3
104             mkdir addeddir4
105             echo 'add4' >addeddir3/addedfile4
106             echo 'add5' >addeddir4/addedfile5
107             ;;
108         1)
109             # deleting
110             rm addedfile2
111             rmdir addeddir2
112             rm -rf addeddir3
113             ;;
114         2)
115             # renaming
116             mv addedfile1 addedfile2 # rename to previous existing file
117             mv addeddir4/addedfile5 addeddir4/addedfile4
118             mv addeddir4 addeddir6
119             mv addeddir1 addeddir2 # rename to previous existing dir
120             ;;
121         3)
122             # linking
123             ln addedfile0 linkfile0
124             ln addedfile0 linkfile0_1  # have a 2nd link to file
125             ln addedfile2 linkfile2
126             ln addeddir6/addedfile4 linkfile64
127             ;;
128         4)
129             # unlinking
130             rm linkfile0  # remove a link
131             rm addedfile2 # remove original link
132             rm linkfile64  # remove link
133             rm addeddir6/addedfile4 # remove last link
134             ;;
135         5)  # link first - then onto 6)
136             rm -rf *
137             echo 'add6' >addedfile6
138             ln addedfile6 linkfile6_1
139             ln addedfile6 linkfile6_2
140             ln addedfile6 linkfile6_3
141             ;;
142         6)  # then move the inode that the links point to
143             mv addedfile6 addedfile6_mv
144             rm linkfile6_1
145             rm linkfile6_2
146             rm linkfile6_3
147             ln addedfile6_mv linkfile6_mv_1
148             ln addedfile6_mv linkfile6_mv_2
149             ln addedfile6_mv linkfile6_mv_3
150             ;;
151     esac
152     cd $here
153     sleep 2
154     _stable_fs
155
156     echo "Listing of what files we have at level $i:"
157     _list_dir $dump_dir | tee $tmp.ls.$i
158
159     _do_dump_file -f $tmp.df.level$i -l $i
160     let i=$i+1
161 done
162
163 echo "Look at what files are contained in the inc. dump"
164 i=0
165 while [ $i -le $num_dumps ]; do
166     echo ""
167     echo "restoring from df.level$i"
168     _do_restore_toc -f $tmp.df.level$i
169     let i=$i+1
170 done
171
172 echo "Do the cumulative restores"
173 _prepare_restore_dir
174 i=0
175 while [ $i -le $num_dumps ]; do
176     echo ""
177     echo "restoring from df.level$i"
178     _do_restore_file_cum -f $tmp.df.level$i
179     echo "list restore_dir"
180     _list_dir $restore_dir | _check_quota_file | tee $tmp.restorals.$i
181     let i=$i+1
182 done
183
184 echo ""
185 echo "Do the ls comparison"
186 i=0
187 while [ $i -le $num_dumps ]; do
188     echo "Comparing ls of FS with restored FS at level $i"
189     diff -s $tmp.ls.$i $tmp.restorals.$i | sed "s#$tmp#TMP#g"
190     echo ""
191     let i=$i+1
192 done
193
194
195 # success, all done
196 status=0
197 exit