Skip to contentSkip to conversation

xfstests: btrfs, add test for btrfs properties

PATCH Superseded Filipe David Borba Manana 2 participants 3 messages Apr 15, 2014 – Apr 16, 2014 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests: btrfs, add test for btrfs properties

This test case verifies the btrfs properties feature, a new feature introduced in the linux kernel version 3.14.

---
 common/rc           |   9 +++
 tests/btrfs/048     | 220 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/048.out |  78 +++++++++++++++++++
 tests/btrfs/group   |   1 +
 4 files changed, 308 insertions(+)
 create mode 100755 tests/btrfs/048
 create mode 100644 tests/btrfs/048.out
common/rc +9 -0
index acf419b..d4ba74f 100644
@@ -2262,6 +2262,15 @@ _run_btrfs_util_prog()
 	run_check $BTRFS_UTIL_PROG $*
 }
 
+_require_btrfs_properties()
+{
+	$BTRFS_UTIL_PROG | grep 'btrfs property ' > /dev/null 2>&1
+	if [ $? -ne 0 ]
+	then
+		_notrun "Missing btrfs-progs with properties support, skipped this test"
+	fi
+}
+
 init_rc()
 {
 	if [ "$iam" == new ]
tests/btrfs/048 new file +220 -0

220 lines not on this page · raw message

tests/btrfs/048.out new file +78 -0

78 lines not on this page · raw message

tests/btrfs/group +1 -0
index d4e3fc1..af60c79 100644
@@ -50,3 +50,4 @@
 045 auto quick
 046 auto quick
 047 auto quick
+048 auto quick
Signature · 1 line
1.9.1
#1 lore raw
Quoted 4 lines · Filipe David Borba Manana

This test case verifies the btrfs properties feature, a new feature introduced in the linux kernel version 3.14.

...

Quoted 14 lines
---
 common/rc           |   9 +++
 tests/btrfs/048     | 220 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/048.out |  78 +++++++++++++++++++
 tests/btrfs/group   |   1 +
 4 files changed, 308 insertions(+)
 create mode 100755 tests/btrfs/048
 create mode 100644 tests/btrfs/048.out
common/rc +0 -0
index acf419b..d4ba74f 100644

common/rc _run_btrfs_util_prog() · line 2271

Quoted 10 lines
common/rc +7 -0
@@ -2262,6 +2262,15 @@ _run_btrfs_util_prog()
 	run_check $BTRFS_UTIL_PROG $*
 }
 
