03d105aa27460471744cb7b92148780796ceea42
[xfstests-dev.git] / tests / btrfs / 024
1 #! /bin/bash
2 # FS QA Test No. btrfs/024
3 #
4 # btrfs wrong compression type regression test. This test is used to check
5 # the oops will happen when the users write some data into the files whose
6 # compress flag is set but the compression of the fs is disabled.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2013 Fujitsu.  All Rights Reserved.
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
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33
34 status=1        # failure is the default!
35
36 _cleanup()
37 {
38         rm -f $tmp.*
39 }
40
41 trap "_cleanup ; exit \$status" 0 1 2 3 15
42
43 # get standard environment, filters and checks
44 . ./common/rc
45 . ./common/filter
46
47 # real QA test starts here
48 _supported_fs btrfs
49 _supported_os Linux
50 _require_scratch
51
52 __workout()
53 {
54         work_file="$SCRATCH_MNT/tmpfile"
55
56         touch $work_file
57         chattr =c $work_file
58         $XFS_IO_PROG -f -c "pwrite 0 1M" -c "fsync" $work_file | _filter_xfs_io
59 }
60
61 echo "*** test nodatacow"
62 _scratch_mkfs > /dev/null 2>&1
63 _scratch_mount "-o nodatacow"
64 __workout
65 _scratch_unmount
66 _check_scratch_fs
67
68 echo "*** test compress=no"
69 _scratch_mkfs > /dev/null 2>&1
70 _scratch_mount "-o compress=no"
71 __workout
72 _scratch_unmount
73 _check_scratch_fs
74
75 echo "*** test compress-force=no"
76 _scratch_mkfs > /dev/null 2>&1
77 _scratch_mount "-o compress-force=no"
78 __workout
79 _scratch_unmount
80
81 echo "*** done"
82 status=0 ; exit