set -e
export PATH=$PATH:/lib/firmware/foo/usr/bin/
MKFS="mke2fs -q -t ext4"

_testit() {
	mount /dev/sda1 /mnt
	(cd /mnt ; dbench -s 2 -c /lib/firmware/foo/usr/share/dbench/client.txt | tail -1)
	umount /mnt
}

testit() {
	_testit
	_testit
	_testit
}


# Unaligned
cat <<END | sfdisk -q -f -H255 -S63 -uS /dev/sda > /dev/null
63,
;
END

echo "Unaligned, unqualified"
$MKFS /dev/sda1
testit

echo "Unaligned, stripe-width=32"
$MKFS /dev/sda1 -E stripe-width=32
testit

echo "Unaligned, stride=32"
$MKFS /dev/sda1 -E stride=32
testit

echo "Unaligned, stripe-width=128"
$MKFS /dev/sda1 -E stripe-width=128
testit

# Aligned
cat <<END | sfdisk -q -f -H255 -S63 -uS /dev/sda > /dev/null
256,
;
END

echo "Aligned, unqualified"
$MKFS /dev/sda1
testit

echo "Aligned, stripe-width=32"
$MKFS /dev/sda1 -E stripe-width=32
testit

echo "Aligned, stride=32"
$MKFS /dev/sda1 -E stride=32
testit

echo "Aligned, stripe-width=128"
$MKFS /dev/sda1 -E stripe-width=128
testit
