xfstests: remove _need_to_be_root
[xfstests-dev.git] / tests / btrfs / 059
1 #! /bin/bash
2 # FS QA Test No. btrfs/059
3 #
4 # Regression test for btrfs where removing the flag FS_COMPR_FL (chattr -c)
5 # from an inode wouldn't clear its compression property.
6 # This was fixed in the following linux kernel patch:
7 #
8 #     Btrfs: add missing compression property remove in btrfs_ioctl_setflags
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (C) 2014 SUSE Linux Products GmbH. All Rights Reserved.
12 # Author: Filipe Manana <fdmanana@suse.com>
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
17 #
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26 #-----------------------------------------------------------------------
27 #
28
29 seq=`basename $0`
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35
36 status=1        # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 _cleanup()
40 {
41         rm -fr $tmp
42 }
43
44 # get standard environment, filters and checks
45 . ./common/rc
46 . ./common/filter
47
48 # real QA test starts here
49 _supported_fs btrfs
50 _supported_os Linux
51 _require_test
52 _require_scratch
53 _require_btrfs "property"
54
55 rm -f $seqres.full
56
57 _scratch_mkfs >> $seqres.full 2>&1
58 _scratch_mount
59
60 mkdir $SCRATCH_MNT/testdir
61 echo "Setting compression flag in the directory..."
62 chattr +c $SCRATCH_MNT/testdir
63 echo "Directory compression property value:"
64 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir compression
65
66 touch $SCRATCH_MNT/testdir/file1
67 echo "file1 compression property value:"
68 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
69
70 echo "Clearing compression flag from directory..."
71 chattr -c $SCRATCH_MNT/testdir
72 echo "Directory compression property value:"
73 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir compression
74
75 touch $SCRATCH_MNT/testdir/file2
76 echo "file2 compression property value:"
77 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file2 compression
78
79 touch $SCRATCH_MNT/testdir/file1
80 echo "file1 compression property value:"
81 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
82
83 status=0
84 exit