[PATCH 1/2] common/filter.btrfs: add a new _filter_snapshot

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



As the newer btrfs-progs have changed the output of the command
"btrfs subvolume snapshot," which is part of the golden output,
create a helper filter to ensure the test cases pass on older
btrfs-progs.

Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx>
---
 common/filter.btrfs | 9 +++++++++
 tests/btrfs/001     | 3 ++-
 tests/btrfs/152     | 6 +++---
 tests/btrfs/168     | 6 +++---
 tests/btrfs/202     | 4 ++--
 tests/btrfs/302     | 4 ++--
 6 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/common/filter.btrfs b/common/filter.btrfs
index 9ef9676175c9..415ed6dfd088 100644
--- a/common/filter.btrfs
+++ b/common/filter.btrfs
@@ -156,5 +156,14 @@ _filter_device_add()
 
 }
 
+_filter_snapshot()
+{
+	# btrfs-progs commit 5f87b467a9e7 ("btrfs-progs: subvolume: output the
+	# prompt line only when the ioctl succeeded") changed the output for
+	# btrfs subvolume snapshot, ensure that the latest fstests continue to
+	# work on older btrfs-progs without the above commit.
+	_filter_scratch | sed -e "s/Create a/Create/g"
+}
+
 # make sure this script returns success
 /bin/true
diff --git a/tests/btrfs/001 b/tests/btrfs/001
index 6c2639990373..cfcf2ade4590 100755
--- a/tests/btrfs/001
+++ b/tests/btrfs/001
@@ -26,7 +26,8 @@ dd if=/dev/zero of=$SCRATCH_MNT/foo bs=1M count=1 &> /dev/null
 echo "List root dir"
 ls $SCRATCH_MNT
 echo "Creating snapshot of root dir"
-$BTRFS_UTIL_PROG subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap | _filter_scratch
+$BTRFS_UTIL_PROG subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap | \
+							_filter_snapshot
 echo "List root dir after snapshot"
 ls $SCRATCH_MNT
 echo "List snapshot dir"
diff --git a/tests/btrfs/152 b/tests/btrfs/152
index 75f576c3cfca..b89fe361e84e 100755
--- a/tests/btrfs/152
+++ b/tests/btrfs/152
@@ -11,7 +11,7 @@
 _begin_fstest auto quick metadata qgroup send
 
 # Import common functions.
-. ./common/filter
+. ./common/filter.btrfs
 
 # real QA test starts here
 _supported_fs btrfs
@@ -32,9 +32,9 @@ touch $SCRATCH_MNT/subvol{1,2}/foo
 
 # Create base snapshots and send them
 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/subvol1 \
-	$SCRATCH_MNT/subvol1/.snapshots/1 | _filter_scratch
+	$SCRATCH_MNT/subvol1/.snapshots/1 | _filter_snapshot
 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/subvol2 \
-	$SCRATCH_MNT/subvol2/.snapshots/1 | _filter_scratch
+	$SCRATCH_MNT/subvol2/.snapshots/1 | _filter_snapshot
 for recv in recv1_1 recv1_2 recv2_1 recv2_2; do
 	$BTRFS_UTIL_PROG send $SCRATCH_MNT/subvol1/.snapshots/1 2> /dev/null | \
 		$BTRFS_UTIL_PROG receive $SCRATCH_MNT/${recv} | _filter_scratch
diff --git a/tests/btrfs/168 b/tests/btrfs/168
index acc58b51ee39..78bc9b8f81bb 100755
--- a/tests/btrfs/168
+++ b/tests/btrfs/168
@@ -20,7 +20,7 @@ _cleanup()
 }
 
 # Import common functions.
-. ./common/filter
+. ./common/filter.btrfs
 
 # real QA test starts here
 _supported_fs btrfs
@@ -74,7 +74,7 @@ $BTRFS_UTIL_PROG property set $SCRATCH_MNT/sv1 ro false
 # Create a snapshot of the subvolume, to be used later as the parent snapshot
 # for an incremental send operation.
 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/sv1 $SCRATCH_MNT/snap1 \
-	| _filter_scratch
+							| _filter_snapshot
 
 # First do a full send of this snapshot.
 $FSSUM_PROG -A -f -w $send_files_dir/snap1.fssum $SCRATCH_MNT/snap1
@@ -88,7 +88,7 @@ $XFS_IO_PROG -c "pwrite -S 0x19 4K 8K" $SCRATCH_MNT/sv1/baz >>$seqres.full
 # Create a second snapshot of the subvolume, to be used later as the send
 # snapshot of an incremental send operation.
 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/sv1 $SCRATCH_MNT/snap2 \
-	| _filter_scratch
+							| _filter_snapshot
 
 # Temporarily turn the second snapshot to read-write mode and then open a file
 # descriptor on its foo file.
diff --git a/tests/btrfs/202 b/tests/btrfs/202
index 5f0429f18bf9..57ecbe47c0bb 100755
--- a/tests/btrfs/202
+++ b/tests/btrfs/202
@@ -8,7 +8,7 @@
 . ./common/preamble
 _begin_fstest auto quick subvol snapshot
 
-. ./common/filter
+. ./common/filter.btrfs
 
 _supported_fs btrfs
 _require_scratch
@@ -28,7 +28,7 @@ _scratch_mount
 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a | _filter_scratch
 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a/b | _filter_scratch
 $BTRFS_UTIL_PROG subvolume snapshot $SCRATCH_MNT/a $SCRATCH_MNT/c \
-	| _filter_scratch
+							| _filter_snapshot
 
 # Need the dummy entry created so that we get the invalid removal when we rmdir
 ls $SCRATCH_MNT/c/b
diff --git a/tests/btrfs/302 b/tests/btrfs/302
index f3e6044b5251..52d712ac50de 100755
--- a/tests/btrfs/302
+++ b/tests/btrfs/302
@@ -15,7 +15,7 @@
 . ./common/preamble
 _begin_fstest auto quick snapshot subvol
 
-. ./common/filter
+. ./common/filter.btrfs
 
 _supported_fs btrfs
 _require_scratch
@@ -46,7 +46,7 @@ $FSSUM_PROG -A -f -w $fssum_file $SCRATCH_MNT/subvol
 # Now create a snapshot of the subvolume and make it accessible from within the
 # subvolume.
 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/subvol \
-		 $SCRATCH_MNT/subvol/snap | _filter_scratch
+				 $SCRATCH_MNT/subvol/snap | _filter_snapshot
 
 # Now unmount and mount again the fs. We want to verify we are able to read all
 # metadata for the snapshot from disk (no IO failures, etc).
-- 
2.39.3





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux