diff mbox series

[2/2] btrfs-progs: cli-tests: add test case for return value of "btrfs subvlume create"

Message ID 2df04d2266134948bdd6755b9dbeaf70f42908f3.1704855097.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: fix the return value of "btrfs | expand

Commit Message

Qu Wenruo Jan. 10, 2024, 2:53 a.m. UTC
The test case would check if "btrfs subvolume create":

- Report error on an existing path
- Still report error if mulitple paths are given and one of them already
  exists
- For above case, still created a subvolume for the good parameter

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../025-subvolume-create-failures/test.sh     | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100755 tests/cli-tests/025-subvolume-create-failures/test.sh

Comments

Qu Wenruo Jan. 10, 2024, 6:57 a.m. UTC | #1
On 2024/1/10 13:23, Qu Wenruo wrote:
> The test case would check if "btrfs subvolume create":
> 
> - Report error on an existing path
> - Still report error if mulitple paths are given and one of them already
>    exists
> - For above case, still created a subvolume for the good parameter
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>   .../025-subvolume-create-failures/test.sh     | 30 +++++++++++++++++++
>   1 file changed, 30 insertions(+)
>   create mode 100755 tests/cli-tests/025-subvolume-create-failures/test.sh
> 
> diff --git a/tests/cli-tests/025-subvolume-create-failures/test.sh b/tests/cli-tests/025-subvolume-create-failures/test.sh
> new file mode 100755
> index 000000000000..b268a069ba37
> --- /dev/null
> +++ b/tests/cli-tests/025-subvolume-create-failures/test.sh
> @@ -0,0 +1,30 @@
> +#!/bin/bash
> +# Create subvolume failure cases to make sure the return value is correct
> +
> +source "$TEST_TOP/common" || exit
> +
> +setup_root_helper
> +prepare_test_dev
> +
> +run_check_mkfs_test_dev
> +run_check_mount_test_dev
> +
> +# Create one subvolume and one file as place holder for later subvolume
> +# creation to fail.
> +run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1"
> +run_check $SUDO_HELPER touch "$TEST_MNT/subv2"
> +
> +# Using existing path to create a subvolume must fail
> +run_mustfail "should report error when target path already exists" \
> +	$SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1"
> +
> +run_mustfail "should report error when target path already exists" \
> +	$SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv2"
> +
> +# Using multiple subvolumes in one create go, the good one "subv3" should be
> +# created
> +run_mustfail "should report error when target path already exists" \
> +	$SUDO_HELPER "$TOP/btrfs" subvolume create \
> +	"$TEST_MNT/subv1" "$TEST_MNT/subv2" "$TEST_MNT/subv3"
> +
> +run_check $SUDO_HELPER stat "$TEST_MNT/subv3"

My bad, I forgot to unmount the test dev

David, mind to add the following line to clean it up?

run_check_umount_test_dev

Thanks,
Qu
David Sterba Jan. 10, 2024, 3:32 p.m. UTC | #2
On Wed, Jan 10, 2024 at 05:27:17PM +1030, Qu Wenruo wrote:
> 
> 
> On 2024/1/10 13:23, Qu Wenruo wrote:
> > The test case would check if "btrfs subvolume create":
> > 
> > - Report error on an existing path
> > - Still report error if mulitple paths are given and one of them already
> >    exists
> > - For above case, still created a subvolume for the good parameter
> > 
> > Signed-off-by: Qu Wenruo <wqu@suse.com>
> > ---
> >   .../025-subvolume-create-failures/test.sh     | 30 +++++++++++++++++++
> >   1 file changed, 30 insertions(+)
> >   create mode 100755 tests/cli-tests/025-subvolume-create-failures/test.sh
> > 
> > diff --git a/tests/cli-tests/025-subvolume-create-failures/test.sh b/tests/cli-tests/025-subvolume-create-failures/test.sh
> > new file mode 100755
> > index 000000000000..b268a069ba37
> > --- /dev/null
> > +++ b/tests/cli-tests/025-subvolume-create-failures/test.sh
> > @@ -0,0 +1,30 @@
> > +#!/bin/bash
> > +# Create subvolume failure cases to make sure the return value is correct
> > +
> > +source "$TEST_TOP/common" || exit
> > +
> > +setup_root_helper
> > +prepare_test_dev
> > +
> > +run_check_mkfs_test_dev
> > +run_check_mount_test_dev
> > +
> > +# Create one subvolume and one file as place holder for later subvolume
> > +# creation to fail.
> > +run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1"
> > +run_check $SUDO_HELPER touch "$TEST_MNT/subv2"
> > +
> > +# Using existing path to create a subvolume must fail
> > +run_mustfail "should report error when target path already exists" \
> > +	$SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1"
> > +
> > +run_mustfail "should report error when target path already exists" \
> > +	$SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv2"
> > +
> > +# Using multiple subvolumes in one create go, the good one "subv3" should be
> > +# created
> > +run_mustfail "should report error when target path already exists" \
> > +	$SUDO_HELPER "$TOP/btrfs" subvolume create \
> > +	"$TEST_MNT/subv1" "$TEST_MNT/subv2" "$TEST_MNT/subv3"
> > +
> > +run_check $SUDO_HELPER stat "$TEST_MNT/subv3"
> 
> My bad, I forgot to unmount the test dev
> 
> David, mind to add the following line to clean it up?
> 
> run_check_umount_test_dev

Updated, thanks.
diff mbox series

Patch

diff --git a/tests/cli-tests/025-subvolume-create-failures/test.sh b/tests/cli-tests/025-subvolume-create-failures/test.sh
new file mode 100755
index 000000000000..b268a069ba37
--- /dev/null
+++ b/tests/cli-tests/025-subvolume-create-failures/test.sh
@@ -0,0 +1,30 @@ 
+#!/bin/bash
+# Create subvolume failure cases to make sure the return value is correct
+
+source "$TEST_TOP/common" || exit
+
+setup_root_helper
+prepare_test_dev
+
+run_check_mkfs_test_dev
+run_check_mount_test_dev
+
+# Create one subvolume and one file as place holder for later subvolume
+# creation to fail.
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1"
+run_check $SUDO_HELPER touch "$TEST_MNT/subv2"
+
+# Using existing path to create a subvolume must fail
+run_mustfail "should report error when target path already exists" \
+	$SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1"
+
+run_mustfail "should report error when target path already exists" \
+	$SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv2"
+
+# Using multiple subvolumes in one create go, the good one "subv3" should be
+# created
+run_mustfail "should report error when target path already exists" \
+	$SUDO_HELPER "$TOP/btrfs" subvolume create \
+	"$TEST_MNT/subv1" "$TEST_MNT/subv2" "$TEST_MNT/subv3"
+
+run_check $SUDO_HELPER stat "$TEST_MNT/subv3"