4a84e6db077452d067f9186bab6906b63a2df9e1
[platform/upstream/btrfs-progs.git] / tests / mkfs-tests / 004-rootdir-keeps-size / test.sh
1 #!/bin/bash
2 # make sure that mkfs.btrfs --rootsize does not change size of the image
3
4 source "$TEST_TOP/common"
5
6 check_prereq mkfs.btrfs
7
8 prepare_test_dev
9
10 test_mkfs_with_size() {
11         local size
12         local imgsize
13         local tmp
14
15         size="$1"
16         run_check truncate -s$size $TEST_DEV
17         imgsize=$(run_check_stdout stat --format=%s $TEST_DEV)
18         run_check $SUDO_HELPER $TOP/mkfs.btrfs -f \
19                 --rootdir $INTERNAL_BIN/Documentation \
20                 $TEST_DEV
21         tmp=$(run_check_stdout stat --format=%s $TEST_DEV)
22         if ! [ "$imgsize" = "$tmp" ]; then
23                 _fail "image size changed from $imgsize to $tmp"
24         fi
25 }
26
27 test_mkfs_with_size 128M
28 test_mkfs_with_size 256M
29 test_mkfs_with_size 512M
30 test_mkfs_with_size 1G
31 test_mkfs_with_size 2G