All of lore.kernel.org
 help / color / mirror / Atom feed
From: Su Yanjun <suyj.fnst@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: Su Yanjun <suyj.fnst@cn.fujitsu.com>
Subject: [PATCH] btrfs-progs: tests: Add the testcase for subvolume name length limit test
Date: Tue, 18 Sep 2018 16:44:48 +0800	[thread overview]
Message-ID: <20180918084448.14195-1-suyj.fnst@cn.fujitsu.com> (raw)

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

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
-- 
2.18.0

             reply	other threads:[~2018-09-18 14:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-18  8:44 Su Yanjun [this message]
2018-10-24 15:28 ` [PATCH] btrfs-progs: tests: Add the testcase for subvolume name length limit test David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180918084448.14195-1-suyj.fnst@cn.fujitsu.com \
    --to=suyj.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.