xfs: use $XFS_QUOTA_PROG instead of hardcoding xfs_quota
[xfstests-dev.git] / tests / xfs / 220
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2009 Christoph Hellwig.  All Rights Reserved.
4 #
5 # FS QA Test No. 220
6 #
7 # Test quota off handling.
8 #
9 # Based on bug reports from Utako Kusaka <u-kusaka@wm.jp.nec.com> and
10 # Ryota Yamauchi <r-yamauchi@vf.jp.nec.com>.
11 #
12 . ./common/preamble
13 _begin_fstest auto quota quick
14
15 # Override the default cleanup function.
16 _cleanup()
17 {
18         cd /
19         _scratch_unmount >/dev/null 2>&1
20 }
21
22 # Import common functions.
23 . ./common/filter
24 . ./common/quota
25
26 # real QA test starts here
27 _supported_fs xfs
28
29 _require_scratch
30 _require_quota
31
32 # Only mount with the specific quota options mentioned below
33 _qmount_option "defaults"
34
35 echo "Silence is golden."
36
37 # create scratch filesystem
38 _scratch_mkfs_xfs >/dev/null 2>&1
39
40 # mount  with quotas enabled
41 _scratch_mount -o uquota
42
43 # turn off quota
44 $XFS_QUOTA_PROG -x -c off $SCRATCH_DEV
45
46 # and unmount (this used to crash)
47 _scratch_unmount
48
49 # create scratch filesystem
50 _scratch_mkfs_xfs >/dev/null 2>&1
51
52 # mount  with quotas enabled
53 _scratch_mount -o uquota
54
55 # turn off quota and remove space allocated to the quota files
56 # (this used to give wrong ENOSYS returns in 2.6.31)
57 #
58 # The sed expression below replaces a notrun to cater for kernels that have
59 # removed the ability to disable quota accounting at runtime.  On those
60 # kernel this test is rather useless, and in a few years we can drop it.
61 $XFS_QUOTA_PROG -x -c off -c remove $SCRATCH_DEV 2>&1 | \
62         sed -e '/XFS_QUOTARM: Invalid argument/d'
63
64 # and unmount again
65 _scratch_unmount
66
67 status=0
68 exit $status