diff mbox series

[v2,3/3] btrfs-progs: misc-tests: add test to ensure the restored image can be mounted

Message ID 20210429090658.245238-4-wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: image: make restored image file to be properly enlarged | expand

Commit Message

Qu Wenruo April 29, 2021, 9:06 a.m. UTC
This new test case is to make sure the restored image file has been
properly enlarged so that newer kernel won't complain.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../048-image-restore-mount/test.sh           | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100755 tests/misc-tests/048-image-restore-mount/test.sh

Comments

David Sterba April 29, 2021, 7:56 p.m. UTC | #1
On Thu, Apr 29, 2021 at 05:06:58PM +0800, Qu Wenruo wrote:
> This new test case is to make sure the restored image file has been
> properly enlarged so that newer kernel won't complain.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  .../048-image-restore-mount/test.sh           | 20 +++++++++++++++++++
>  1 file changed, 20 insertions(+)
>  create mode 100755 tests/misc-tests/048-image-restore-mount/test.sh
> 
> diff --git a/tests/misc-tests/048-image-restore-mount/test.sh b/tests/misc-tests/048-image-restore-mount/test.sh
> new file mode 100755
> index 000000000000..b61b7a7188cf
> --- /dev/null
> +++ b/tests/misc-tests/048-image-restore-mount/test.sh
> @@ -0,0 +1,20 @@
> +#!/bin/bash
> +# Verify that the restored image of an empty btrfs filesystem can still be
> +# mounted
> +
> +source "$TEST_TOP/common"
> +
> +check_prereq btrfs-image
> +check_prereq mkfs.btrfs
> +check_prereq btrfs
> +
> +tmp=$(mktemp -d --tmpdir btrfs-progs-image.XXXXXXXX)
> +prepare_test_dev
> +
> +run_check_mkfs_test_dev
> +run_check "$TOP/btrfs-image" "$TEST_DEV" "$tmp/dump"
> +run_check "$TOP/btrfs-image" -r "$tmp/dump" "$tmp/restored"
> +
> +run_check $SUDO_HELPER mount -t btrfs -o loop "$tmp/restored" "$TEST_MNT"
> +umount "$TEST_MNT" &> /dev/null

Please note that unlike in fstests, the progs testsuite is intentionally
verbose and the command output should end up in the logs, and all main
commands should be started with run_check (in this case with
$SUDO_HELPER as well).
diff mbox series

Patch

diff --git a/tests/misc-tests/048-image-restore-mount/test.sh b/tests/misc-tests/048-image-restore-mount/test.sh
new file mode 100755
index 000000000000..b61b7a7188cf
--- /dev/null
+++ b/tests/misc-tests/048-image-restore-mount/test.sh
@@ -0,0 +1,20 @@ 
+#!/bin/bash
+# Verify that the restored image of an empty btrfs filesystem can still be
+# mounted
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs-image
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+tmp=$(mktemp -d --tmpdir btrfs-progs-image.XXXXXXXX)
+prepare_test_dev
+
+run_check_mkfs_test_dev
+run_check "$TOP/btrfs-image" "$TEST_DEV" "$tmp/dump"
+run_check "$TOP/btrfs-image" -r "$tmp/dump" "$tmp/restored"
+
+run_check $SUDO_HELPER mount -t btrfs -o loop "$tmp/restored" "$TEST_MNT"
+umount "$TEST_MNT" &> /dev/null
+rm -rf -- "$tmp"