btrfs: check qgroup doesn't crash when beyond limit
[xfstests-dev.git] / tests / btrfs / 023
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 023
6 #
7 # Test to verify if the group profile is created
8 #
9 # The test aims to create the raid and verify that its created
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22     cd /
23     rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31 _supported_fs btrfs
32 _require_scratch_dev_pool 4
33 rm -f $seqres.full
34
35 create_group_profile()
36 {
37         local mkfs_options="-d$1 -m$1"
38
39         _scratch_pool_mkfs $mkfs_options >> $seqres.full 2>&1 || _fail "mkfs failed"
40 }
41
42 check_group_profile()
43 {
44         local test_raid="$1"
45
46         _scratch_mount
47         $BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT > $tmp.tmp 2>&1
48         _scratch_unmount
49         cat $tmp.tmp >> $seqres.full
50         grep Data $tmp.tmp | grep -q "${test_raid}:"
51         [ $? -eq 0 ] || _fail "$test_raid not found for Data"
52         grep Metadata $tmp.tmp | grep -q "${test_raid}:"
53         [ $? -eq 0 ] || _fail "$test_raid not found for Metadata"
54 }
55
56 create_group_profile "raid0"
57 check_group_profile "RAID0"
58
59 create_group_profile "raid1"
60 check_group_profile "RAID1"
61
62 create_group_profile "raid10"
63 check_group_profile "RAID10"
64
65 if [ -e "/sys/fs/btrfs/features/raid56" ]; then
66         create_group_profile "raid5"
67         check_group_profile "RAID5"
68
69         create_group_profile "raid6"
70         check_group_profile "RAID6"
71 fi
72
73 # success, all done
74 echo "Silence is golden"
75 status=0
76 exit