xfstests: move xfs specific tests out of top directory
[xfstests-dev.git] / tests / xfs / 261
1 #! /bin/bash
2 # FS QA Test No. 261
3 #
4 # This test exercises an issue in libxcmd where a problem with any
5 # mount point or project quota directory causes the program to exit
6 # complete.  The effect of this is that one cannot operate on any
7 # directory, even if the problem directory is completely unrelated
8 # to the directory one wants to operate on.
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2011 SGI.  All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=$(basename $0)
29 echo "QA output created by ${seq}"
30
31 here=$(pwd)
32
33 tmp=/tmp/$$
34 my_mtab=${tmp}.mtab
35
36 mtab=/proc/self/mounts
37
38 status=1        # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 _cleanup()
42 {
43     cd /
44     rm -f ${tmp}.*
45 }
46
47 # get standard environment, filters and checks
48 . ./common.rc
49 . ./common.filter
50 . ./common.quota
51
52 echo "Silence is golden."
53
54 # real QA test starts here
55
56 # Modify as appropriate.
57 _supported_fs xfs
58 _supported_os Linux
59
60 _require_quota
61 _require_scratch
62
63 # Just use the current mount table as an example mtab file.  Odds
64 # are good there's nothing wrong with it.
65 _setup_my_mtab() {
66         cp "${mtab}" "${my_mtab}"
67 }
68
69 # Any bogus entry in the mtab file is enough to trigger the problem.
70 # So just append a bogus entry at the end of the private mtab file.
71 # This matches an actually-observed entry in a mount table (with a
72 # few characters in the paths changed to protect the innocent).
73 _perturb_my_mtab() {
74         cat <<-! >> "${my_mtab}"
75                 /dev/disk/by-id/scsi-3600508e000000000c329ba1d8b0c391b-part3 /tmp/autoY8qcJ9\040(deleted) xfs rw 0 0
76         !
77 }
78
79 _check() {
80         if [ $# -eq 0 ]; then
81                 export MOUNT_OPTIONS=""
82         elif [ $# -eq 1 ]; then
83                 [ $1 = u -o $1 = g -o $1 = p ] || exit
84                 export MOUNT_OPTIONS="-o${1}quota"
85         else
86                 exit
87         fi
88
89         _qmount
90
91         # Set up a private mount table file, then try out a simple quota
92         # command to show mounts
93         _setup_my_mtab
94         echo print | xfs_quota  -t "${my_mtab}" > /dev/null || exit
95
96         # Do the same simple quota command after adding a bogus entry to the
97         # mount table.  Old code will bail on this because it has trouble
98         # with the bogus entry.
99         _perturb_my_mtab
100         echo print | xfs_quota -t "${my_mtab}" > /dev/null || exit
101 }
102
103 #########
104
105 # Mount SCRATCH with no quota options
106 _check
107
108 # user quota enabled
109 _check u
110
111 # group quota enabled
112 _check g
113
114 # user quota enabled
115 _check p
116
117 status=0        # success, all done