Fix test output, had some spurious whitespace.
[xfstests-dev.git] / 065
1 #! /bin/sh
2 # XFS 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
58 _my_ls_filter()
59 {
60     #
61     # Print size ($5) and fname ($9).
62     # The size is significant since we add to the file as part
63     # of a file change for the incremental.
64     #
65     # Filter out the housekeeping files of xfsrestore
66     # Filter out toplevel "dumpdir/$" report.
67     #
68     $AWK_PROG '
69         NF == 9 && $0 ~ /dir/ { print $9; next }
70         NF == 9 { print $5, $9; next }
71         NF == 1 { print } ' |\
72     sed -e 's/.*dumpdir/dumpdir/' |\
73     egrep -v 'housekeeping|dirattr|dirextattr|namreg|state|tree|dumpdir/$|dumpdir:$' |\
74     egrep -v "$restore_dir:" 
75 }
76
77 # real QA test starts here
78
79 #
80 # too much hassle to get output matching with quotas turned on
81 # so don't run it
82 #
83 umount $SCRATCH_DEV 2>/dev/null
84 _scratch_mount
85 $here/src/feature -U $SCRATCH_DEV && \
86         _notrun "Quota enabled, test needs controlled xfsdump output"
87 $here/src/feature -G $SCRATCH_DEV && \
88         _notrun "Quota enabled, test needs controlled xfsdump output"
89 umount $SCRATCH_DEV
90
91 #
92 # adding      - touch/echo, mkdir
93 # deleting    - rm, rmdir
94 # renaming    - mv
95 # linking     - ln
96 # unlinking   - rm
97 # files and directories
98 #
99
100 _wipe_fs
101 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
102 cd $dump_dir
103
104 echo "Do the incremental dumps"
105 i=0
106 num_dumps=8 # do some extra to ensure nothing changes
107 while [ $i -le $num_dumps ]; do
108     cd $dump_dir
109     case $i in
110         0)
111             # adding
112             echo 'add0' >addedfile0
113             echo 'add1' >addedfile1
114             echo 'add2' >addedfile2
115             echo 'add3' >addedfile3
116             mkdir addeddir1
117             mkdir addeddir2
118             mkdir addeddir3
119             mkdir addeddir4
120             echo 'add4' >addeddir3/addedfile4
121             echo 'add5' >addeddir4/addedfile5
122             ;;
123         1)
124             # deleting
125             rm addedfile2 
126             rmdir addeddir2 
127             rm -rf addeddir3
128             ;;
129         2) 
130             # renaming
131             mv addedfile1 addedfile2 # rename to previous existing file
132             mv addeddir4/addedfile5 addeddir4/addedfile4
133             mv addeddir4 addeddir6
134             mv addeddir1 addeddir2 # rename to previous existing dir
135             ;;
136         3)
137             # linking
138             ln addedfile0 linkfile0 
139             ln addedfile0 linkfile0_1  # have a 2nd link to file
140             ln addedfile2 linkfile2
141             ln addeddir6/addedfile4 linkfile64
142             ;;
143         4)
144             # unlinking
145             rm linkfile0  # remove a link
146             rm addedfile2 # remove original link
147             rm linkfile64  # remove link
148             rm addeddir6/addedfile4 # remove last link
149             ;;
150         5)  # link first - then onto 6)
151             rm -rf *
152             echo 'add6' >addedfile6
153             ln addedfile6 linkfile6_1 
154             ln addedfile6 linkfile6_2 
155             ln addedfile6 linkfile6_3 
156             ;;
157         6)  # then move the inode that the links point to
158             mv addedfile6 addedfile6_mv 
159             rm linkfile6_1
160             rm linkfile6_2
161             rm linkfile6_3
162             ln addedfile6_mv linkfile6_mv_1
163             ln addedfile6_mv linkfile6_mv_2 
164             ln addedfile6_mv linkfile6_mv_3 
165             ;;
166     esac
167     cd $here
168     sleep 2
169     _stable_fs
170
171     echo "Listing of what files we have at level $i:"
172     ls -lRF $dump_dir | _my_ls_filter | tee $tmp.ls.$i
173
174     dump_file=$tmp.df.level$i
175     _do_dump_file -l $i
176     i=`expr $i + 1`     
177 done
178
179 echo "Look at what files are contained in the inc. dump"
180 i=0
181 while [ $i -le $num_dumps ]; do
182     echo ""
183     echo "restoring from df.level$i"
184     dump_file=$tmp.df.level$i
185     _do_restore_toc
186     i=`expr $i + 1`     
187 done
188
189 echo "Do the cumulative restores"
190 i=0
191 while [ $i -le $num_dumps ]; do
192     dump_file=$tmp.df.level$i
193     echo ""
194     echo "restoring from df.level$i"
195     _do_restore_file_cum -l $i
196     echo "ls -lRF restore_dir"
197     ls -lRF $restore_dir | _my_ls_filter |\
198     _check_quota_file | tee $tmp.restorals.$i
199     i=`expr $i + 1`     
200 done
201
202 echo ""
203 echo "Do the ls comparison"
204 i=0
205 while [ $i -le $num_dumps ]; do
206     echo "Comparing ls of FS with restored FS at level $i"
207     diff -s $tmp.ls.$i $tmp.restorals.$i | sed "s#$tmp#TMP#g"
208     echo ""
209     i=`expr $i + 1`     
210 done
211
212
213 # success, all done
214 status=0
215 exit