xfstests: move xfs specific tests out of top directory
[xfstests-dev.git] / tests / xfs / 196
1 #! /bin/bash
2 # FS QA Test No. 196
3 #
4 # Make sure renames accross project boundaries are properly rejected
5 # and that we don't use the wrong lock flags internally.
6 #
7 # Based on a report and testcase from Arkadiusz Miskiewicz <arekm@maven.pl>
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2008 Christoph Hellwig.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33
34 _cleanup()
35 {
36         cd /
37         umount $SCRATCH_MNT
38         rm -f $tmp.*
39 }
40 trap "_cleanup; exit \$status" 0 1 2 3 15
41
42 # get standard environment, filters and checks
43 . ./common.rc
44 . ./common.filter
45 . ./common.quota
46
47 # real QA test starts here
48 _supported_fs xfs
49 _supported_os Linux
50
51 _require_scratch
52 _require_xfs_quota
53
54 #
55 # Setup temporary replacements for /etc/projects and /etc/projid
56 #
57 cat >$tmp.projects <<EOF
58 42:$SCRATCH_MNT/t
59 EOF
60
61 cat >$tmp.projid <<EOF
62 answer:42
63 EOF
64
65 #
66 # And make sure we always use our replacements
67 #
68 quota_cmd="xfs_quota -D $tmp.projects -P $tmp.projid"
69
70 _scratch_mkfs_xfs >/dev/null 2>&1
71 _qmount_option "pquota"
72 _qmount
73
74 #
75 # Create the project root
76 #
77 mkdir $SCRATCH_MNT/t
78
79 $quota_cmd -x -c 'project -s answer' $SCRATCH_MNT >/dev/null 2>&1
80 $quota_cmd -x -c 'limit -p bhard=100m answer' $SCRATCH_MNT
81
82 touch $SCRATCH_MNT/test
83
84 #
85 # Try renaming a file into the project.  This should fail.
86 #
87 # We repeat this a couple thousand times as a single rename couldn't
88 # always trigger the wrong unlock flags bug we had in older kernels.
89 #
90 for i in `seq 1 2000`; do
91     src/rename test t/test
92 done
93
94 # success, all done
95 echo "*** done"
96 rm -f $seq.full
97 status=0