summaryrefslogtreecommitdiff
path: root/tests/convert-tests.sh
blob: 3d912f349aa051c23732008949e7a8085b978f44 (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
36
37
38
39
40
41
42
#!/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

test(){
	echo "    [TEST]   $1"
	nodesize=$2
	shift 2
	echo "creating ext image with: $*" >> convert-tests-results.txt
	# 256MB is the smallest acceptable btrfs image.
	rm -f $here/test.img >> convert-tests-results.txt 2>&1 \
		|| _fail "could not remove test image file"
	truncate -s 256M $here/test.img >> convert-tests-results.txt 2>&1 \
		|| _fail "could not create test image file"
	$* -F $here/test.img >> convert-tests-results.txt 2>&1 \
		|| _fail "filesystem create failed"
	$here/btrfs-convert -N "$nodesize" $here/test.img \
			>> convert-tests-results.txt 2>&1 \
		|| _fail "btrfs-convert failed"
	$here/btrfs check $here/test.img >> convert-tests-results.txt 2>&1 \
		|| _fail "btrfs check detected errors"
}

# btrfs-convert requires 4k blocksize.
test "ext2 4k nodesize" 4096 mke2fs -b 4096
test "ext3 4k nodesize" 4096 mke2fs -j -b 4096
test "ext4 4k nodesize" 4096 mke2fs -t ext4 -b 4096
test "ext2 16k nodesize" 16384 mke2fs -b 4096
test "ext3 16k nodesize" 16384 mke2fs -j -b 4096
test "ext4 16k nodesize" 16384 mke2fs -t ext4 -b 4096