btrfs-progs: test/mkfs: Test if the minimal device size is valid
[platform/upstream/btrfs-progs.git] / tests / mkfs-tests / 010-minimal-size / test.sh
1 #!/bin/bash
2 # test if the reported minimal size of mkfs.btrfs is valid
3
4 source "$TOP/tests/common"
5
6 check_prereq mkfs.btrfs
7 check_prereq btrfs
8
9 setup_root_helper
10
11 do_test()
12 {
13         # 1M should be small enough to reliably fail, we use the output to get
14         # the minimal device size for the given option combination
15         prepare_test_dev 1M
16         output=$(run_mustfail_stdout "mkfs.btrfs for small image" \
17                  "$TOP/mkfs.btrfs" -f $@ "$TEST_DEV")
18         good_size=$(echo "$output" | grep -oP "(?<=is )\d+")
19
20         prepare_test_dev "$good_size"
21         run_check $TOP/mkfs.btrfs -f $@ "$TEST_DEV"
22         run_check_mount_test_dev
23         run_check_umount_test_dev
24 }
25
26 do_test -n 4k   -m single       -d single
27 do_test -n 4k   -m single       -d dup
28 do_test -n 4k   -m dup          -d single
29 do_test -n 4k   -m dup          -d dup
30
31 do_test -n 8k   -m single       -d single
32 do_test -n 8k   -m single       -d dup
33 do_test -n 8k   -m dup          -d single
34 do_test -n 8k   -m dup          -d dup
35
36 do_test -n 16k  -m single       -d single
37 do_test -n 16k  -m single       -d dup
38 do_test -n 16k  -m dup          -d single
39 do_test -n 16k  -m dup          -d dup
40
41 do_test -n 32k  -m single       -d single
42 do_test -n 32k  -m single       -d dup
43 do_test -n 32k  -m dup          -d single
44 do_test -n 32k  -m dup          -d dup
45
46 do_test -n 64k  -m single       -d single
47 do_test -n 64k  -m single       -d dup
48 do_test -n 64k  -m dup          -d single
49 do_test -n 64k  -m dup          -d dup