summaryrefslogtreecommitdiff
path: root/tests/convert-tests.sh
diff options
context:
space:
mode:
authorAdam Buchbinder <abuchbinder@google.com>2014-05-21 10:20:27 -0700
committerDavid Sterba <dsterba@suse.cz>2014-08-22 14:39:35 +0200
commit2100836188672d64adf0def8975dceea710ce51c (patch)
tree0dba4504e81933c0348cb347eaea913afa2a6a83 /tests/convert-tests.sh
parent700c3ca9b1312c19ed5c657da3137a6b6f6fa63c (diff)
downloadbtrfs-progs-2100836188672d64adf0def8975dceea710ce51c.tar.gz
btrfs-progs: Add some simple end-to-end tests for btrfs-convert
These use the system's mke2fs, and don't require loop devices or root privileges. They don't pick up anything with the default flags right now, but they do pick up some sanitizer issues when the tools are compiled with any of -fsanitize={address,memory,thread}. Signed-off-by: Adam Buchbinder <abuchbinder@google.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'tests/convert-tests.sh')
-rw-r--r--tests/convert-tests.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/convert-tests.sh b/tests/convert-tests.sh
new file mode 100644
index 0000000..87369c5
--- /dev/null
+++ b/tests/convert-tests.sh
@@ -0,0 +1,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