From patchwork Mon Jul 27 14:01:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaolei X-Patchwork-Id: 6874321 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4E476C05AC for ; Mon, 27 Jul 2015 14:03:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93A59206E2 for ; Mon, 27 Jul 2015 14:03:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA65A206C3 for ; Mon, 27 Jul 2015 14:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753422AbbG0ODn (ORCPT ); Mon, 27 Jul 2015 10:03:43 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:27556 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753800AbbG0ODj (ORCPT ); Mon, 27 Jul 2015 10:03:39 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="98938163" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 27 Jul 2015 22:07:12 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t6RE1j3t026017 for ; Mon, 27 Jul 2015 22:01:45 +0800 Received: from localhost.localdomain (10.167.226.114) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Mon, 27 Jul 2015 22:03:35 +0800 From: Zhaolei To: CC: Zhao Lei Subject: [PATCH 2/2] btrfs-progs-tests: Fix mount fail of 013-extent-tree-rebuild Date: Mon, 27 Jul 2015 22:01:59 +0800 Message-ID: X-Mailer: git-send-email 1.8.5.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Zhao Lei When using loop device for test, fsck-tests/013-extent-tree-rebuild failed with following error message: # ./fsck-tests.sh ... [TEST] 013-extent-tree-rebuild failed: mount /data/btrfsprogs/tests/test.img /data/btrfsprogs/tests/mnt test failed for case 013-extent-tree-rebuild # Considering that $TEST_DEV can be block or loop device, we need determine our mount option in a condition for both case. This patch make above request to a common function, to solve current problem in 013-extent-tree-rebuild, and support similar request in future. Signed-off-by: Zhao Lei --- tests/common | 24 ++++++++++++++++++++++++ tests/fsck-tests/013-extent-tree-rebuild/test.sh | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/common b/tests/common index ba0b78a..381ff96 100644 --- a/tests/common +++ b/tests/common @@ -165,3 +165,27 @@ init_env() mkdir -p "$TEST_MNT" || { echo "Failed mkdir -p $TEST_MNT"; exit 1; } } init_env + +mount_test_dev() +{ + local loop_opt + if [[ -b "$TEST_DEV" ]]; then + loop_opt=() + elif [[ -f "$TEST_DEV" ]]; then + loop_opt=(-o loop) + else + _fail "Invalid \$TEST_DEV: $TEST_DEV" + fi + + [[ -d "$TEST_MNT" ]] || { + _fail "Invalid \$TEST_MNT: $TEST_MNT" + } + + mount "${loop_opt[@]}" "$TEST_DEV" "$TEST_MNT" || _fail "mount $TEST_DEV to $TEST_MNT failed" +} + +umount_test_dev() +{ + umount "$TEST_DEV" +} + diff --git a/tests/fsck-tests/013-extent-tree-rebuild/test.sh b/tests/fsck-tests/013-extent-tree-rebuild/test.sh index b7909d2..ff3c922 100755 --- a/tests/fsck-tests/013-extent-tree-rebuild/test.sh +++ b/tests/fsck-tests/013-extent-tree-rebuild/test.sh @@ -12,14 +12,14 @@ test_extent_tree_rebuild() { run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV - run_check $SUDO_HELPER mount $TEST_DEV $TEST_MNT + run_check $SUDO_HELPER mount_test_dev run_check $SUDO_HELPER cp -aR /lib/modules/`uname -r`/ $TEST_MNT for i in `seq 1 100`;do run_check $SUDO_HELPER $TOP/btrfs sub snapshot $TEST_MNT \ $TEST_MNT/snapaaaaaaa_$i done - run_check $SUDO_HELPER umount $TEST_DEV + run_check $SUDO_HELPER umount_test_dev # get extent root bytenr extent_root_bytenr=`$SUDO_HELPER $TOP/btrfs-debug-tree -r $TEST_DEV | \