diff mbox series

btrfs-progs: tests: Add the testcase for subvolume name length limit test

Message ID 20180918084448.14195-1-suyj.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: tests: Add the testcase for subvolume name length limit test | expand

Commit Message

Su Yanjun Sept. 18, 2018, 8:44 a.m. UTC
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>
---
 .../033-filename-length-limit/test.sh         | 86 +++++++++++++++++++
 1 file changed, 86 insertions(+)
 create mode 100755 tests/misc-tests/033-filename-length-limit/test.sh

Comments

David Sterba Oct. 24, 2018, 3:28 p.m. UTC | #1
On Tue, Sep 18, 2018 at 04:44:48PM +0800, Su Yanjun wrote:
> 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>

Applied, with some adjustments, thanks.
diff mbox series

Patch

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 000000000000..7764ad9b584c
--- /dev/null
+++ b/tests/misc-tests/033-filename-length-limit/test.sh
@@ -0,0 +1,86 @@ 
+#!/bin/bash
+#
+# test file name length limit settings
+
+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 aaa
+# 255
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$longname"
+# 256, must fail
+run_mustfail "name 256 bytes long succeeded" \
+	$SUDO_HELPER "$TOP/btrfs" subvolume create "$longname"5
+# 255*2, must fail
+run_mustfail "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 aaa snaps/bbb
+# 255
+run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot aaa snaps/"$longname"
+# 256, must fail
+run_mustfail "name 256 bytes long succeeded" \
+	$SUDO_HELPER "$TOP/btrfs" subvolume snapshot aaa snaps/"$longname"5
+# 255*2, must fail
+run_mustfail "name 2 * 255 bytes long succeeded" \
+	$SUDO_HELPER "$TOP/btrfs" subvolume snapshot aaa snaps/"$longname$longname"
+
+cd ..
+
+run_check_umount_test_dev