btrfs-progs: Add nodesize test for btrfs-convert
[platform/upstream/btrfs-progs.git] / tests / convert-tests.sh
1 #!/bin/bash
2 #
3 # convert ext2/3/4 images to btrfs images, and make sure the results are
4 # clean.
5 #
6
7 here=`pwd`
8
9 _fail()
10 {
11         echo "$*" | tee -a convert-tests-results.txt
12         exit 1
13 }
14
15 rm -f convert-tests-results.txt
16
17 test(){
18         echo "    [TEST]   $1"
19         nodesize=$2
20         shift 2
21         echo "creating ext image with: $*" >> convert-tests-results.txt
22         # 256MB is the smallest acceptable btrfs image.
23         rm -f $here/test.img >> convert-tests-results.txt 2>&1 \
24                 || _fail "could not remove test image file"
25         truncate -s 256M $here/test.img >> convert-tests-results.txt 2>&1 \
26                 || _fail "could not create test image file"
27         $* -F $here/test.img >> convert-tests-results.txt 2>&1 \
28                 || _fail "filesystem create failed"
29         $here/btrfs-convert -N "$nodesize" $here/test.img \
30                         >> convert-tests-results.txt 2>&1 \
31                 || _fail "btrfs-convert failed"
32         $here/btrfs check $here/test.img >> convert-tests-results.txt 2>&1 \
33                 || _fail "btrfs check detected errors"
34 }
35
36 # btrfs-convert requires 4k blocksize.
37 test "ext2 4k nodesize" 4096 mke2fs -b 4096
38 test "ext3 4k nodesize" 4096 mke2fs -j -b 4096
39 test "ext4 4k nodesize" 4096 mke2fs -t ext4 -b 4096
40 test "ext2 16k nodesize" 16384 mke2fs -b 4096
41 test "ext3 16k nodesize" 16384 mke2fs -j -b 4096
42 test "ext4 16k nodesize" 16384 mke2fs -t ext4 -b 4096