summaryrefslogtreecommitdiff
path: root/tests/misc-tests/035-receive-common-mount-point-prefix/test.sh
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2019-01-26 00:37:47 +0000
committerDimitri John Ledkov <xnox@ubuntu.com>2019-01-26 00:37:47 +0000
commit2fd02b1f5f50d499b8f19d0cc5e9bc9ed7e686cd (patch)
tree7557002a8de5892b17c04d1afcd8fdc99a0af4e7 /tests/misc-tests/035-receive-common-mount-point-prefix/test.sh
parent03b9f8baf40383f4c2d709c656ca35bd75362dff (diff)
New upstream release
Diffstat (limited to 'tests/misc-tests/035-receive-common-mount-point-prefix/test.sh')
-rwxr-xr-xtests/misc-tests/035-receive-common-mount-point-prefix/test.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/misc-tests/035-receive-common-mount-point-prefix/test.sh b/tests/misc-tests/035-receive-common-mount-point-prefix/test.sh
new file mode 100755
index 0000000..375ade2
--- /dev/null
+++ b/tests/misc-tests/035-receive-common-mount-point-prefix/test.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+# Test that receive determines the correct mount point path when there is
+# another mount point that matches the destination's path as a prefix.
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs
+check_prereq mkfs.btrfs
+
+setup_root_helper
+
+rm -f dev1 dev2
+run_check truncate -s 1G dev1
+run_check truncate -s 1G dev2
+chmod a+w dev1 dev2
+
+loop1=$(run_check_stdout $SUDO_HELPER losetup --find --show dev1)
+loop2=$(run_check_stdout $SUDO_HELPER losetup --find --show dev2)
+
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$loop1"
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$loop2"
+
+run_check $SUDO_HELPER mount "$loop1" "$TEST_MNT"
+run_check $SUDO_HELPER mkdir "$TEST_MNT/ddis"
+run_check $SUDO_HELPER mkdir "$TEST_MNT/ddis-not-a-mount"
+run_check $SUDO_HELPER mount "$loop2" "$TEST_MNT/ddis"
+
+echo "some data" | $SUDO_HELPER tee "$TEST_MNT/ddis/file" > /dev/null
+
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r \
+ "$TEST_MNT/ddis" "$TEST_MNT/ddis/snap"
+
+run_check truncate -s 0 send.data
+chmod a+w send.data
+run_check $SUDO_HELPER "$TOP/btrfs" send -f send.data "$TEST_MNT/ddis/snap"
+
+# The following receive used to fail because it incorrectly determined the mount
+# point of the destination path to be $TEST_MNT/ddis and not $TEST_MNT.
+run_check $SUDO_HELPER "$TOP/btrfs" receive -f send.data \
+ "$TEST_MNT/ddis-not-a-mount"
+
+run_check $SUDO_HELPER umount "$TEST_MNT/ddis"
+run_check $SUDO_HELPER umount "$TEST_MNT"
+
+# Cleanup loop devices and send data.
+run_check $SUDO_HELPER losetup -d "$loop1"
+run_check $SUDO_HELPER losetup -d "$loop2"
+rm -f dev1 dev2 send.data