2016-11-29 15:12:15 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# end of stream conditions: test that no instructions in a stream are still
|
|
|
|
# received, at least the header must be present
|
|
|
|
|
2018-02-08 06:34:19 +00:00
|
|
|
source "$TEST_TOP/common"
|
2016-11-29 15:12:15 +00:00
|
|
|
|
|
|
|
check_prereq mkfs.btrfs
|
|
|
|
check_prereq btrfs
|
|
|
|
|
|
|
|
setup_root_helper
|
2017-10-27 13:50:34 +00:00
|
|
|
prepare_test_dev
|
2016-11-29 15:12:15 +00:00
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
2017-04-03 20:21:08 +00:00
|
|
|
# All helpers can exercise various options passed to 'btrfs receive'
|
|
|
|
|
2016-11-29 15:12:15 +00:00
|
|
|
test_full_empty_stream() {
|
|
|
|
local str
|
|
|
|
|
|
|
|
str="$here/stream-full-empty.stream"
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev
|
2016-11-29 15:12:15 +00:00
|
|
|
run_check_mount_test_dev
|
|
|
|
|
|
|
|
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 subv1
|
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap
|
2016-11-29 15:12:15 +00:00
|
|
|
|
2022-09-15 14:02:09 +00:00
|
|
|
_mktemp_local "$str"
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$str" subv1-snap
|
2016-11-29 15:12:15 +00:00
|
|
|
|
|
|
|
cd "$here" || _fail "cannot chdir back to test directory"
|
|
|
|
run_check_umount_test_dev
|
|
|
|
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev
|
2016-11-29 15:12:15 +00:00
|
|
|
run_check_mount_test_dev
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" receive "$@" -v -f "$str" "$TEST_MNT"
|
2016-11-29 15:12:15 +00:00
|
|
|
run_check_umount_test_dev
|
|
|
|
|
|
|
|
run_check rm -f -- "$str"
|
|
|
|
}
|
|
|
|
|
|
|
|
test_full_simple_stream() {
|
|
|
|
local str
|
|
|
|
|
|
|
|
str="$here/stream-full-simple.stream"
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev
|
2016-11-29 15:12:15 +00:00
|
|
|
run_check_mount_test_dev
|
|
|
|
|
|
|
|
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 subv1
|
2016-11-29 15:12:15 +00:00
|
|
|
for i in 1 2 3; do
|
|
|
|
run_check $SUDO_HELPER dd if=/dev/zero of=subv1/file1_$i bs=1M count=1
|
|
|
|
done
|
|
|
|
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap
|
2016-11-29 15:12:15 +00:00
|
|
|
|
2022-09-15 14:02:09 +00:00
|
|
|
_mktemp_local "$str"
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$str" subv1-snap
|
2016-11-29 15:12:15 +00:00
|
|
|
|
|
|
|
cd "$here" || _fail "cannot chdir back to test directory"
|
|
|
|
run_check_umount_test_dev
|
|
|
|
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev
|
2016-11-29 15:12:15 +00:00
|
|
|
run_check_mount_test_dev
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" receive "$@" -v -f "$str" "$TEST_MNT"
|
2016-11-29 15:12:15 +00:00
|
|
|
run_check_umount_test_dev
|
|
|
|
|
|
|
|
run_check rm -f -- "$str"
|
|
|
|
}
|
|
|
|
|
|
|
|
test_incr_empty_stream() {
|
|
|
|
local fstr
|
|
|
|
local istr
|
|
|
|
|
|
|
|
fstr="$here/stream-full-empty.stream"
|
|
|
|
istr="$here/stream-incr-empty.stream"
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev
|
2016-11-29 15:12:15 +00:00
|
|
|
run_check_mount_test_dev
|
|
|
|
|
|
|
|
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 subv1
|
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap
|
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv2-snap
|
2016-11-29 15:12:15 +00:00
|
|
|
|
2022-09-15 14:02:09 +00:00
|
|
|
_mktemp_local "$fstr"
|
|
|
|
_mktemp_local "$istr"
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$fstr" subv1-snap
|
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" send -p subv1-snap -f "$istr" subv2-snap
|
2016-11-29 15:12:15 +00:00
|
|
|
|
|
|
|
cd "$here" || _fail "cannot chdir back to test directory"
|
|
|
|
run_check_umount_test_dev
|
|
|
|
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev
|
2016-11-29 15:12:15 +00:00
|
|
|
run_check_mount_test_dev
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" receive "$@" -v -f "$fstr" "$TEST_MNT"
|
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" receive "$@" -v -f "$istr" "$TEST_MNT"
|
2016-11-29 15:12:15 +00:00
|
|
|
run_check_umount_test_dev
|
|
|
|
|
|
|
|
run_check rm -f -- "$fstr" "$istr"
|
|
|
|
}
|
|
|
|
|
|
|
|
test_incr_simple_stream() {
|
|
|
|
local str
|
|
|
|
|
|
|
|
fstr="$here/stream-full-simple.stream"
|
|
|
|
istr="$here/stream-incr-simple.stream"
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev
|
2016-11-29 15:12:15 +00:00
|
|
|
run_check_mount_test_dev
|
|
|
|
|
|
|
|
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 subv1
|
2016-11-29 15:12:15 +00:00
|
|
|
for i in 1 2 3; do
|
|
|
|
run_check $SUDO_HELPER dd if=/dev/zero of=subv1/file1_$i bs=1M count=1
|
|
|
|
done
|
|
|
|
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv1-snap
|
2016-11-29 15:12:15 +00:00
|
|
|
|
|
|
|
for i in 1 2 3; do
|
|
|
|
run_check $SUDO_HELPER dd if=/dev/urandom of=subv1/file1_$i bs=1M count=1
|
|
|
|
done
|
|
|
|
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r subv1 subv2-snap
|
2016-11-29 15:12:15 +00:00
|
|
|
|
2022-09-15 14:02:09 +00:00
|
|
|
_mktemp_local "$fstr"
|
|
|
|
_mktemp_local "$istr"
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" send -f "$fstr" subv1-snap
|
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" send -p subv1-snap -f "$istr" subv2-snap
|
2016-11-29 15:12:15 +00:00
|
|
|
|
|
|
|
cd "$here" || _fail "cannot chdir back to test directory"
|
|
|
|
run_check_umount_test_dev
|
|
|
|
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev
|
2016-11-29 15:12:15 +00:00
|
|
|
run_check_mount_test_dev
|
2018-03-23 15:34:30 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" receive "$@" -v -f "$fstr" "$TEST_MNT"
|
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" receive "$@" -v -f "$istr" "$TEST_MNT"
|
2016-11-29 15:12:15 +00:00
|
|
|
run_check_umount_test_dev
|
|
|
|
|
|
|
|
run_check rm -f -- "$fstr" "$istr"
|
|
|
|
}
|
|
|
|
|
|
|
|
test_full_empty_stream
|
|
|
|
test_full_simple_stream
|
|
|
|
test_incr_empty_stream
|
|
|
|
test_incr_simple_stream
|
2017-04-03 20:21:08 +00:00
|
|
|
|
|
|
|
extra_opt=-e
|
2018-03-23 15:34:30 +00:00
|
|
|
test_full_empty_stream "$extra_opt"
|
|
|
|
test_full_simple_stream "$extra_opt"
|
|
|
|
test_incr_empty_stream "$extra_opt"
|
|
|
|
test_incr_simple_stream "$extra_opt"
|