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