btrfs-progs: tests: Add testcase for rootdir inline extent size
[platform/upstream/btrfs-progs.git] / tests / mkfs-tests / 014-rootdir-inline-extent / test.sh
1 #!/bin/bash
2 # Regression test for mkfs.btrfs --rootdir with inline file extents
3 # For any large inline file extent, btrfs check could already report it
4
5 source "$TEST_TOP/common"
6
7 check_global_prereq fallocate
8 check_prereq mkfs.btrfs
9
10 prepare_test_dev
11
12 tmp=$(mktemp -d --tmpdir btrfs-progs-mkfs.rootdirXXXXXXX)
13
14 pagesize=$(getconf PAGESIZE)
15 create_file()
16 {
17         local size=$1
18         # Reuse size as filename
19         run_check fallocate -l $size "$tmp/$size"
20 }
21
22 test_mkfs_rootdir()
23 {
24         nodesize=$1
25         run_check "$TOP/mkfs.btrfs" --nodesize $nodesize -f --rootdir "$tmp" \
26                 "$TEST_DEV"
27         run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
28 }
29
30 # Use power of 2 from 512 to 64K (maximum node size) as base file size
31 for i in 512 1024 2048 4096 8192 16384 32768; do
32         create_file $(($i - 102))
33         # 101 is the overhead size for max inline extent
34         create_file $(($i - 101))
35         create_file $(($i - 100))
36
37         create_file $(($i - 1))
38         create_file $i
39         create_file $(($i + 1))
40 done
41
42 for nodesize in 4096 8192 16384 32768 65536; do
43         if [ $nodesize -ge $pagesize ]; then
44                 test_mkfs_rootdir $nodesize
45         fi
46 done
47 rm -rf -- "$tmp"