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