mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-23 14:45:19 +00:00
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>
This commit is contained in:
parent
99340c2ef7
commit
e75f466ddd
@ -50,7 +50,7 @@ convert_test_preamble() {
|
||||
msg="$2"
|
||||
shift 3
|
||||
echo " [TEST/conv] $msg, btrfs" "${features:-defaults}"
|
||||
echo "creating ext image with: $@" >> "$RESULTS"
|
||||
echo "creating test image with: $@" >> "$RESULTS"
|
||||
}
|
||||
|
||||
# prepare TEST_DEV before conversion, create filesystem and mount it, image
|
||||
@ -59,6 +59,8 @@ convert_test_preamble() {
|
||||
# $2+: free form, command to create the filesystem, with appended -F
|
||||
convert_test_prep_fs() {
|
||||
local fstype
|
||||
local force
|
||||
local mountopts
|
||||
|
||||
fstype="$1"
|
||||
shift
|
||||
@ -67,10 +69,21 @@ convert_test_prep_fs() {
|
||||
run_check truncate -s 0 "$TEST_DEV"
|
||||
# 256MB is the smallest acceptable btrfs image.
|
||||
run_check truncate -s 512M "$TEST_DEV"
|
||||
run_check "$@" -F "$TEST_DEV"
|
||||
force=
|
||||
mountopts=
|
||||
case "$fstype" in
|
||||
ext[234])
|
||||
force=-F ;;
|
||||
reiserfs)
|
||||
force=-ff
|
||||
mountopts="-o acl,user_xattr,attrs" ;;
|
||||
*)
|
||||
_fail "unknown filesystem to convert: $fstype"
|
||||
esac
|
||||
run_check "$@" $force "$TEST_DEV"
|
||||
|
||||
# create a file to check btrfs-convert can convert regular file correct
|
||||
run_check_mount_convert_dev "$fstype"
|
||||
run_check_mount_convert_dev "$fstype" $mountopts
|
||||
|
||||
# create a file inside the fs before convert, to make sure there is
|
||||
# data covering btrfs backup superblock range (64M)
|
||||
|
16
tests/convert-tests/010-reiserfs-basic/test.sh
Executable file
16
tests/convert-tests/010-reiserfs-basic/test.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$TOP/tests/common"
|
||||
source "$TOP/tests/common.convert"
|
||||
|
||||
setup_root_helper
|
||||
prepare_test_dev 512M
|
||||
check_prereq btrfs-convert
|
||||
|
||||
for feature in '' 'extref' 'skinny-metadata' 'no-holes'; do
|
||||
convert_test reiserfs "$feature" "reiserfs 4k nodesize" 4096 mkreiserfs -b 4096
|
||||
convert_test reiserfs "$feature" "reiserfs 8k nodesize" 8192 mkreiserfs -b 4096
|
||||
convert_test reiserfs "$feature" "reiserfs 16k nodesize" 16384 mkreiserfs -b 4096
|
||||
convert_test reiserfs "$feature" "reiserfs 32k nodesize" 32768 mkreiserfs -b 4096
|
||||
convert_test reiserfs "$feature" "reiserfs 64k nodesize" 65536 mkreiserfs -b 4096
|
||||
done
|
67
tests/convert-tests/011-reiserfs-delete-all-rollback/test.sh
Executable file
67
tests/convert-tests/011-reiserfs-delete-all-rollback/test.sh
Executable file
@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
# create a base image, convert to btrfs, remove all files, rollback the reiserfs image
|
||||
|
||||
source "$TOP/tests/common"
|
||||
source "$TOP/tests/common.convert"
|
||||
|
||||
setup_root_helper
|
||||
prepare_test_dev 512M
|
||||
check_prereq btrfs-convert
|
||||
|
||||
# simple wrapper for a convert test
|
||||
# $1: btrfs features, argument to -O
|
||||
# $2: message
|
||||
# $3: nodesize value
|
||||
# $4 + rest: command to create the reiserfs image
|
||||
do_test() {
|
||||
local features
|
||||
local msg
|
||||
local nodesize
|
||||
local CHECKSUMTMP
|
||||
local here
|
||||
|
||||
features="$1"
|
||||
msg="$2"
|
||||
nodesize="$3"
|
||||
shift 3
|
||||
convert_test_preamble "$features" "$msg" "$nodesize" "$@"
|
||||
convert_test_prep_fs reiserfs "$@"
|
||||
populate_fs
|
||||
CHECKSUMTMP=$(mktemp --tmpdir btrfs-progs-convert.XXXXXXXXXX)
|
||||
convert_test_gen_checksums "$CHECKSUMTMP"
|
||||
|
||||
run_check_umount_test_dev
|
||||
|
||||
convert_test_do_convert "$features" "$nodesize"
|
||||
|
||||
run_check_mount_test_dev
|
||||
convert_test_post_check_checksums "$CHECKSUMTMP"
|
||||
|
||||
here=$(pwd)
|
||||
cd "$TEST_MNT" || _fail "cannot cd to TEST_MNT"
|
||||
# reiserfs_saved/image must not be deleted
|
||||
run_mayfail $SUDO_HELPER find "$TEST_MNT"/ -mindepth 1 -path '*reiserfs_saved' -prune -o -exec rm -vrf "{}" \;
|
||||
cd "$here"
|
||||
run_check "$TOP/btrfs" filesystem sync "$TEST_MNT"
|
||||
run_check_umount_test_dev
|
||||
convert_test_post_rollback
|
||||
|
||||
run_check_mount_convert_dev reiserfs
|
||||
convert_test_post_check_checksums "$CHECKSUMTMP"
|
||||
run_check_umount_test_dev
|
||||
|
||||
# mount again and verify checksums
|
||||
run_check_mount_convert_dev reiserfs
|
||||
convert_test_post_check_checksums "$CHECKSUMTMP"
|
||||
run_check_umount_test_dev
|
||||
|
||||
rm "$CHECKSUMTMP"
|
||||
}
|
||||
|
||||
for feature in '' 'extref' 'skinny-metadata' 'no-holes'; do
|
||||
do_test "$feature" "reiserfs 4k nodesize" 4096 mkreiserfs -b 4096
|
||||
do_test "$feature" "reiserfs 8k nodesize" 8192 mkreiserfs -b 4096
|
||||
do_test "$feature" "reiserfs 16k nodesize" 16384 mkreiserfs -b 4096
|
||||
do_test "$feature" "reiserfs 32k nodesize" 32768 mkreiserfs -b 4096
|
||||
do_test "$feature" "reiserfs 64k nodesize" 65536 mkreiserfs -b 4096
|
||||
done
|
23
tests/convert-tests/012-reiserfs-large-hole-extent/test.sh
Executable file
23
tests/convert-tests/012-reiserfs-large-hole-extent/test.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
# Create a base image with large hole extent, then convert to btrfs,
|
||||
# check the converted image.
|
||||
# Check if btrfs-convert can handle such large hole.
|
||||
# Fast pinpoint regression test. No options combination nor checksum
|
||||
# verification
|
||||
|
||||
source "$TOP/tests/common"
|
||||
source "$TOP/tests/common.convert"
|
||||
|
||||
setup_root_helper
|
||||
prepare_test_dev 512M
|
||||
check_prereq btrfs-convert
|
||||
|
||||
default_mkfs="mkreiserfs -b 4096"
|
||||
convert_test_preamble '' 'large hole extent test' 16k "$default_mkfs"
|
||||
convert_test_prep_fs reiserfs $default_mkfs
|
||||
|
||||
run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file" bs=1M \
|
||||
count=1 seek=1024 > /dev/null 2>&1
|
||||
|
||||
run_check_umount_test_dev
|
||||
convert_test_do_convert
|
35
tests/convert-tests/013-reiserfs-common-inode-flags/test.sh
Executable file
35
tests/convert-tests/013-reiserfs-common-inode-flags/test.sh
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
# Check if btrfs-convert can copy common inode flags like SYNC/IMMUTABLE
|
||||
|
||||
source "$TOP/tests/common"
|
||||
source "$TOP/tests/common.convert"
|
||||
|
||||
setup_root_helper
|
||||
prepare_test_dev 512M
|
||||
check_prereq btrfs-convert
|
||||
|
||||
fail=0
|
||||
default_mkfs="mkreiserfs -b 4096"
|
||||
convert_test_preamble '' 'common inode flags test' 16k "$default_mkfs"
|
||||
convert_test_prep_fs reiserfs $default_mkfs
|
||||
|
||||
# create file with specific flags
|
||||
run_check $SUDO_HELPER touch "$TEST_MNT/flag_test"
|
||||
run_check $SUDO_HELPER chattr +aAdSi "$TEST_MNT/flag_test"
|
||||
run_check lsattr "$TEST_MNT/flag_test"
|
||||
|
||||
run_check_umount_test_dev
|
||||
convert_test_do_convert
|
||||
run_check_mount_test_dev
|
||||
|
||||
# Log the status
|
||||
run_check lsattr "$TEST_MNT/flag_test"
|
||||
# Above flags should be copied to btrfs flags, and lsattr should get them
|
||||
run_check_stdout lsattr "$TEST_MNT/flag_test" | cut -f1 -d\ | grep "[aAdiS]" -q
|
||||
if [ $? -ne 0 ]; then
|
||||
rm tmp_output
|
||||
_fail "no common inode flags are copied after convert"
|
||||
fi
|
||||
|
||||
run_check_umount_test_dev
|
||||
convert_test_post_rollback
|
73
tests/convert-tests/014-reiserfs-tail-handling/test.sh
Executable file
73
tests/convert-tests/014-reiserfs-tail-handling/test.sh
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user