summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-03-22 19:01:39 +0100
committerDavid Sterba <dsterba@suse.com>2016-03-30 16:26:09 +0200
commitd7477bcd0b714a984f83b78aa19a9785bf3c8039 (patch)
tree2bc84411b729c27a5f3aec28202471bd4d41f28a
parent10d308d5ead864fe6b3db5228ed7833163bbca97 (diff)
btrfs-progs: tests: add misc 014-filesystem-label
Test various label lengths on a mounted filesystem. Signed-off-by: David Sterba <dsterba@suse.com>
-rwxr-xr-xtests/misc-tests/014-filesystem-label/test.sh69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/misc-tests/014-filesystem-label/test.sh b/tests/misc-tests/014-filesystem-label/test.sh
new file mode 100755
index 00000000..a5e08ccc
--- /dev/null
+++ b/tests/misc-tests/014-filesystem-label/test.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+#
+# test label settings
+
+source $TOP/tests/common
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+
+run_check truncate -s 2G $IMAGE
+run_check $TOP/mkfs.btrfs -L BTRFS-TEST-LABEL -f $IMAGE
+run_check $SUDO_HELPER mount $IMAGE $TEST_MNT
+run_check $SUDO_HELPER chmod a+rw $TEST_MNT
+
+cd $TEST_MNT
+run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT
+# shortest label
+run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT a
+run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT
+run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT ''
+
+longlabel=\
+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
+
+run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT "$longlabel"
+run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT
+# 256, must fail
+run_mustfail "label 256 bytes long succeeded" \
+ $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT "$longlabel"5
+run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT
+run_mustfail "label 2 * 255 bytes long succeeded" \
+ $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT "$longlabel$longlabel"
+run_check $SUDO_HELPER $TOP/btrfs filesystem label $TEST_MNT
+
+cd ..
+
+run_check $SUDO_HELPER umount $TEST_MNT