From patchwork Wed Nov 29 09:16:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10081659 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 6298C60353 for ; Wed, 29 Nov 2017 09:16:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63AA129739 for ; Wed, 29 Nov 2017 09:16:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 589C12973D; Wed, 29 Nov 2017 09:16:52 +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 3E8B129739 for ; Wed, 29 Nov 2017 09:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753921AbdK2JQp (ORCPT ); Wed, 29 Nov 2017 04:16:45 -0500 Received: from victor.provo.novell.com ([137.65.250.26]:35014 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753764AbdK2JQe (ORCPT ); Wed, 29 Nov 2017 04:16:34 -0500 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); Wed, 29 Nov 2017 02:16:21 -0700 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH 9/9] btrfs-progs: tests/mkfs: Introduce test case to verify if mkfs.btrfs rootdir shrink behaves correctly Date: Wed, 29 Nov 2017 17:16:04 +0800 Message-Id: <20171129091604.2194-10-wqu@suse.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171129091604.2194-1-wqu@suse.com> References: <20171129091604.2194-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 Signed-off-by: Qu Wenruo --- tests/mkfs-tests/012-rootdir-no-shrink/test.sh | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 tests/mkfs-tests/012-rootdir-no-shrink/test.sh diff --git a/tests/mkfs-tests/012-rootdir-no-shrink/test.sh b/tests/mkfs-tests/012-rootdir-no-shrink/test.sh new file mode 100755 index 000000000000..1dfa55b376f6 --- /dev/null +++ b/tests/mkfs-tests/012-rootdir-no-shrink/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Test if mkfs.btrfs --rootdir will skip shrinking correctly + +source "$TOP/tests/common" + +check_prereq mkfs.btrfs + +setup_root_helper + +fs_size=$((512 * 1024 * 1024)) +bs=$((1024 * 1024)) +tmp=$(mktemp -d --tmpdir btrfs-progs-mkfs.rootdirXXXXXXX) + +prepare_test_dev $fs_size + +### no shrink case ### + +run_check "$TOP/mkfs.btrfs" -f -r $tmp "$TEST_DEV" +run_check_mount_test_dev + +# We should be able to write at least half of the fs size data since +# the fs is not shrunk +run_check $SUDO_HELPER dd if=/dev/zero bs=$bs count=$(($fs_size / $bs / 2)) \ + of="$TEST_MNT/file" + +run_check_umount_test_dev + +### shrink case ### +run_check "$TOP/mkfs.btrfs" -f -r $tmp --shrink "$TEST_DEV" +run_check_mount_test_dev + +run_mustfail "mkfs.btrfs for shrink rootdir" \ + $SUDO_HELPER dd if=/dev/zero bs=$bs count=$(($fs_size / $bs / 2)) \ + of="$TEST_MNT/file" + +run_check_umount_test_dev + +rm -rf -- "$tmp"