summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSu Yanjun <suyj.fnst@cn.fujitsu.com>2018-09-18 16:44:48 +0800
committerDavid Sterba <dsterba@suse.com>2018-10-25 16:11:40 +0200
commitb4843d366906cdb5b1198c0206b720ba28ee66f6 (patch)
tree6106ed04b07b48e5617a50cd7bab1b28c1b49d76
parent3ea85fa8861e1fcbc14df828aa1f948ee39c7e6e (diff)
btrfs-progs: tests: Add the testcase for subvolume name length limit test
Total of three conditions are tested. One for short name, one with name length 255, the last one with more than 255. This case should pass after commit 'btrfs-progs: change filename limit to 255 when creating subvolume'. Signed-off-by: Su Yanjun <suyj.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rwxr-xr-xtests/misc-tests/033-filename-length-limit/test.sh82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/misc-tests/033-filename-length-limit/test.sh b/tests/misc-tests/033-filename-length-limit/test.sh
new file mode 100755
index 0000000..673138e
--- /dev/null
+++ b/tests/misc-tests/033-filename-length-limit/test.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+#
+# test file name length limits for subvolumes
+
+source "$TEST_TOP/common"
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+prepare_test_dev
+
+run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV"
+run_check_mount_test_dev
+run_check $SUDO_HELPER chmod a+rw "$TEST_MNT"
+
+cd "$TEST_MNT"
+
+longname=\
+0123456789\
+0123456789\
+0123456789\
+0123456789\
+0123456789\
+\
+0123456789\
+0123456789\
+0123456789\
+0123456789\
+0123456789\
+\
+0123456789\
+0123456789\
+0123456789\
+0123456789\
+0123456789\
+\
+0123456789\
+0123456789\
+0123456789\
+0123456789\
+0123456789\
+\
+0123456789\
+0123456789\
+0123456789\
+0123456789\
+0123456789\
+\
+01234
+
+# subvolume name length limit test
+
+# short name test
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume create subvol
+# 255
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$longname"
+# 256, must fail
+run_mustfail "subvolume with name 256 bytes long succeeded" \
+ $SUDO_HELPER "$TOP/btrfs" subvolume create "$longname"5
+# 255*2, must fail
+run_mustfail "subvolume with name 2 * 255 bytes long succeeded" \
+ $SUDO_HELPER "$TOP/btrfs" subvolume create "$longname$longname"
+
+# snapshot name length limit test
+
+run_check $SUDO_HELPER mkdir snaps
+
+# short name test
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot subvol snaps/snap
+# 255
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot subvol snaps/"$longname"
+# 256, must fail
+run_mustfail "snapshot with name 256 bytes long succeeded" \
+ $SUDO_HELPER "$TOP/btrfs" subvolume snapshot subvol snaps/"$longname"5
+# 255*2, must fail
+run_mustfail "subvolume with name 2 * 255 bytes long succeeded" \
+ $SUDO_HELPER "$TOP/btrfs" subvolume snapshot subvol snaps/"$longname$longname"
+
+cd ..
+
+run_check_umount_test_dev