QA test updates.
[xfstests-dev.git] / 065
1 #! /bin/sh
2 # XFS QA Test No. 065
3 # $Id: 065,v 1.4 2002/03/06 04:57:59 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, 2002 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 '
70         NF == 9 && $0 ~ /dir/ { print $9; next }
71         NF == 9 { print $5, $9; next }
72         NF == 1 { print } ' |\
73     sed -e 's/.*dumpdir/dumpdir/' |\
74     egrep -v 'housekeeping|dirattr|dirextattr|namreg|state|tree|dumpdir/$|dumpdir:$' |\
75     egrep -v "$restore_dir:" 
76 }
77
78 # real QA test starts here
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 ||\
103     _error "cannot mkdir \"$dump_dir\""
104 cd $dump_dir
105
106 echo "Do the incremental dumps"
107 i=0
108 num_dumps=8 # do some extra to ensure nothing changes
109 while [ $i -le $num_dumps ]; do
110     cd $dump_dir
111     case $i in
112         0)
113             # adding
114             echo 'add0' >addedfile0
115             echo 'add1' >addedfile1
116             echo 'add2' >addedfile2
117             echo 'add3' >addedfile3
118             mkdir addeddir1
119             mkdir addeddir2
120             mkdir addeddir3
121             mkdir addeddir4
122             echo 'add4' >addeddir3/addedfile4
123             echo 'add5' >addeddir4/addedfile5
124             ;;
125         1)
126             # deleting
127             rm addedfile2 
128             rmdir addeddir2 
129             rm -rf addeddir3
130             ;;
131         2) 
132             # renaming
133             mv addedfile1 addedfile2 # rename to previous existing file
134             mv addeddir4/addedfile5 addeddir4/addedfile4
135             mv addeddir4 addeddir6
136             mv addeddir1 addeddir2 # rename to previous existing dir
137             ;;
138         3)
139             # linking
140             ln addedfile0 linkfile0 
141             ln addedfile0 linkfile0_1  # have a 2nd link to file
142             ln addedfile2 linkfile2
143             ln addeddir6/addedfile4 linkfile64
144             ;;
145         4)
146             # unlinking
147             rm linkfile0  # remove a link
148             rm addedfile2 # remove original link
149             rm linkfile64  # remove link
150             rm addeddir6/addedfile4 # remove last link
151             ;;
152         5)  # link first - then onto 6)
153             rm -rf *
154             echo 'add6' >addedfile6
155             ln addedfile6 linkfile6_1 
156             ln addedfile6 linkfile6_2 
157             ln addedfile6 linkfile6_3 
158             ;;
159         6)  # then move the inode that the links point to
160             mv addedfile6 addedfile6_mv 
161             rm linkfile6_1
162             rm linkfile6_2
163             rm linkfile6_3
164             ln addedfile6_mv linkfile6_mv_1
165             ln addedfile6_mv linkfile6_mv_2 
166             ln addedfile6_mv linkfile6_mv_3 
167             ;;
168     esac
169     cd $here
170     sleep 2
171     _stable_fs
172
173     echo "Listing of what files we have at level $i:"
174     ls -lRF $dump_dir | _my_ls_filter | tee $tmp.ls.$i
175
176     dump_file=$tmp.df.level$i
177     _do_dump_file -l $i
178     i=`expr $i + 1`     
179 done
180
181 echo "Look at what files are contained in the inc. dump"
182 i=0
183 while [ $i -le $num_dumps ]; do
184     echo ""
185     echo "restoring from df.level$i"
186     dump_file=$tmp.df.level$i
187     _do_restore_toc
188     i=`expr $i + 1`     
189 done
190
191 echo "Do the cumulative restores"
192 i=0
193 while [ $i -le $num_dumps ]; do
194     dump_file=$tmp.df.level$i
195     echo ""
196     echo "restoring from df.level$i"
197     _do_restore_file_cum -l $i
198     echo "ls -lRF restore_dir"
199     ls -lRF $restore_dir | _my_ls_filter |\
200     _check_quota_file | tee $tmp.restorals.$i
201     i=`expr $i + 1`     
202 done
203
204 echo ""
205 echo "Do the ls comparison"
206 i=0
207 while [ $i -le $num_dumps ]; do
208     echo "Comparing ls of FS with restored FS at level $i"
209     diff -s $tmp.ls.$i $tmp.restorals.$i | sed "s#$tmp#TMP#g"
210     echo ""
211     i=`expr $i + 1`     
212 done
213
214
215 # success, all done
216 status=0
217 exit