From patchwork Thu Feb 18 06:24:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 8346411 Return-Path: X-Original-To: patchwork-linux-btrfs@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 B5CF1C0553 for ; Thu, 18 Feb 2016 06:27:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DA9E020383 for ; Thu, 18 Feb 2016 06:27:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02C2120382 for ; Thu, 18 Feb 2016 06:27:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1425080AbcBRG0h (ORCPT ); Thu, 18 Feb 2016 01:26:37 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:27412 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1424009AbcBRG0h (ORCPT ); Thu, 18 Feb 2016 01:26:37 -0500 X-IronPort-AV: E=Sophos;i="5.20,367,1444665600"; d="scan'208";a="327813" Received: from unknown (HELO cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 18 Feb 2016 14:26:31 +0800 Received: from localhost.localdomain (unknown [10.167.226.34]) by cn.fujitsu.com (Postfix) with ESMTP id F0DEC4056403 for ; Thu, 18 Feb 2016 14:26:28 +0800 (CST) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [RFC PATCH v2 1/5] fstests: Add support to check btrfs sysfs features Date: Thu, 18 Feb 2016 14:24:24 +0800 Message-Id: <1455776668-12306-2-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1455776668-12306-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1455776668-12306-1-git-send-email-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: F0DEC4056403.AFED8 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@cn.fujitsu.com X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Btrfs has its sysfs interface showing what features current kernel/btrfs module support. Add _require_btrfs_kernel_feature() to check such interface. Also rename _require_btrfs() to _require_btrfs_subcommand() to avoid confusion. Signed-off-by: Qu Wenruo --- common/rc | 12 +++++++++++- tests/btrfs/004 | 2 +- tests/btrfs/048 | 2 +- tests/btrfs/059 | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/common/rc b/common/rc index 52c4a36..971473b 100644 --- a/common/rc +++ b/common/rc @@ -2680,7 +2680,7 @@ _require_deletable_scratch_dev_pool() } # We check for btrfs and (optionally) features of the btrfs command -_require_btrfs() +_require_btrfs_subcommand() { cmd=$1 _require_command "$BTRFS_UTIL_PROG" btrfs @@ -2691,6 +2691,16 @@ _require_btrfs() [ $? -eq 0 ] || _notrun "$BTRFS_UTIL_PROG too old (must support $cmd)" } +# We check if the kernel support given btrfs feature from its sysfs interface +_require_btrfs_kernel_feature() +{ + feat=$1 + # Use /dev/btrfs-control to ensure btrfs is loaded + touch /dev/btrfs-control + [[ ! -f /sys/fs/btrfs/features/$feat ]] && \ + _notrun "kernel does not support $feat feature" +} + # Check that fio is present, and it is able to execute given jobfile _require_fio() { diff --git a/tests/btrfs/004 b/tests/btrfs/004 index d588c5b..b5686ec 100755 --- a/tests/btrfs/004 +++ b/tests/btrfs/004 @@ -52,7 +52,7 @@ _supported_fs btrfs _supported_os Linux _require_scratch _require_no_large_scratch_dev -_require_btrfs inspect-internal +_require_btrfs_subcommand inspect-internal _require_command "/usr/sbin/filefrag" filefrag rm -f $seqres.full diff --git a/tests/btrfs/048 b/tests/btrfs/048 index dc7386d..9ddd23f 100755 --- a/tests/btrfs/048 +++ b/tests/btrfs/048 @@ -47,7 +47,7 @@ _supported_fs btrfs _supported_os Linux _require_test _require_scratch -_require_btrfs "property" +_require_btrfs_subcommand "property" _need_to_be_root send_files_dir=$TEST_DIR/btrfs-test-$seq diff --git a/tests/btrfs/059 b/tests/btrfs/059 index 3379ead..21d246c 100755 --- a/tests/btrfs/059 +++ b/tests/btrfs/059 @@ -50,7 +50,7 @@ _supported_fs btrfs _supported_os Linux _require_test _require_scratch -_require_btrfs "property" +_require_btrfs_subcommand "property" _need_to_be_root rm -f $seqres.full