generic/109: fix status on completion
[xfstests-dev.git] / tests / generic / 109
1 #! /bin/bash
2 # FS QA Test No. 109
3 #
4 # Test rename for various sizes of directories. This is motivated by a bug
5 # in XFS where directory entry file type was not updated properly on rename.
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
9 # Author: Jan Kara <jack@suse.com>
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37         cd /
38         rm -f $tmp.*
39 }
40
41 # get standard environment, filters and checks
42 . ./common/rc
43
44 # real QA test starts here
45 _supported_fs generic
46 _supported_os Linux
47 _require_scratch
48
49 rm -f $seqres.full
50
51 echo "Silence is golden"
52
53 filldir()
54 {
55         for (( i = 0; i < $1; i++ )); do
56                 echo -n > "fname$i"
57         done
58 }
59
60 # Test renaming of file, symlink over file, symlink, non-existent
61 # name
62 renamedir()
63 {
64         touch fs1
65         touch fs2
66         touch fs3
67         touch fd1
68         touch fd2
69         ln -s foo ss1
70         ln -s foo ss2
71         ln -s foo ss3
72         ln -s foo sd1
73         ln -s foo sd2
74
75         mv -T fs1 fd1
76         mv -T fs2 sd1
77         mv -T fs3 ed1
78
79         mv -T ss1 fd2
80         mv -T ss2 sd2
81         mv -T ss3 ed2
82 }
83
84 _scratch_mkfs >> $seqres.full 2>&1
85 _scratch_mount >> $seqres.full 2>&1
86
87 # Test different directory sizes to test various directory formats
88 for f in 1 2 3 4 5 8 12 18 27 40 60 90 135 202 303 454 681 1020 1530 2295; do
89         mkdir $SCRATCH_MNT/dir$f
90         pushd $SCRATCH_MNT/dir$f >/dev/null
91         filldir $f
92         renamedir
93         popd >/dev/null
94 done
95
96 status=0
97 exit