From patchwork Wed Nov 1 01:30:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10035807 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 D730B603B5 for ; Wed, 1 Nov 2017 01:31:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C97EF28920 for ; Wed, 1 Nov 2017 01:31:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE64428B2B; Wed, 1 Nov 2017 01:31:02 +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=-6.9 required=2.0 tests=BAYES_00,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 6F27228920 for ; Wed, 1 Nov 2017 01:31:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754049AbdKABax (ORCPT ); Tue, 31 Oct 2017 21:30:53 -0400 Received: from prv3-mh.provo.novell.com ([137.65.250.26]:57078 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754044AbdKABaw (ORCPT ); Tue, 31 Oct 2017 21:30:52 -0400 Received: from adam-pc.lan (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Tue, 31 Oct 2017 19:30:50 -0600 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH v4 3/4] btrfs-progs: test/common: Enhance prepare_test_dev to reset device size Date: Wed, 1 Nov 2017 09:30:42 +0800 Message-Id: <20171101013043.19294-4-wqu@suse.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171101013043.19294-1-wqu@suse.com> References: <20171101013043.19294-1-wqu@suse.com> 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 So prepare_test_dev() can be called several times in one test case, to test different device sizes. Signed-off-by: Qu Wenruo --- tests/common | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/common b/tests/common index 977bade201a6..63750dbfeffe 100644 --- a/tests/common +++ b/tests/common @@ -441,8 +441,12 @@ prepare_test_dev() # num[K/M/G/T...] local size="$1" - [[ "$TEST_DEV" ]] && return [[ "$size" ]] || size='2G' + # Still truncate it to new size + if [[ "$TEST_DEV" ]]; then + truncate -s "$size" "$TEST_DEV" + return; + fi echo "\$TEST_DEV not given, use $TOP/test/test.img as fallback" >> \ "$RESULTS"