From patchwork Thu Jan 22 16:29:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 5686661 Return-Path: X-Original-To: patchwork-fstests@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 5A465C058D for ; Thu, 22 Jan 2015 16:29:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E3668201D3 for ; Thu, 22 Jan 2015 16:29:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E7F4E200E5 for ; Thu, 22 Jan 2015 16:29:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752363AbbAVQ3F (ORCPT ); Thu, 22 Jan 2015 11:29:05 -0500 Received: from cantor2.suse.de ([195.135.220.15]:51661 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752224AbbAVQ3D (ORCPT ); Thu, 22 Jan 2015 11:29:03 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 92549AD37 for ; Thu, 22 Jan 2015 16:29:02 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 4FA3CDA81D; Thu, 22 Jan 2015 17:29:02 +0100 (CET) From: David Sterba To: fstests@vger.kernel.org Cc: David Sterba Subject: [PATCH] common: helper to find out options to print raw byte output from qgroup show Date: Thu, 22 Jan 2015 17:29:01 +0100 Message-Id: <1421944141-4442-1-git-send-email-dsterba@suse.cz> X-Mailer: git-send-email 2.1.3 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Newer versions of btrfs-progs change the default output of 'qgroup show', we have to check what version is running and use the right option if needed. Signed-off-by: David Sterba --- common/rc | 7 +++++++ tests/btrfs/017 | 3 ++- tests/btrfs/022 | 12 +++++++----- tests/btrfs/057 | 3 ++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/common/rc b/common/rc index 5377ba08d216..f6a603de5cbf 100644 --- a/common/rc +++ b/common/rc @@ -2799,6 +2799,13 @@ _btrfs_stress_replace() done } +# find the right option to force output in bytes, older versions of btrfs-progs +# print that by default, newer print human readable numbers with unit suffix +_btrfs_qgroup_units() +{ + $BTRFS_UTIL_PROG qgroup show --help 2>&1 | grep -q -- --raw && echo "--raw" +} + # return device size in kb _get_device_size() { diff --git a/tests/btrfs/017 b/tests/btrfs/017 index d00d7c85159b..f8855e3d893a 100755 --- a/tests/btrfs/017 +++ b/tests/btrfs/017 @@ -79,7 +79,8 @@ rm -fr $SCRATCH_MNT/snap/foo* sync -$BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | $AWK_PROG '/[0-9]/ {print $2" "$3}' +units=`_btrfs_qgroup_units` +$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $AWK_PROG '/[0-9]/ {print $2" "$3}' # success, all done status=0 diff --git a/tests/btrfs/022 b/tests/btrfs/022 index 16e1eadc1f6f..5c1a82d79757 100755 --- a/tests/btrfs/022 +++ b/tests/btrfs/022 @@ -52,7 +52,7 @@ _basic_test() _run_btrfs_util_prog subvolume create $SCRATCH_MNT/a _run_btrfs_util_prog quota enable $SCRATCH_MNT/a subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a) - $BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid >> \ + $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid >> \ $seqres.full 2>&1 [ $? -eq 0 ] || _fail "couldn't find our subvols quota group" run_check $FSSTRESS_PROG -d $SCRATCH_MNT/a -w -p 1 -n 2000 \ @@ -62,10 +62,10 @@ _basic_test() # the shared values of both the original subvol and snapshot should # match - a_shared=$($BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid) + a_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid) a_shared=$(echo $a_shared | awk '{ print $2 }') subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT b) - b_shared=$($BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid) + b_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid) b_shared=$(echo $b_shared | awk '{ print $2 }') [ $b_shared -eq $a_shared ] || _fail "shared values don't match" } @@ -81,12 +81,12 @@ _rescan_test() run_check $FSSTRESS_PROG -d $SCRATCH_MNT/a -w -p 1 -n 2000 \ $FSSTRESS_AVOID sync - output=$($BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid) + output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid) echo $output >> $seqres.full refer=$(echo $output | awk '{ print $2 }') excl=$(echo $output | awk '{ print $3 }') _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT - output=$($BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | grep $subvolid) + output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid) echo $output >> $seqres.full [ $refer -eq $(echo $output | awk '{ print $2 }') ] || \ _fail "reference values don't match after rescan" @@ -118,6 +118,8 @@ _limit_test_noexceed() [ $? -eq 0 ] || _fail "should have been allowed to write" } +units=`_btrfs_qgroup_units` + _scratch_mkfs > /dev/null 2>&1 _scratch_mount _basic_test diff --git a/tests/btrfs/057 b/tests/btrfs/057 index f6f4e0e8949f..605bd020b09e 100755 --- a/tests/btrfs/057 +++ b/tests/btrfs/057 @@ -74,7 +74,8 @@ _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT rm -rf $SCRATCH_MNT/* >& /dev/null _run_btrfs_util_prog filesystem sync $SCRATCH_MNT -$BTRFS_UTIL_PROG qgroup show $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' \ +units=`_btrfs_qgroup_units` +$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' \ | $AWK_PROG '{print $2" "$3}' status=0