summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTsutomu Itoh <t-itoh@jp.fujitsu.com>2016-11-09 13:44:15 +0900
committerDavid Sterba <dsterba@suse.com>2016-11-11 16:23:30 +0100
commitf529d6472e09066ab8a2fd8e730f1e8c2acf04d8 (patch)
tree27952f73134c81679de3721cf27aabb3096e71e8 /tests
parent84d1f29d47839ab60e8362f0e05f176d0c6d0755 (diff)
btrfs-progs: tests: add checking of send multiple clone source option
Sending stream size of clone-src(-c) option is checked. Fixed by "btrfs-progs: send: fix handling of -c option". Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/misc-tests/016-send-clone-src/multi-clone-src-v4.8.2.stream.xzbin0 -> 2688 bytes
-rwxr-xr-xtests/misc-tests/016-send-clone-src/test.sh50
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/misc-tests/016-send-clone-src/multi-clone-src-v4.8.2.stream.xz b/tests/misc-tests/016-send-clone-src/multi-clone-src-v4.8.2.stream.xz
new file mode 100644
index 00000000..34c14ed5
--- /dev/null
+++ b/tests/misc-tests/016-send-clone-src/multi-clone-src-v4.8.2.stream.xz
Binary files differ
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 00000000..e256eef9
--- /dev/null
+++ b/tests/misc-tests/016-send-clone-src/test.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+#
+# test for sending stream size of clone-src option, compare against a send
+# stream generated by buggy version
+
+source $TOP/tests/common
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+prepare_test_dev 1g
+
+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 $TOP/btrfs subvolume create subv-parent1
+for i in 1 2 3; do
+ run_check $SUDO_HELPER dd if=/dev/zero of=subv-parent1/file1_$i bs=1M count=1
+ run_check $SUDO_HELPER $TOP/btrfs subvolume snapshot -r subv-parent1 subv-snap1_$i
+done
+
+run_check $SUDO_HELPER $TOP/btrfs subvolume create subv-parent2
+for i in 1 2 3; do
+ run_check $SUDO_HELPER dd if=/dev/zero of=subv-parent2/file2_$i bs=1M count=1
+ run_check $SUDO_HELPER $TOP/btrfs subvolume snapshot -r subv-parent2 subv-snap2_$i
+done
+
+truncate -s0 "$here"/send-stream.img
+chmod a+w "$here"/send-stream.img
+run_check $SUDO_HELPER $TOP/btrfs send -f "$here"/send-stream.img \
+ -c subv-snap1_1 -c subv-snap2_1 subv-snap1_[23] subv-snap2_[23]
+
+image=$(extract_image "$here"/multi-clone-src-v4.8.2.stream.xz)
+old_stream_size=`stat --format=%s "$image"`
+stream_size=`stat --format=%s "$here"/send-stream.img`
+
+if [ $old_stream_size -lt $stream_size ]; then
+ run_check ls -l "$image" "$here"/send-stream.img
+ _fail "sending stream size is bigger than old stream"
+fi
+
+run_check rm -f -- "$image" "$here"/send-stream.img
+
+cd "$here" || _fail "cannot chdir back to test directory"
+
+run_check_umount_test_dev