+_require_btrfs_properties()
+{
+	$BTRFS_UTIL_PROG | grep 'btrfs property ' > /dev/null 2>&1
+	if [ $? -ne 0 ]
+	then
+		_notrun "Missing btrfs-progs with properties support, skipped this test"
+	fi

if [ ... ]; then

....

common/rc _run_btrfs_util_prog()

Quoted 11 lines
common/rc +11 -0
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here="`pwd`"
+tmp=/tmp/$$
+
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+send_files_dir=$TEST_DIR/btrfs-test-$seq

You should define this after including the common/* files.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw

PATCH v2 1/1 xfstests: btrfs, add test for btrfs properties

In reply to Filipe David Borba Manana

This test case verifies the btrfs properties feature, a new feature introduced in the linux kernel version 3.14.

---

V2: Addressed Dave's comments, removed function to check for existence of
the btrfs-progs property command and use instead existing function _require_btrfs which checks if a btrfs-progs command exists and is equivalent to what I had before.

 tests/btrfs/048     | 220 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/048.out |  78 +++++++++++++++++++
 tests/btrfs/group   |   1 +
 3 files changed, 299 insertions(+)
 create mode 100755 tests/btrfs/048
 create mode 100644 tests/btrfs/048.out
tests/btrfs/048 new file +220 -0
new file mode 100755
index 0000000..e998f97
@@ -0,0 +1,220 @@
+#! /bin/bash
+# FS QA Test No. btrfs/048
+#
+# Btrfs properties test. The btrfs properties feature was introduced in the
+# linux kernel 3.14.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    rm -fr $send_files_dir
+    rm -fr $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_btrfs "property"
+_need_to_be_root
+
+send_files_dir=$TEST_DIR/btrfs-test-$seq
+
+rm -f $seqres.full
+rm -fr $send_files_dir
+mkdir $send_files_dir
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+echo "Testing label property"
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT label
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT label foobar
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT label
+echo "***"
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT label ''
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT label
+echo "***"
+mkdir $SCRATCH_MNT/testdir
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir label
+echo "***"
+
+echo -e "\nTesting subvolume ro property"
+_run_btrfs_util_prog subvolume create $SCRATCH_MNT/sv1
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/sv1 ro
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/sv1 ro foo
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/sv1 ro true
+echo "***"
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/sv1 ro
+echo "***"
+touch $SCRATCH_MNT/sv1/foobar 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/sv1 ro false
+touch $SCRATCH_MNT/sv1/foobar 2>&1 | _filter_scratch
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/sv1
+echo "***"
+
+echo -e "\nTesting compression property"
+mkdir $SCRATCH_MNT/testdir/subdir1
+touch $SCRATCH_MNT/testdir/file1
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1 compression
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/file1 compression \
+	foo 2>&1 | _filter_scratch
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/file1 compression lzo
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
+
+# Verify property was persisted.
+_scratch_unmount
+_check_scratch_fs
+_scratch_mount
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/file1 compression zlib
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/file1 compression ''
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
+
+# Test compression property inheritance.
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/subdir1 compression lzo
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1 compression
+echo "***"
+mkdir $SCRATCH_MNT/testdir/subdir1/subsubdir
+touch $SCRATCH_MNT/testdir/subdir1/some_file
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/subsubdir compression
+echo "***"
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/some_file compression
+echo "***"
+mkdir $SCRATCH_MNT/testdir/subdir1/subsubdir/foo
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/subsubdir/foo \
+	compression
+echo "***"
+
+# Verify property was persisted.
+_scratch_unmount
+_check_scratch_fs
+_scratch_mount
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/subsubdir compression
+echo "***"
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/subsubdir/foo \
+	compression
+echo "***"
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/some_file compression
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/subdir1/subsubdir \
+	compression ''
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/subdir1/some_file \
+	compression ''
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/subdir1 compression ''
+echo "***"
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/subsubdir compression
+echo "***"
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/some_file compression
+echo "***"
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1 compression
+echo "***"
+touch $SCRATCH_MNT/testdir/subdir1/some_file_2
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/some_file_2 \
+	compression
+echo "***"
+
+# Verify send is able to replicate properties.
+echo -e "\nTesting properties with send"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/subdir1 compression lzo
+touch $SCRATCH_MNT/testdir/subdir1/foobar
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1 compression
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/foobar compression
+echo "***"
+
+_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
+touch $SCRATCH_MNT/testdir/subdir1/foobar2
+_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
+
+_run_btrfs_util_prog send $SCRATCH_MNT/mysnap1 -f $send_files_dir/1.snap
+_run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 $SCRATCH_MNT/mysnap2 \
+	-f $send_files_dir/2.snap
+
+_scratch_unmount
+_check_scratch_fs
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+_run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/1.snap
+_run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/2.snap
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/mysnap2/testdir/subdir1 compression
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/mysnap2/testdir/subdir1/foobar \
+	compression
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/mysnap2/testdir/subdir1/foobar2 \
+	compression
+echo "***"
+
+_scratch_unmount
+_check_scratch_fs
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+echo -e "\nTesting subvolume properties"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lzo'
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT compression
+echo "***"
+touch $SCRATCH_MNT/file1
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/file1 compression
+echo "***"
+mkdir $SCRATCH_MNT/dir1
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/dir1 compression
+echo "***"
+mkdir $SCRATCH_MNT/dir1/subdir1
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/dir1/subdir1 compression
+echo "***"
+$BTRFS_UTIL_PROG property set $SCRATCH_MNT/dir1/subdir1 compression 'zlib'
+touch $SCRATCH_MNT/dir1/subdir1/foo
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/dir1/subdir1/foo compression
+
+echo -e "\nTesting subvolume property inheritance"
+_run_btrfs_util_prog subvolume create $SCRATCH_MNT/sv1
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/sv1 compression
+touch $SCRATCH_MNT/sv1/file2
+$BTRFS_UTIL_PROG property get $SCRATCH_MNT/sv1/file2 compression
+
+_check_scratch_fs
+
+status=0
+exit
tests/btrfs/048.out new file +78 -0

78 lines not on this page · raw message

tests/btrfs/group +1 -0
index d4e3fc1..af60c79 100644
@@ -50,3 +50,4 @@
 045 auto quick
 046 auto quick
 047 auto quick
+048 auto quick
Signature · 1 line
1.9.1