btrfs-progs: introduce TEST_TOP and INTERNAL_BIN for tests
[platform/upstream/btrfs-progs.git] / tests / misc-tests / 008-leaf-crossing-stripes / test.sh
1 #!/bin/bash
2 # test if btrfs-convert creates a filesystem without leaf crossing stripes
3
4 source "$TEST_TOP/common"
5
6 check_prereq btrfs-convert
7 check_prereq btrfs
8
9 # In my test, it happened in 514M~560M, 737M~769M, 929M~917M,
10 # and HAVE_ERROR=((size + 1) / 2) % 2 if size >= 970
11 #
12 SIZE_FROM=514
13 SIZE_END=560
14 A_PRIME_NUM=17
15 for ((size = SIZE_FROM; size <= SIZE_END; size += A_PRIME_NUM)); do
16         run_check truncate -s "$size"M "$IMAGE"
17         run_check mkfs.ext4 -F "$IMAGE"
18         run_check $TOP/btrfs-convert "$IMAGE"
19         run_check_stdout $TOP/btrfs check "$IMAGE" 2>&1 |
20                 grep -q "crossing stripe boundary" &&
21                 _fail "leaf crossing stripes after btrfs-convert"
22 done
23
24 # grep will expectedly fail
25 exit 0