diff mbox

btrfs-progs: send-test: add checking of clone-src option

Message ID 201611040835.AA00012@WIN-5MHF4RKU941.jp.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tsutomu Itoh Nov. 4, 2016, 8:35 a.m. UTC
Sending stream size of clone-src(-c) option is checked.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
---
 tests/misc-tests/016-send-clone-src/test.sh | 54 +++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100755 tests/misc-tests/016-send-clone-src/test.sh

Comments

David Sterba Nov. 7, 2016, 3:16 p.m. UTC | #1
On Fri, Nov 04, 2016 at 05:35:18PM +0900, Tsutomu Itoh wrote:
> +before_size=`ls -l "$here"/send.stream.before | awk '{print $5}'`
> +after_size=`ls -l "$here"/send.stream.after | awk '{print $5}'`

Thanks for the test. Minor fixes: "stat --format=%s" instead of the
above, and /dev/zero instead of urandom and stream redirection so it
works in my NFS setup.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tsutomu Itoh Nov. 7, 2016, 11:53 p.m. UTC | #2
On 2016/11/08 0:16, David Sterba wrote:
> On Fri, Nov 04, 2016 at 05:35:18PM +0900, Tsutomu Itoh wrote:
>> +before_size=`ls -l "$here"/send.stream.before | awk '{print $5}'`
>> +after_size=`ls -l "$here"/send.stream.after | awk '{print $5}'`
> 
> Thanks for the test. Minor fixes: "stat --format=%s" instead of the
> above, and /dev/zero instead of urandom and stream redirection so it
> works in my NFS setup.

Thanks for the fixing.
But following command should be old btrfs. So please use 'btrfs' instead
of '$TOP/btrfs'.

   run_check $SUDO_HELPER $TOP/btrfs send -f "$here"/send.stream.before \
           -c subv-snap1_1 -c subv-snap2_1 subv-snap1_[23] subv-snap2_[23]

Thanks,
Tsutomu

> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba Nov. 8, 2016, 12:47 p.m. UTC | #3
On Tue, Nov 08, 2016 at 08:53:04AM +0900, Tsutomu Itoh wrote:
> On 2016/11/08 0:16, David Sterba wrote:
> > On Fri, Nov 04, 2016 at 05:35:18PM +0900, Tsutomu Itoh wrote:
> >> +before_size=`ls -l "$here"/send.stream.before | awk '{print $5}'`
> >> +after_size=`ls -l "$here"/send.stream.after | awk '{print $5}'`
> > 
> > Thanks for the test. Minor fixes: "stat --format=%s" instead of the
> > above, and /dev/zero instead of urandom and stream redirection so it
> > works in my NFS setup.
> 
> Thanks for the fixing.
> But following command should be old btrfs. So please use 'btrfs' instead
> of '$TOP/btrfs'.
> 
>    run_check $SUDO_HELPER $TOP/btrfs send -f "$here"/send.stream.before \
>            -c subv-snap1_1 -c subv-snap2_1 subv-snap1_[23] subv-snap2_[23]

Oh, I see, but this would make the test unreliable. What if there's a
updated version installed? So we have to produce the right stream and
then compare the result with the one generated by the built version.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tsutomu Itoh Nov. 8, 2016, 11:50 p.m. UTC | #4
On 2016/11/08 21:47, David Sterba wrote:
> On Tue, Nov 08, 2016 at 08:53:04AM +0900, Tsutomu Itoh wrote:
>> On 2016/11/08 0:16, David Sterba wrote:
>>> On Fri, Nov 04, 2016 at 05:35:18PM +0900, Tsutomu Itoh wrote:
>>>> +before_size=`ls -l "$here"/send.stream.before | awk '{print $5}'`
>>>> +after_size=`ls -l "$here"/send.stream.after | awk '{print $5}'`
>>>
>>> Thanks for the test. Minor fixes: "stat --format=%s" instead of the
>>> above, and /dev/zero instead of urandom and stream redirection so it
>>> works in my NFS setup.
>>
>> Thanks for the fixing.
>> But following command should be old btrfs. So please use 'btrfs' instead
>> of '$TOP/btrfs'.
>>
>>    run_check $SUDO_HELPER $TOP/btrfs send -f "$here"/send.stream.before \
>>            -c subv-snap1_1 -c subv-snap2_1 subv-snap1_[23] subv-snap2_[23]
> 
> Oh, I see, but this would make the test unreliable. What if there's a
> updated version installed? So we have to produce the right stream and
> then compare the result with the one generated by the built version.

