populate: add _require_populate_commands to check for tools
[xfstests-dev.git] / tests / xfs / 270
1 #! /bin/bash
2 # FS QA Test 270
3 #
4 # Today ro-compat features can't be mounted rw, but a bug allows
5 # an ro->rw remount transition. This bug has been fixed on linux
6 # kernel (d0a58e8 xfs: disallow rw remount on fs with unknown
7 # ro-compat features), and this case is the regression testcase.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38         cd /
39         rm -f $tmp.*
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45
46 # remove previous $seqres.full before test
47 rm -f $seqres.full
48
49 # real QA test starts here
50 _supported_fs xfs
51 _supported_os Linux
52 # skip fs check because superblock contains unknown ro-compat features
53 _require_scratch_nocheck
54 # Only V5 XFS disallow rw mount/remount with unknown ro-compat features
55 _require_scratch_xfs_crc
56
57 _scratch_mkfs_xfs >>$seqres.full 2>&1
58
59 # set the highest bit of features_ro_compat, use it as an unknown
60 # feature bit. If one day this bit become known feature, please
61 # change this case.
62 $XFS_DB_PROG -x -c "sb 0" -c "write features_ro_compat $((2**31))" $SCRATCH_DEV
63
64 # rw mount with unknown ro-compat feature should fail
65 echo "rw mount test"
66 _scratch_mount 2>>$seqres.full
67 if [ $? -eq 0 ]; then
68         _fail "rw mount test failed"
69 fi
70
71 # But ro mount should succeed
72 echo "ro mount test"
73 _scratch_mount -o ro
74 if [ $? -ne 0 ]; then
75         _fail "ro mount test failed"
76 else
77         # no hang/panic is fine
78         $FSSTRESS_PROG -d $SCRATCH_MNT -p 4 -n 400 >>$seqres.full 2>&1
79 fi
80
81 # remount as rw, kernel should reject it
82 echo "rw remount test"
83 _scratch_remount rw 2>>$seqres.full
84 if [ $? -eq 0 ]; then
85         dmesg | tail -n 15 >> $seqres.full
86         _fail "rw remount test failed"
87 fi
88
89 _scratch_unmount
90
91 # success, all done
92 status=0
93 exit