diff mbox series

[2/2] btrfs-progs: misc-tests: add a test case to make sure uuid is correctly reported

Message ID 6b439939b69d08debf357e7b9d7a5b3ef8ae6b4b.1672120480.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: fix the uuid report in "btrfs subvolume list -u" | expand

Commit Message

Qu Wenruo Dec. 27, 2022, 5:55 a.m. UTC
The new test case will execute "btrfs subvolume list -u" on the newly
create btrfs.

Since the v0 root item is already deprecated for a long time, newly
created btrfs should be already using the new root item, thus "btrfs
subvolume list -u" should always report the correct uuid.

The test case relies on external program "uuidparse" which should be
provided by util-linux.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../056-subvolume-list-uuid/test.sh           | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100755 tests/misc-tests/056-subvolume-list-uuid/test.sh

Comments

Neal Gompa Dec. 28, 2022, 12:05 p.m. UTC | #1
On Tue, Dec 27, 2022 at 1:10 AM Qu Wenruo <wqu@suse.com> wrote:
>
> The new test case will execute "btrfs subvolume list -u" on the newly
> create btrfs.
>
> Since the v0 root item is already deprecated for a long time, newly
> created btrfs should be already using the new root item, thus "btrfs
> subvolume list -u" should always report the correct uuid.
>
> The test case relies on external program "uuidparse" which should be
> provided by util-linux.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  .../056-subvolume-list-uuid/test.sh           | 28 +++++++++++++++++++
>  1 file changed, 28 insertions(+)
>  create mode 100755 tests/misc-tests/056-subvolume-list-uuid/test.sh
>
> diff --git a/tests/misc-tests/056-subvolume-list-uuid/test.sh b/tests/misc-tests/056-subvolume-list-uuid/test.sh
> new file mode 100755
> index 000000000000..45f4f956c25f
> --- /dev/null
> +++ b/tests/misc-tests/056-subvolume-list-uuid/test.sh
> @@ -0,0 +1,28 @@
> +#!/bin/bash
> +#
> +# Make sure "btrfs subvolume list -u" shows uuid correctly
> +
> +source "$TEST_TOP/common"
> +
> +check_prereq mkfs.btrfs
> +check_prereq btrfs
> +check_global_prereq uuidparse
> +
> +setup_root_helper
> +prepare_test_dev
> +
> +tmp=$(_mktemp_dir list_uuid)
> +
> +run_check_mkfs_test_dev
> +run_check_mount_test_dev
> +run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1"
> +run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume list -u "$TEST_MNT" |\
> +       cut -d\  -f9 > "$tmp/output"
> +
> +result=$(cat "$tmp/output" | uuidparse -o TYPE -n)
> +rm -rf -- "$tmp"
> +
> +if [ "$result" == "invalid" ]; then
> +       _fail "subvolume list failed to report uuid"
> +fi
> +run_check_umount_test_dev
> --
> 2.39.0
>

Reviewed-by: Neal Gompa <neal@gompa.dev>
diff mbox series

Patch

diff --git a/tests/misc-tests/056-subvolume-list-uuid/test.sh b/tests/misc-tests/056-subvolume-list-uuid/test.sh
new file mode 100755
index 000000000000..45f4f956c25f
--- /dev/null
+++ b/tests/misc-tests/056-subvolume-list-uuid/test.sh
@@ -0,0 +1,28 @@ 
+#!/bin/bash
+#
+# Make sure "btrfs subvolume list -u" shows uuid correctly
+
+source "$TEST_TOP/common"
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+check_global_prereq uuidparse
+
+setup_root_helper
+prepare_test_dev
+
+tmp=$(_mktemp_dir list_uuid)
+
+run_check_mkfs_test_dev
+run_check_mount_test_dev
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1"
+run_check_stdout $SUDO_HELPER "$TOP/btrfs" subvolume list -u "$TEST_MNT" |\
+	cut -d\  -f9 > "$tmp/output"
+
+result=$(cat "$tmp/output" | uuidparse -o TYPE -n)
+rm -rf -- "$tmp"
+
+if [ "$result" == "invalid" ]; then
+	_fail "subvolume list failed to report uuid"
+fi
+run_check_umount_test_dev