diff mbox series

[3/3] btrfs-progs: cli-tests: add test case for subvolume create multiple arguments

Message ID 453c0e60ff7db7a1af06df230e2847d0f2b62692.1698903010.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: subvolume create: accept multiple arguments | expand

Commit Message

Qu Wenruo Nov. 2, 2023, 5:33 a.m. UTC
The test case would verify the following behaviors:

- Partial failure
  Should return 1, but the remaining valid destinations would still be
  created.

- All success
  That's as usual.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../021-subvolume-multiple-arguments/test.sh  | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100755 tests/cli-tests/021-subvolume-multiple-arguments/test.sh
diff mbox series

Patch

diff --git a/tests/cli-tests/021-subvolume-multiple-arguments/test.sh b/tests/cli-tests/021-subvolume-multiple-arguments/test.sh
new file mode 100755
index 000000000000..f86763829d31
--- /dev/null
+++ b/tests/cli-tests/021-subvolume-multiple-arguments/test.sh
@@ -0,0 +1,37 @@ 
+#!/bin/bash
+# Create subvolume with multiple destinations
+
+source "$TEST_TOP/common" || exit
+
+setup_root_helper
+prepare_test_dev
+
+run_check_mkfs_test_dev
+run_check_mount_test_dev
+
+# Create one invalid subvolume with 2 valid ones.
+# The command should return 1 but the 2 valid ones should be created.
+run_mustfail "should report error for any failed subvolume creation" \
+	$SUDO_HELPER "$TOP/btrfs" subvolume create \
+	"$TEST_MNT/non-exist-dir/subv0" \
+	"$TEST_MNT/subv1" \
+	"$TEST_MNT/subv2"
+
+run_check $SUDO_HELPER stat "$TEST_MNT/subv1"
+run_check $SUDO_HELPER stat "$TEST_MNT/subv2"
+
+# Create multiple subvolumes with parent
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume create -p \
+	"$TEST_MNT/non-exist-dir/subv0" \
+	"$TEST_MNT/subv1/subv3" \
+	"$TEST_MNT/subv4" \
+
+run_check $SUDO_HELPER stat "$TEST_MNT/non-exist-dir/subv0"
+run_check $SUDO_HELPER stat "$TEST_MNT/subv1/subv3"
+run_check $SUDO_HELPER stat "$TEST_MNT/subv4"
+
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume create -p "$TEST_MNT/dir3/dir1/./..//.///subv3//////"
+run_check $SUDO_HELPER stat "$TEST_MNT/dir3/dir1"
+run_check $SUDO_HELPER stat "$TEST_MNT/dir3/subv3"
+run_check find "$TEST_MNT" -ls
+run_check_umount_test_dev