From patchwork Tue Nov 29 07:32:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9451127 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 AFC4260756 for ; Tue, 29 Nov 2016 07:33:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A691927F7F for ; Tue, 29 Nov 2016 07:33:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B83927FA6; Tue, 29 Nov 2016 07:33:58 +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 579EA27F7F for ; Tue, 29 Nov 2016 07:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756119AbcK2Hdo (ORCPT ); Tue, 29 Nov 2016 02:33:44 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:39314 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1755120AbcK2Hdc (ORCPT ); Tue, 29 Nov 2016 02:33:32 -0500 X-IronPort-AV: E=Sophos;i="5.20,367,1444665600"; d="scan'208";a="989653" Received: from unknown (HELO cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 29 Nov 2016 15:33:18 +0800 Received: from localhost.localdomain (unknown [10.167.226.34]) by cn.fujitsu.com (Postfix) with ESMTP id 596B1434903F; Tue, 29 Nov 2016 15:33:14 +0800 (CST) From: Qu Wenruo To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 01/10] fstests: common: Introduce function to check qgroup correctness Date: Tue, 29 Nov 2016 15:32:54 +0800 Message-Id: <20161129073303.14776-2-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161129073303.14776-1-quwenruo@cn.fujitsu.com> References: <20161129073303.14776-1-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 596B1434903F.AC272 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@cn.fujitsu.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 Old btrfs qgroup test cases uses fix golden output numbers, which limits the coverage since they can't handle mount options like compress or inode_map, and cause false alert. Introduce _btrfs_check_scratch_qgroup() function to check qgroup correctness using "btrfs check --qgroup-report" function, which will follow the way kernel handle qgroup and are proved very reliable. Signed-off-by: Qu Wenruo --- common/rc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/common/rc b/common/rc index 8c99306..35d2d56 100644 --- a/common/rc +++ b/common/rc @@ -3018,6 +3018,25 @@ _require_deletable_scratch_dev_pool() done } +# We check if "btrfs check" support to check qgroup correctness +# Old fixed golden output can cover case like compress and inode_map +# mount options, which limits the coverage +_require_btrfs_check_qgroup() +{ + _require_command "$BTRFS_UTIL_PROG" btrfs + output=$($BTRFS_UTIL_PROG check --help | grep "qgroup-report") + if [ -z "$output" ]; then + _notrun "$BTRFS_UTIL_PROG too old (must support 'check --qgroup-report')" + fi +} + +_btrfs_check_scratch_qgroup() +{ + _require_btrfs_check_qgroup + $BTRFS_UTIL_PROG check --qgroup-report $SCRATCH_DEV 2>&1 |\ + grep -E "Counts for qgroup.*are different" +} + # We check for btrfs and (optionally) features of the btrfs command _require_btrfs() {