btrfs/012: check free size of scratch device before copying files
[xfstests-dev.git] / tests / generic / 383
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 383
6 #
7 # Test xfs_quota when project names beginning with digits.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 qa_user=""
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 . ./common/filter
28 . ./common/quota
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # real QA test starts here
34 _supported_fs generic
35 _require_scratch
36 _require_quota
37 _require_xfs_quota_foreign
38
39 _scratch_mkfs >/dev/null 2>&1
40 _scratch_enable_pquota
41
42 do_project_test()
43 {
44         local qa_project=123456-project
45         local dir=$SCRATCH_MNT/project
46
47         mkdir $dir 2>/dev/null
48
49         #project quota files
50         cat >$tmp.projects <<EOF
51 10:$dir
52 EOF
53
54         cat >$tmp.projid <<EOF
55 $qa_project:10
56 EOF
57
58         $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
59                 -c "project -s $qa_project" $SCRATCH_MNT > /dev/null
60
61         # We set & test inodes, because xfs vs ext4 consume differing
62         # amounts of space for an empty dir, but an inode is an inode...
63         $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
64                 -c "limit -p isoft=100 ihard=200 $qa_project" $SCRATCH_MNT
65
66         echo "=== quota command output ==="
67         $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid \
68                 -c "quota -p -v -i $qa_project" $SCRATCH_MNT | _filter_quota
69
70         echo "=== report command output ==="
71         $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
72                 -c "report -p -N -i" $SCRATCH_MNT | _filter_project_quota
73 }
74
75 # Test project
76 _qmount_option "usrquota,prjquota"
77 _qmount
78 _require_prjquota $SCRATCH_DEV
79 do_project_test
80
81 # success, all done
82 status=0
83 exit