summaryrefslogtreecommitdiff
path: root/tests/convert-tests/014-reiserfs-tail-handling
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2017-08-22 18:32:57 +0200
committerDavid Sterba <dsterba@suse.com>2017-09-08 16:15:05 +0200
commite75f466ddd8138093b5355af9fda24ca204bce58 (patch)
treeda24f71cfff5d4eeefee0f70c43f6d217819e5b7 /tests/convert-tests/014-reiserfs-tail-handling
parent99340c2ef762f3da92e4bb4ce3b2f6d5fc6ef9d0 (diff)
btrfs-progs: tests: add support for converting reiserfs
Many of the test cases for convert apply regardless of what the source file system is and using ext4 is sufficient. I've included several test cases that are reiserfs-specific. Signed-off-by: Jeff Mahoney <jeffm@suse.com> [ patch split from the previous one, minor cleanups in common.convert ] Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tests/convert-tests/014-reiserfs-tail-handling')
-rwxr-xr-xtests/convert-tests/014-reiserfs-tail-handling/test.sh73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/convert-tests/014-reiserfs-tail-handling/test.sh b/tests/convert-tests/014-reiserfs-tail-handling/test.sh
new file mode 100755
index 00000000..58cfaa4b
--- /dev/null
+++ b/tests/convert-tests/014-reiserfs-tail-handling/test.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+# Check the various combinations of real blocks, holes, and tails
+# Since it's possible to have a valid extent layout that check will
+# happily accept AND have garbage in the output, compare the results
+# as well.
+# We use separate inputs for tails and real blocks so we can determine
+# if there was a failure in copying either.
+
+source "$TOP/tests/common"
+source "$TOP/tests/common.convert"
+
+setup_root_helper
+prepare_test_dev 512M
+check_prereq btrfs-convert
+check_global_prereq md5sum
+
+perl -e "print 'a'x8192;" > input
+perl -e "print 'b'x8192;" > input2
+
+default_mkfs="mkreiserfs -b 4096"
+convert_test_preamble '' 'tail conversion test' 16k "$default_mkfs"
+convert_test_prep_fs reiserfs $default_mkfs
+
+# Hole alone
+run_check $SUDO_HELPER truncate -s 81920 "$TEST_MNT/hole"
+
+# Tail alone
+run_check $SUDO_HELPER dd if=input of="$TEST_MNT/1k" bs=1k count=1 \
+ > /dev/null 2>&1
+
+# Single indirect block
+run_check $SUDO_HELPER dd if=input of="$TEST_MNT/4k" bs=1k count=4 \
+ > /dev/null 2>&1
+
+# Indirect block + tail
+run_check $SUDO_HELPER dd if=input of="$TEST_MNT/5k" bs=1k count=4 \
+ > /dev/null 2>&1
+run_check $SUDO_HELPER dd if=input2 of="$TEST_MNT/5k" bs=1k count=1 \
+ seek=4 > /dev/null 2>&1
+
+# Hole followed by tail
+run_check $SUDO_HELPER dd if=input of="$TEST_MNT/hole-1k" bs=1k count=1 \
+ seek=4 > /dev/null 2>&1
+
+# Indirect block followed by hole
+run_check $SUDO_HELPER dd if=input of="$TEST_MNT/4k-hole" bs=1k count=4 \
+ > /dev/null 2>&1
+run_check $SUDO_HELPER truncate -s 81920 "$TEST_MNT/4k-hole"
+
+# Indirect block followed by hole followed by tail
+run_check $SUDO_HELPER dd if=input of="$TEST_MNT/4k-hole-1k" bs=1k count=4 \
+ > /dev/null 2>&1
+run_check $SUDO_HELPER truncate -s 8192 "$TEST_MNT/4k-hole-1k"
+run_check $SUDO_HELPER dd if=input2 of="$TEST_MNT/4k-hole-1k" bs=1k count=1 \
+ seek=8 > /dev/null 2>&1
+
+rm -f input input2
+
+declare -A SUMS
+for file in "$TEST_MNT"/*; do
+ SUM=$(md5sum "$file")
+ SUMS["$file"]=$SUM
+done
+
+run_check_umount_test_dev
+convert_test_do_convert
+
+run_check_mount_test_dev
+for file in "${!SUMS[@]}"; do
+ SUM=$(md5sum "$file")
+ run_check test "$SUM" = "${SUMS[$file]}"
+done
+run_check_umount_test_dev