]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
xfstests btrfs/012: test btrfs-convert
authorEric Sandeen <sandeen@redhat.com>
Sun, 4 Aug 2013 20:12:31 +0000 (20:12 +0000)
committerRich Johnston <rjohnston@sgi.com>
Sun, 13 Oct 2013 00:30:19 +0000 (19:30 -0500)
Turns out btrfs-convert broke on July 3, and lo! we
do not have a regression test, and now we have one,
and there was much rejoicing.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
tests/btrfs/012 [new file with mode: 0755]
tests/btrfs/012.out [new file with mode: 0644]
tests/btrfs/group

diff --git a/tests/btrfs/012 b/tests/btrfs/012
new file mode 100755 (executable)
index 0000000..de90149
--- /dev/null
@@ -0,0 +1,118 @@
+#! /bin/bash
+# FS QA Test No. 012
+#
+# Test btrfs-convert
+#
+# 1) create ext4 filesystem & populate it
+# 2) convert it to btrfs, mount it, verify contents
+# 3) verify archived ext4 image integriy & contents
+# 4) populate btrfs fs with new data
+# 5) roll back conversion to original ext4
+# 6) verify rolled-back fs integrity & contents
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "== QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter.btrfs
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+
+BTRFS_CONVERT_PROG="`set_prog_path btrfs-convert`"
+MKFS_EXT4_PROG="`set_prog_path mkfs.ext4`"
+E2FSCK_PROG="`set_prog_path e2fsck`"
+
+_require_command $BTRFS_CONVERT_PROG btrfs-convert
+_require_command $MKFS_EXT4_PROG mkfs.ext4
+_require_command $E2FSCK_PROG e2fsck
+
+rm -f $seqres.full
+
+# Create & populate an ext4 filesystem
+$MKFS_EXT4_PROG -b 4096 $SCRATCH_DEV > $seqres.full 2>&1 || \
+       _notrun "Could not create ext4 filesystem"
+# Manual mount so we don't use -t btrfs or selinux context
+mount -t ext4 $SCRATCH_DEV $SCRATCH_MNT
+
+cp -aR /lib/modules/`uname -r`/ $SCRATCH_MNT
+_scratch_unmount
+
+# Convert it to btrfs, mount it, verify the data
+$BTRFS_CONVERT_PROG $SCRATCH_DEV >> $seqres.full 2>&1 || \
+       _fail "btrfs-convert failed"
+_scratch_mount || _fail "Could not mount new btrfs fs"
+# (Ignore the symlinks which may be broken/nonexistent)
+diff -r /lib/modules/`uname -r`/ $SCRATCH_MNT/`uname -r`/ 2>&1 | grep -vw "source\|build"
+
+# Old ext4 image file should exist & be consistent
+$E2FSCK_PROG -fn $SCRATCH_MNT/ext2_saved/image >> $seqres.full 2>&1 || \
+       _fail "archived ext4 image is corrupt"
+
+# And the files in that image should match
+mkdir -p $SCRATCH_MNT/mnt
+mount -o loop $SCRATCH_MNT/ext2_saved/image $SCRATCH_MNT/mnt || \
+       _fail "could not loop mount saved ext4 image"
+# Ignore the symlinks which may be broken/nonexistent
+diff -r /lib/modules/`uname -r`/ $SCRATCH_MNT/mnt/`uname -r`/ 2>&1 | grep -vw "source\|build"
+umount $SCRATCH_MNT/mnt
+
+# Now put some fresh data on the btrfs fs
+mkdir -p $SCRATCH_MNT/new 
+cp -aR /lib/modules/`uname -r`/ $SCRATCH_MNT/new
+
+_scratch_unmount
+
+# Now restore the ext4 device
+$BTRFS_CONVERT_PROG -r $SCRATCH_DEV >> $seqres.full 2>&1 || \
+       _fail "btrfs-convert rollback failed"
+
+# Check it again
+$E2FSCK_PROG -fn $SCRATCH_DEV >> $seqres.full 2>&1 || \
+        _fail "restored ext4 image is corrupt"
+
+# Mount the un-converted ext4 device & check the contents
+mount -t ext4 $SCRATCH_DEV $SCRATCH_MNT
+# (Ignore the symlinks which may be broken/nonexistent)
+diff -r /lib/modules/`uname -r`/ $SCRATCH_MNT/`uname -r`/ 2>&1 | grep -vw "source\|build"
+
+_scratch_unmount
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/012.out b/tests/btrfs/012.out
new file mode 100644 (file)
index 0000000..2a41e7e
--- /dev/null
@@ -0,0 +1 @@
+== QA output created by 012
index d2fe030dbb849140a83eb31517f56048c3af7a88..2d2d005000a662eee975c186263f792654c3f64c 100644 (file)
@@ -14,3 +14,4 @@
 009 auto quick
 010 auto quick
 011 auto
+012 auto