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