btrfs-progs: tests, adjust alignment of the pretty command name
[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         shift
20         echo "creating ext image with: $*" >> convert-tests-results.txt
21         # 256MB is the smallest acceptable btrfs image.
22         rm -f $here/test.img >> convert-tests-results.txt 2>&1 \
23                 || _fail "could not remove test image file"
24         truncate -s 256M $here/test.img >> convert-tests-results.txt 2>&1 \
25                 || _fail "could not create test image file"
26         $* -F $here/test.img >> convert-tests-results.txt 2>&1 \
27                 || _fail "filesystem create failed"
28         $here/btrfs-convert $here/test.img >> convert-tests-results.txt 2>&1 \
29                 || _fail "btrfs-convert failed"
30         $here/btrfs check $here/test.img >> convert-tests-results.txt 2>&1 \
31                 || _fail "btrfs check detected errors"
32 }
33
34 # btrfs-convert requires 4k blocksize.
35 test "ext2" mke2fs -b 4096
36 test "ext3" mke2fs -j -b 4096
37 test "ext4" mke2fs -t ext4 -b 4096