From patchwork Thu Jul 14 15:57:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Tulak X-Patchwork-Id: 9230055 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 D418860572 for ; Thu, 14 Jul 2016 15:57:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C579827F94 for ; Thu, 14 Jul 2016 15:57:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7F7128285; Thu, 14 Jul 2016 15:57:12 +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 51FEF27F94 for ; Thu, 14 Jul 2016 15:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751295AbcGNP5L (ORCPT ); Thu, 14 Jul 2016 11:57:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36348 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751149AbcGNP5L (ORCPT ); Thu, 14 Jul 2016 11:57:11 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AAA92D4D76 for ; Thu, 14 Jul 2016 15:57:10 +0000 (UTC) Received: from jtulak.brq.redhat.com (jtulak.brq.redhat.com [10.34.26.85]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6EFv9RX010705; Thu, 14 Jul 2016 11:57:09 -0400 From: Jan Tulak To: fstests@vger.kernel.org Cc: eguan@redhat.com, Jan Tulak Subject: [PATCH v2] xfstests: add _require_xfs_mkfs_validation to common/rc Date: Thu, 14 Jul 2016 17:57:03 +0200 Message-Id: <1468511823-16184-1-git-send-email-jtulak@redhat.com> In-Reply-To: <1468500214-6237-5-git-send-email-jtulak@redhat.com> References: <1468500214-6237-5-git-send-email-jtulak@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 14 Jul 2016 15:57:10 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a simple way to skip a test if it is (or is not) run on mkfs correctly validating inputs. Signed-off-by: Jan Tulak --- UPDATE: * Use tmp file instead of scratch - we are using -N flag, so it doesn't really matter. * Make both _requires to use the same function for testing, so if it is ever changed, the change will be reflected in both. --- common/rc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/common/rc b/common/rc index 0c68e4f..c66d31d 100644 --- a/common/rc +++ b/common/rc @@ -3843,6 +3843,39 @@ _get_fs_sysfs_attr() cat /sys/fs/${FSTYP}/${dname}/${attr} } +# Skip if we are running an older binary without the stricter input checks. +# Make multiple checks to be sure that there is no regression on the one +# selected feature check, which would skew the result. +# +# At first, make a common function that runs the tests and returns +# number of failed cases. +mkfs_validation_check() +{ + local cmd="$MKFS_XFS_PROG -f -N -d file,name=/tmp/foo,size=$((1024 * 1024 * 1024))" + $cmd -s size=2s >/dev/null 2>&1 + local sum=$? + $cmd -l version=2,su=$((256 * 1024 + 4096)) >/dev/null 2>&1 + sum=`expr $sum + $?` + return $sum +} +# Skip the test if all calls passed - mkfs accepts invalid input +_require_xfs_mkfs_validation() +{ + mkfs_validation_check + if [ "$?" -eq 0 ]; then + _notrun "Requires newer mkfs with stricter input checks: the oldest supported version of xfsprogs is 4.7." + fi +} + +# The oposite of _require_xfs_mkfs_validation. +_require_xfs_mkfs_without_validation() +{ + mkfs_validation_check + if [ "$?" -ne 0 ]; then + _notrun "Requires older mkfs without strict input checks: the last supported version of xfsprogs is 4.5." + fi +} + init_rc ################################################################################