common/rc: add _scratch_{u}mount_idmapped() helpers
[xfstests-dev.git] / tests / generic / 109
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 109
6 #
7 # Test rename for various sizes of directories. This is motivated by a bug
8 # in XFS where directory entry file type was not updated properly on rename.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27
28 # real QA test starts here
29 _supported_fs generic
30 _require_scratch
31 _require_symlinks
32
33 rm -f $seqres.full
34
35 echo "Silence is golden"
36
37 filldir()
38 {
39         for (( i = 0; i < $1; i++ )); do
40                 echo -n > "fname$i"
41         done
42 }
43
44 # Test renaming of file, symlink over file, symlink, non-existent
45 # name
46 renamedir()
47 {
48         touch fs1
49         touch fs2
50         touch fs3
51         touch fd1
52         touch fd2
53         ln -s foo ss1
54         ln -s foo ss2
55         ln -s foo ss3
56         ln -s foo sd1
57         ln -s foo sd2
58
59         mv -T fs1 fd1
60         mv -T fs2 sd1
61         mv -T fs3 ed1
62
63         mv -T ss1 fd2
64         mv -T ss2 sd2
65         mv -T ss3 ed2
66 }
67
68 _scratch_mkfs >> $seqres.full 2>&1
69 _scratch_mount >> $seqres.full 2>&1
70
71 # Test different directory sizes to test various directory formats
72 for f in 1 2 3 4 5 8 12 18 27 40 60 90 135 202 303 454 681 1020 1530 2295; do
73         mkdir $SCRATCH_MNT/dir$f
74         pushd $SCRATCH_MNT/dir$f >/dev/null
75         filldir $f
76         renamedir
77         popd >/dev/null
78 done
79
80 status=0
81 exit