I understood. I'll post V2 patch.

Thanks,
Tsutomu

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/tests/misc-tests/016-send-clone-src/test.sh b/tests/misc-tests/016-send-clone-src/test.sh
new file mode 100755
index 0000000..dddd16d
--- /dev/null
+++ b/tests/misc-tests/016-send-clone-src/test.sh
@@ -0,0 +1,54 @@ 
+#!/bin/bash
+#
+# test for sending stream size of clone-src option
+
+source $TOP/tests/common
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+prepare_test_dev 2g
+
+run_check $TOP/mkfs.btrfs -f $IMAGE
+run_check_mount_test_dev
+
+here=`pwd`
+cd "$TEST_MNT" || _fail "cannot chdir to TEST_MNT"
+
+run_check $SUDO_HELPER btrfs subvolume create subv-parent1
+run_check $SUDO_HELPER dd if=/dev/urandom of=subv-parent1/file1_1 bs=1M count=10
+run_check $SUDO_HELPER btrfs subvolume snapshot -r subv-parent1 subv-snap1_1
+run_check $SUDO_HELPER dd if=/dev/urandom of=subv-parent1/file1_2 bs=1M count=10
+run_check $SUDO_HELPER btrfs subvolume snapshot -r subv-parent1 subv-snap1_2
+run_check $SUDO_HELPER dd if=/dev/urandom of=subv-parent1/file1_3 bs=1M count=10
+run_check $SUDO_HELPER btrfs subvolume snapshot -r subv-parent1 subv-snap1_3
+
+run_check $SUDO_HELPER btrfs subvolume create subv-parent2
+run_check $SUDO_HELPER dd if=/dev/urandom of=subv-parent2/file2_1 bs=1M count=10
+run_check $SUDO_HELPER btrfs subvolume snapshot -r subv-parent2 subv-snap2_1
+run_check $SUDO_HELPER dd if=/dev/urandom of=subv-parent2/file2_2 bs=1M count=10
+run_check $SUDO_HELPER btrfs subvolume snapshot -r subv-parent2 subv-snap2_2
+run_check $SUDO_HELPER dd if=/dev/urandom of=subv-parent2/file2_3 bs=1M count=10
+run_check $SUDO_HELPER btrfs subvolume snapshot -r subv-parent2 subv-snap2_3
+
+run_check $SUDO_HELPER btrfs send -f "$here"/send.stream.before \
+	-c subv-snap1_1 -c subv-snap2_1 subv-snap1_[23] subv-snap2_[23]
+
+run_check $SUDO_HELPER $TOP/btrfs send -f "$here"/send.stream.after \
+	-c subv-snap1_1 -c subv-snap2_1 subv-snap1_[23] subv-snap2_[23]
+
+before_size=`ls -l "$here"/send.stream.before | awk '{print $5}'`
+after_size=`ls -l "$here"/send.stream.after | awk '{print $5}'`
+
+if [ $before_size -lt $after_size ]; then
+	run_check ls -l "$here"/send.stream.*
+	_fail "sending stream size is bigger than old stream"
+fi
+
+run_check rm -f "$here"/send.stream.*
+
+cd "$here" || _fail "cannot chdir back to test directory"
+
+run_check_umount_test_dev
+