From patchwork Wed May 17 01:41:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 9731477 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9925B602B4 for ; Wed, 17 May 2017 15:31:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89A4828459 for ; Wed, 17 May 2017 15:31:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E88D287C1; Wed, 17 May 2017 15:31:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.9 required=2.0 tests=BAYES_00, DATE_IN_PAST_12_24, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F4B0286DF for ; Wed, 17 May 2017 15:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754037AbdEQPbb (ORCPT ); Wed, 17 May 2017 11:31:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:60344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753944AbdEQPba (ORCPT ); Wed, 17 May 2017 11:31:30 -0400 Received: from debian3.lan (bl12-226-64.dsl.telepac.pt [85.245.226.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D13E223986 for ; Wed, 17 May 2017 15:31:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D13E223986 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=fdmanana@kernel.org From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH 2/2] btrfs-progs: test for restoring multiple devices fs into a single device Date: Wed, 17 May 2017 02:41:31 +0100 Message-Id: <20170517014131.8549-1-fdmanana@kernel.org> X-Mailer: git-send-email 2.11.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Filipe Manana Test that we are able to create an image from a multiple devices fs, that we are able to restore that image into a single device and finally that we are able to mount it. Signed-off-by: Filipe Manana Reviewed-by: Liu Bo --- tests/misc-tests/020-image-multi-devices/test.sh | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 tests/misc-tests/020-image-multi-devices/test.sh diff --git a/tests/misc-tests/020-image-multi-devices/test.sh b/tests/misc-tests/020-image-multi-devices/test.sh new file mode 100755 index 00000000..d4a5f006 --- /dev/null +++ b/tests/misc-tests/020-image-multi-devices/test.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Test btrfs-image with multiple devices filesystem and verify that restoring +# the created image works against a single device. + +source $TOP/tests/common + +check_prereq btrfs-image +check_prereq mkfs.btrfs +check_prereq btrfs + +setup_root_helper + +rm -f dev1 dev2 +run_check truncate -s 2G dev1 +run_check truncate -s 2G dev2 + +loop1=$(run_check_stdout $SUDO_HELPER losetup --find --show dev1) +loop2=$(run_check_stdout $SUDO_HELPER losetup --find --show dev2) + +# Create the test file system. + +run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $loop1 $loop2 +run_check $SUDO_HELPER mount $loop1 $TEST_MNT +run_check $SUDO_HELPER dd bs=1M count=1 if=/dev/zero of=$TEST_MNT/foobar +orig_md5=$(run_check_stdout md5sum $TEST_MNT/foobar | cut -d ' ' -f 1) +run_check $SUDO_HELPER umount $TEST_MNT + +# Create the image to restore later. +run_check $SUDO_HELPER $TOP/btrfs-image $loop1 $IMAGE + +# Wipe out the filesystem from the devices, restore the image on a single +# device, check everything works and file foobar is there and with 1Mb of +# zeroes. +run_check $SUDO_HELPER wipefs -a $loop1 +run_check $SUDO_HELPER wipefs -a $loop2 + +run_check $SUDO_HELPER $TOP/btrfs-image -r $IMAGE $loop1 + +run_check $SUDO_HELPER mount $loop1 $TEST_MNT +new_md5=$(run_check_stdout md5sum $TEST_MNT/foobar | cut -d ' ' -f 1) +run_check $SUDO_HELPER umount $TEST_MNT + +# Cleanup loop devices. +run_check $SUDO_HELPER losetup -d $loop1 +run_check $SUDO_HELPER losetup -d $loop2 +rm -f dev1 dev2 + +# Compare the file digests. +[ $orig_md5 == $new_md5 ] || _fail "File digests do not match"