generic/506: mount scratch fs before testing for prjquota presence
[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 _require_scratch
54
55 #
56 # too much hassle to get output matching with quotas turned on
57 # so don't run it
58 #
59 _scratch_mkfs_xfs >> $seqres.full
60 _scratch_mount
61 $here/src/feature -U $SCRATCH_DEV && \
62         _notrun "UQuota enabled, test needs controlled xfsdump output"
63 $here/src/feature -G $SCRATCH_DEV && \
64         _notrun "GQuota enabled, test needs controlled xfsdump output"
65 $here/src/feature -P $SCRATCH_DEV && \
66         _notrun "PQuota enabled, test needs controlled xfsdump output"
67 _scratch_unmount
68
69 #
70 # adding      - touch/echo, mkdir
71 # deleting    - rm, rmdir
72 # renaming    - mv
73 # linking     - ln
74 # unlinking   - rm
75 # files and directories
76 #
77
78 _wipe_fs
79 mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
80 cd $dump_dir
81
82 echo "Do the incremental dumps"
83 i=0
84 num_dumps=8 # do some extra to ensure nothing changes
85 while [ $i -le $num_dumps ]; do
86     cd $dump_dir
87     case $i in
88         0)
89             # adding
90             echo 'add0' >addedfile0
91             echo 'add1' >addedfile1
92             echo 'add2' >addedfile2
93             echo 'add3' >addedfile3
94             mkdir addeddir1
95             mkdir addeddir2
96             mkdir addeddir3
97             mkdir addeddir4
98             echo 'add4' >addeddir3/addedfile4
99             echo 'add5' >addeddir4/addedfile5
100             ;;
101         1)
102             # deleting
103             rm addedfile2
104             rmdir addeddir2
105             rm -rf addeddir3
106             ;;
107         2)
108             # renaming
109             mv addedfile1 addedfile2 # rename to previous existing file
110             mv addeddir4/addedfile5 addeddir4/addedfile4
111             mv addeddir4 addeddir6
112             mv addeddir1 addeddir2 # rename to previous existing dir
113             ;;
114         3)
115             # linking
116             ln addedfile0 linkfile0
117             ln addedfile0 linkfile0_1  # have a 2nd link to file
118             ln addedfile2 linkfile2
119             ln addeddir6/addedfile4 linkfile64
120             ;;
121         4)
122             # unlinking
123             rm linkfile0  # remove a link
124             rm addedfile2 # remove original link
125             rm linkfile64  # remove link
126             rm addeddir6/addedfile4 # remove last link
127             ;;
128         5)  # link first - then onto 6)
129             rm -rf *
130             echo 'add6' >addedfile6
131             ln addedfile6 linkfile6_1
132             ln addedfile6 linkfile6_2
133             ln addedfile6 linkfile6_3
134             ;;
135         6)  # then move the inode that the links point to
136             mv addedfile6 addedfile6_mv
137             rm linkfile6_1
138             rm linkfile6_2
139             rm linkfile6_3
140             ln addedfile6_mv linkfile6_mv_1
141             ln addedfile6_mv linkfile6_mv_2
142             ln addedfile6_mv linkfile6_mv_3
143             ;;
144     esac
145     cd $here
146     sleep 2
147     _stable_fs
148
149     echo "Listing of what files we have at level $i:"
150     _list_dir $dump_dir | tee $tmp.ls.$i
151
152     _do_dump_file -f $tmp.df.level$i -l $i
153     let i=$i+1
154 done
155
156 echo "Look at what files are contained in the inc. dump"
157 i=0
158 while [ $i -le $num_dumps ]; do
159     echo ""
160     echo "restoring from df.level$i"
161     _do_restore_toc -f $tmp.df.level$i
162     let i=$i+1
163 done
164
165 echo "Do the cumulative restores"
166 _prepare_restore_dir
167 i=0
168 while [ $i -le $num_dumps ]; do
169     echo ""
170     echo "restoring from df.level$i"
171     _do_restore_file_cum -f $tmp.df.level$i
172     echo "list restore_dir"
173     _list_dir $restore_dir | _check_quota_file | tee $tmp.restorals.$i
174     let i=$i+1
175 done
176
177 echo ""
178 echo "Do the ls comparison"
179 i=0
180 while [ $i -le $num_dumps ]; do
181     echo "Comparing ls of FS with restored FS at level $i"
182     diff -s $tmp.ls.$i $tmp.restorals.$i | sed "s#$tmp#TMP#g"
183     echo ""
184     let i=$i+1
185 done
186
187 # success, all done
188 status=0
189 exit