common: rework _require_ext4_mkfs_feature
[xfstests-dev.git] / tests / ext4 / 025
1 #! /bin/bash
2 # FS QA Test ext4/025
3 #
4 # Regression test for commit:
5 # 3a4b77c ("ext4: validate s_first_meta_bg at mount time").
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2017 Fujitsu.  All Rights Reserved.
9 # Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #-----------------------------------------------------------------------
24
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36         rm -f $tmp.*
37 }
38
39 # get standard environment and checks
40 . ./common/rc
41 . ./common/filter
42
43 # remove previous $seqres.full before test
44 rm -f $seqres.full
45
46 # real QA test starts here
47 _supported_fs ext4
48 _supported_os Linux
49 _require_scratch_nocheck
50 _require_command "$DEBUGFS_PROG" debugfs
51 _require_scratch_ext4_feature "bigalloc,meta_bg,^resize_inode"
52
53 echo "Create ext4 fs and modify first_meta_bg's value"
54 _scratch_mkfs "-O bigalloc,meta_bg,^resize_inode" >> $seqres.full 2>&1
55
56 # set a big enough first_meta_bg to trigger buffer overrun
57 # 842150400 is from original fuzzed ext4 image in bug report
58 $DEBUGFS_PROG -w -R "ssv first_meta_bg 842150400" $SCRATCH_DEV >> $seqres.full 2>&1
59
60 echo "Try to mount a modified ext4 fs"
61 _scratch_mount >> $seqres.full 2>&1 || echo "Fail to mount ext4 fs expectedly"
62
63 # success, all done
64 status=0
65 exit