btrfs-progs: test/mkfs: Test if the minimal device size is valid
authorQu Wenruo <wqu@suse.com>
Thu, 12 Oct 2017 07:11:33 +0000 (15:11 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jan 2018 17:11:35 +0000 (18:11 +0100)
New test case to test if the minimal device size given by "mkfs.btrfs"
failure case is valid.

Signed-off-by: Qu Wenruo <wqu@suse.com>
[ renamed script ]
Signed-off-by: David Sterba <dsterba@suse.com>
tests/mkfs-tests/010-minimal-size/test.sh [new file with mode: 0755]

diff --git a/tests/mkfs-tests/010-minimal-size/test.sh b/tests/mkfs-tests/010-minimal-size/test.sh
new file mode 100755 (executable)
index 0000000..f75a22d
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/bash
+# test if the reported minimal size of mkfs.btrfs is valid
+
+source "$TOP/tests/common"
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+
+do_test()
+{
+       # 1M should be small enough to reliably fail, we use the output to get
+       # the minimal device size for the given option combination
+       prepare_test_dev 1M
+       output=$(run_mustfail_stdout "mkfs.btrfs for small image" \
+                "$TOP/mkfs.btrfs" -f $@ "$TEST_DEV")
+       good_size=$(echo "$output" | grep -oP "(?<=is )\d+")
+
+       prepare_test_dev "$good_size"
+       run_check $TOP/mkfs.btrfs -f $@ "$TEST_DEV"
+       run_check_mount_test_dev
+       run_check_umount_test_dev
+}
+
+do_test -n 4k  -m single       -d single
+do_test -n 4k  -m single       -d dup
+do_test -n 4k  -m dup          -d single
+do_test -n 4k  -m dup          -d dup
+
+do_test -n 8k  -m single       -d single
+do_test -n 8k  -m single       -d dup
+do_test -n 8k  -m dup          -d single
+do_test -n 8k  -m dup          -d dup
+
+do_test -n 16k -m single       -d single
+do_test -n 16k -m single       -d dup
+do_test -n 16k -m dup          -d single
+do_test -n 16k -m dup          -d dup
+
+do_test -n 32k -m single       -d single
+do_test -n 32k -m single       -d dup
+do_test -n 32k -m dup          -d single
+do_test -n 32k -m dup          -d dup
+
+do_test -n 64k -m single       -d single
+do_test -n 64k -m single       -d dup
+do_test -n 64k -m dup          -d single
+do_test -n 64k -m dup          -d dup