c4da1ff2ea5b0c253324b01fb1f6d95c19a68242
[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 modify it
13 # under the terms of version 2 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, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20 # Further, this software is distributed without any warranty that it is
21 # free of the rightful claim of any third person regarding infringement
22 # or the like.  Any license provided herein, whether implied or
23 # otherwise, applies only to this software file.  Patent licenses, if
24 # any, provided herein do not apply to combinations of this program with
25 # other software, or any other product whatsoever.
26
27 # You should have received a copy of the GNU General Public License along
28 # with this program; if not, write the Free Software Foundation, Inc., 59
29 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
30
31 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
32 # Mountain View, CA  94043, or:
33
34 # http://www.sgi.com 
35
36 # For further information regarding this notice, see: 
37
38 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 #-----------------------------------------------------------------------
40 #
41 # creator
42 owner=tes@sgi.com
43
44 seq=`basename $0`
45 echo "QA output created by $seq"
46
47 here=`pwd`
48 tmp=/tmp/$$
49 status=1        # failure is the default!
50 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
51
52 # get standard environment, filters and checks
53 . ./common.rc
54 . ./common.filter
55 . ./common.dump
56
57 _my_ls_filter()
58 {
59     #
60     # Print size ($5) and fname ($9).
61     # The size is significant since we add to the file as part
62     # of a file change for the incremental.
63     #
64     # Filter out the housekeeping files of xfsrestore
65     # Filter out toplevel "dumpdir/$" report.
66     #
67     $AWK_PROG '
68         NF == 9 && $0 ~ /dir/ { print $9; next }
69         NF == 9 { print $5, $9; next }
70         NF == 1 { print } ' |\
71     sed -e 's/.*dumpdir/dumpdir/' |\
72     egrep -v 'housekeeping|dirattr|dirextattr|namreg|state|tree|dumpdir/$|dumpdir:$' |\
73     egrep -v "$restore_dir:" 
74 }
75
76 # real QA test starts here
77 _supported_fs xfs
78 _supported_os IRIX Linux
79
80 #
81 # too much hassle to get output matching with quotas turned on
82 # so don't run it
83 #
84 umount $SCRATCH_DEV 2>/dev/null
85 _scratch_mount
86 $here/src/feature -U $SCRATCH_DEV && \
87         _notrun "Quota enabled, test needs controlled xfsdump output"
88 $here/src/feature -G $SCRATCH_DEV && \
89         _notrun "Quota enabled, test needs controlled xfsdump output"
90 umount $SCRATCH_DEV
91
92 #
93 # adding      - touch/echo, mkdir
94 # deleting    - rm, rmdir
95 # renaming    - mv
96 # linking     - ln
97 # unlinking   - rm
98 # files and directories
99 #
100
101 _wipe_fs
102 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
103 cd $dump_dir
104
105 echo "Do the incremental dumps"
106 i=0
107 num_dumps=8 # do some extra to ensure nothing changes
108 while [ $i -le $num_dumps ]; do
109     cd $dump_dir
110     case $i in
111         0)
112             # adding
113             echo 'add0' >addedfile0
114             echo 'add1' >addedfile1
115             echo 'add2' >addedfile2
116             echo 'add3' >addedfile3
117             mkdir addeddir1
118             mkdir addeddir2
119             mkdir addeddir3
120             mkdir addeddir4
121             echo 'add4' >addeddir3/addedfile4
122             echo 'add5' >addeddir4/addedfile5
123             ;;
124         1)
125             # deleting
126             rm addedfile2 
127             rmdir addeddir2 
128             rm -rf addeddir3
129             ;;
130         2) 
131             # renaming
132             mv addedfile1 addedfile2 # rename to previous existing file
133             mv addeddir4/addedfile5 addeddir4/addedfile4
134             mv addeddir4 addeddir6
135             mv addeddir1 addeddir2 # rename to previous existing dir
136             ;;
137         3)
138             # linking
139             ln addedfile0 linkfile0 
140             ln addedfile0 linkfile0_1  # have a 2nd link to file
141             ln addedfile2 linkfile2
142             ln addeddir6/addedfile4 linkfile64
143             ;;
144         4)
145             # unlinking
146             rm linkfile0  # remove a link
147             rm addedfile2 # remove original link
148             rm linkfile64  # remove link
149             rm addeddir6/addedfile4 # remove last link
150             ;;
151         5)  # link first - then onto 6)
152             rm -rf *
153             echo 'add6' >addedfile6
154             ln addedfile6 linkfile6_1 
155             ln addedfile6 linkfile6_2 
156             ln addedfile6 linkfile6_3 
157             ;;
158         6)  # then move the inode that the links point to
159             mv addedfile6 addedfile6_mv 
160             rm linkfile6_1
161             rm linkfile6_2
162             rm linkfile6_3
163             ln addedfile6_mv linkfile6_mv_1
164             ln addedfile6_mv linkfile6_mv_2 
165             ln addedfile6_mv linkfile6_mv_3 
166             ;;
167     esac
168     cd $here
169     sleep 2
170     _stable_fs
171
172     echo "Listing of what files we have at level $i:"
173     ls -lRF $dump_dir | _my_ls_filter | tee $tmp.ls.$i
174
175     dump_file=$tmp.df.level$i
176     _do_dump_file -l $i
177     i=`expr $i + 1`     
178 done
179
180 echo "Look at what files are contained in the inc. dump"
181 i=0
182 while [ $i -le $num_dumps ]; do
183     echo ""
184     echo "restoring from df.level$i"
185     dump_file=$tmp.df.level$i
186     _do_restore_toc
187     i=`expr $i + 1`     
188 done
189
190 echo "Do the cumulative restores"
191 i=0
192 while [ $i -le $num_dumps ]; do
193     dump_file=$tmp.df.level$i
194     echo ""
195     echo "restoring from df.level$i"
196     _do_restore_file_cum -l $i
197     echo "ls -lRF restore_dir"
198     ls -lRF $restore_dir | _my_ls_filter |\
199     _check_quota_file | tee $tmp.restorals.$i
200     i=`expr $i + 1`     
201 done
202
203 echo ""
204 echo "Do the ls comparison"
205 i=0
206 while [ $i -le $num_dumps ]; do
207     echo "Comparing ls of FS with restored FS at level $i"
208     diff -s $tmp.ls.$i $tmp.restorals.$i | sed "s#$tmp#TMP#g"
209     echo ""
210     i=`expr $i + 1`     
211 done
212
213
214 # success, all done
215 status=0
216 exit