2016-11-09 04:44:15 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# test for sending stream size of clone-src option, compare against a send
|
|
|
|
# stream generated by buggy version
|
|
|
|
|
2023-04-19 15:08:41 +00:00
|
|
|
source "$TEST_TOP/common" || exit
|
2016-11-09 04:44:15 +00:00
|
|
|
|
|
|
|
check_prereq mkfs.btrfs
|
|
|
|
check_prereq btrfs
|
|
|
|
|
|
|
|
setup_root_helper
|
2017-10-27 13:50:34 +00:00
|
|
|
prepare_test_dev
|
2019-06-05 17:09:38 +00:00
|
|
|
|
|
|
|
run_check_mkfs_test_dev
|
2016-11-09 04:44:15 +00:00
|
|
|
run_check_mount_test_dev
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
cd "$TEST_MNT" || _fail "cannot chdir to TEST_MNT"
|
|
|
|
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv-parent1
|
2016-11-09 04:44:15 +00:00
|
|
|
for i in 1 2 3; do
|
2024-06-12 23:39:06 +00:00
|
|
|
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"
|
2016-11-09 04:44:15 +00:00
|
|
|
done
|
|
|
|
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subv-parent2
|
2016-11-09 04:44:15 +00:00
|
|
|
for i in 1 2 3; do
|
2024-06-12 23:39:06 +00:00
|
|
|
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"
|
2016-11-09 04:44:15 +00:00
|
|
|
done
|
|
|
|
|
2022-09-15 14:02:09 +00:00
|
|
|
_mktemp_local "$here/send-stream.img"
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$here"/send-stream.img \
|
2016-11-09 04:44:15 +00:00
|
|
|
-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`
|
|
|
|
|
2018-03-23 15:34:30 +00:00
|
|
|
if [ "$old_stream_size" -lt "$stream_size" ]; then
|
2016-11-09 04:44:15 +00:00
|
|
|
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
|