f33b8aa399f44f61b82c03eb5c1f6e51851dcdef
[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         echo "Minimal device size is $good_size" >> "$RESULTS"
22         run_check $TOP/mkfs.btrfs -f $@ "$TEST_DEV"
23         run_check_mount_test_dev
24         run_check_umount_test_dev
25 }
26
27 do_test -n 4k   -m single       -d single
28 do_test -n 4k   -m single       -d dup
29 do_test -n 4k   -m dup          -d single
30 do_test -n 4k   -m dup          -d dup
31
32 do_test -n 8k   -m single       -d single
33 do_test -n 8k   -m single       -d dup
34 do_test -n 8k   -m dup          -d single
35 do_test -n 8k   -m dup          -d dup
36
37 do_test -n 16k  -m single       -d single
38 do_test -n 16k  -m single       -d dup
39 do_test -n 16k  -m dup          -d single
40 do_test -n 16k  -m dup          -d dup
41
42 do_test -n 32k  -m single       -d single
43 do_test -n 32k  -m single       -d dup
44 do_test -n 32k  -m dup          -d single
45 do_test -n 32k  -m dup          -d dup
46
47 do_test -n 64k  -m single       -d single
48 do_test -n 64k  -m single       -d dup
49 do_test -n 64k  -m dup          -d single
50 do_test -n 64k  -m dup          -d dup