summaryrefslogtreecommitdiff
path: root/tests/convert-tests.sh
blob: 87369c5ed37022fa9bf91681240cdfe64816d2c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
#
# convert ext2/3/4 images to btrfs images, and make sure the results are
# clean.
#

here=`pwd`

_fail()
{
	echo "$*" | tee -a convert-tests-results.txt
	exit 1
}

rm -f convert-tests-results.txt
rm -f test.img

test(){
	echo "     [TEST]    $1"
        shift
        echo "creating ext image with: $*" >> convert-tests-results.txt
	# 256MB is the smallest acceptable btrfs image.
	dd if=/dev/zero of=$here/test.img bs=1024 count=$((256*1024)) \
		>> convert-tests-results.txt 2>&1 || _fail "dd failed"
	$* -F $here/test.img >> convert-tests-results.txt 2>&1 \
		|| _fail "filesystem create failed"
	$here/btrfs-convert $here/test.img >> convert-tests-results.txt 2>&1 \
		|| _fail "btrfs-convert failed"
	$here/btrfsck $here/test.img >> convert-tests-results.txt 2>&1 \
		|| _fail "btrfsck detected errors"
}

test "ext2, 4k blocksize" mke2fs -b 4096
test "ext3, 4k blocksize" mke2fs -j -b 4096
test "ext4, 4k blocksize" mke2fs -t ext4 -b 4096