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