xfs/530: skip test if user MKFS_OPTIONS screw up formatting
[xfstests-dev.git] / tests / xfs / 065
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 065
6 #
7 # Testing incremental dumps and cumulative restores with
8 # "adding, deleting, renaming, linking, and unlinking files and
9 #  directories".
10 # Do different operations for each level.
11 #
12 . ./common/preamble
13 _begin_fstest dump auto
14
15 # Override the default cleanup function.
16 _cleanup()
17 {
18         _cleanup_dump
19         cd /
20         rm -f $tmp.*
21 }
22
23 # Import common functions.
24 . ./common/filter
25 . ./common/dump
26 . ./common/quota
27
28 #
29 # list recursively the directory
30 #
31 # e.g. lstat output: src/lstat64 31056 -rwxr-xr-x 38403,0
32 # Don't print out sizes of directories - which can vary - overwrite with XXX.
33 #
34 _list_dir()
35 {
36     __dir=$1
37     find $__dir  -exec $here/src/lstat64 -t {} \; |\
38     sed -e 's/.*dumpdir/dumpdir/' -e '/^dumpdir /d' |\
39     sed -e 's/.*restoredir/restoredir/' -e '/^restoredir /d' |\
40     egrep -v 'housekeeping|dirattr|dirextattr|namreg|state|tree' |\
41     awk '$3 ~ /^d/ { $2 = "XXX" } {print}' |\
42     LC_COLLATE=POSIX sort
43
44
45 # real QA test starts here
46 _supported_fs xfs
47 _require_scratch
48
49 #
50 # too much hassle to get output matching with quotas turned on
51 # so don't run it
52 #
53 _scratch_mkfs_xfs >> $seqres.full
54 _qmount_option noquota
55 _scratch_mount
56 $here/src/feature -U $SCRATCH_DEV && \
57         _notrun "UQuota enabled, test needs controlled xfsdump output"
58 $here/src/feature -G $SCRATCH_DEV && \
59         _notrun "GQuota enabled, test needs controlled xfsdump output"
60 $here/src/feature -P $SCRATCH_DEV && \
61         _notrun "PQuota enabled, test needs controlled xfsdump output"
62 _scratch_unmount
63
64 #
65 # adding      - touch/echo, mkdir
66 # deleting    - rm, rmdir
67 # renaming    - mv
68 # linking     - ln
69 # unlinking   - rm
70 # files and directories
71 #
72
73 _wipe_fs
74 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
75 cd $dump_dir
76
77 echo "Do the incremental dumps"
78 i=0
79 num_dumps=8 # do some extra to ensure nothing changes
80 while [ $i -le $num_dumps ]; do
81     cd $dump_dir
82     case $i in
83         0)
84             # adding
85             echo 'add0' >addedfile0
86             echo 'add1' >addedfile1
87             echo 'add2' >addedfile2
88             echo 'add3' >addedfile3
89             mkdir addeddir1
90             mkdir addeddir2
91             mkdir addeddir3
92             mkdir addeddir4
93             echo 'add4' >addeddir3/addedfile4
94             echo 'add5' >addeddir4/addedfile5
95             ;;
96         1)
97             # deleting
98             rm addedfile2
99             rmdir addeddir2
100             rm -rf addeddir3
101             ;;
102         2)
103             # renaming
104             mv addedfile1 addedfile2 # rename to previous existing file
105             mv addeddir4/addedfile5 addeddir4/addedfile4
106             mv addeddir4 addeddir6
107             mv addeddir1 addeddir2 # rename to previous existing dir
108             ;;
109         3)
110             # linking
111             ln addedfile0 linkfile0
112             ln addedfile0 linkfile0_1  # have a 2nd link to file
113             ln addedfile2 linkfile2
114             ln addeddir6/addedfile4 linkfile64
115             ;;
116         4)
117             # unlinking
118             rm linkfile0  # remove a link
119             rm addedfile2 # remove original link
120             rm linkfile64  # remove link
121             rm addeddir6/addedfile4 # remove last link
122             ;;
123         5)  # link first - then onto 6)
124             rm -rf *
125             echo 'add6' >addedfile6
126             ln addedfile6 linkfile6_1
127             ln addedfile6 linkfile6_2
128             ln addedfile6 linkfile6_3
129             ;;
130         6)  # then move the inode that the links point to
131             mv addedfile6 addedfile6_mv
132             rm linkfile6_1
133             rm linkfile6_2
134             rm linkfile6_3
135             ln addedfile6_mv linkfile6_mv_1
136             ln addedfile6_mv linkfile6_mv_2
137             ln addedfile6_mv linkfile6_mv_3
138             ;;
139     esac
140     cd $here
141     sleep 2
142     _stable_fs
143
144     echo "Listing of what files we have at level $i:"
145     _list_dir $dump_dir | tee $tmp.ls.$i
146
147     _do_dump_file -f $tmp.df.level$i -l $i
148     let i=$i+1
149 done
150
151 echo "Look at what files are contained in the inc. dump"
152 i=0
153 while [ $i -le $num_dumps ]; do
154     echo ""
155     echo "restoring from df.level$i"
156     _do_restore_toc -f $tmp.df.level$i
157     let i=$i+1
158 done
159
160 echo "Do the cumulative restores"
161 _prepare_restore_dir
162 i=0
163 while [ $i -le $num_dumps ]; do
164     echo ""
165     echo "restoring from df.level$i"
166     _do_restore_file_cum -f $tmp.df.level$i
167     echo "list restore_dir"
168     _list_dir $restore_dir | _check_quota_file | tee $tmp.restorals.$i
169     let i=$i+1
170 done
171
172 echo ""
173 echo "Do the ls comparison"
174 i=0
175 while [ $i -le $num_dumps ]; do
176     echo "Comparing ls of FS with restored FS at level $i"
177     diff -s $tmp.ls.$i $tmp.restorals.$i | sed "s#$tmp#TMP#g"
178     echo ""
179     let i=$i+1
180 done
181
182 # success, all done
183 status=0
184 exit