From patchwork Mon Jan 6 09:13:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 3436841 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E530F9F163 for ; Mon, 6 Jan 2014 09:12:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD10A2012D for ; Mon, 6 Jan 2014 09:12:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC0CA200E8 for ; Mon, 6 Jan 2014 09:12:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753026AbaAFJMd (ORCPT ); Mon, 6 Jan 2014 04:12:33 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:15294 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752588AbaAFJMa (ORCPT ); Mon, 6 Jan 2014 04:12:30 -0500 X-IronPort-AV: E=Sophos;i="4.95,611,1384272000"; d="scan'208";a="9378291" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 06 Jan 2014 17:08:51 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s069CPl2030052; Mon, 6 Jan 2014 17:12:27 +0800 Received: from adam-work.lan ([10.167.226.24]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2014010617112706-846327 ; Mon, 6 Jan 2014 17:11:27 +0800 From: Qu Wenruo To: xfs@oss.sgi.com, linux-btrfs@vger.kernel.org Cc: Miao Xie Subject: [PATCH] xfstests: Enhance the scratch dev pool and deletable device check Date: Mon, 6 Jan 2014 17:13:18 +0800 Message-Id: <1388999598-17058-1-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 1.8.5.2 X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/01/06 17:11:27, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/01/06 17:11:29, Serialize complete at 2014/01/06 17:11:29 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Miao Xie From: Miao Xie _require_scratch_dev_pool() checks the devices number in SCRATCH_DEV_POOL, but it's not enough since some btrfs RAID10 tests needs 4 devices, but when 3 or less devices are provided, the check is useless and related test case will fail(btrfs/003 btrfs/011 btrfs/023). Also _require_deletable_scratch_dev_pool only checks whether it is virtul, like virtio(not including virtio-scsi) disk will pass the check but is unable to delete. This patch enhance _require_scratch_dev_pool by add optional $1 as needed device number to do extra check. And enhance _require_deletable_scratch_dev_pool by directly check /sys/class/block/$DEV/device/delete file. Signed-off-by: Miao Xie Signed-off-by: Qu Wenruo --- common/rc | 22 ++++++++++++++-------- tests/btrfs/003 | 2 +- tests/btrfs/011 | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/common/rc b/common/rc index a2005c9..09644af 100644 --- a/common/rc +++ b/common/rc @@ -1927,16 +1927,24 @@ _test_inode_extsz() _require_scratch_dev_pool() { local i + local ndevs + if [ -z "$SCRATCH_DEV_POOL" ]; then _notrun "this test requires a valid \$SCRATCH_DEV_POOL" fi - # btrfs test case needs 2 or more scratch_dev_pool; other FS not sure + if [ -z "$1" ]; then + ndevs=2 + else + ndevs=$1 + fi + + # btrfs test case needs ndevs or more scratch_dev_pool; other FS not sure # so fail it case $FSTYP in btrfs) - if [ "`echo $SCRATCH_DEV_POOL|wc -w`" -lt 2 ]; then - _notrun "btrfs and this test needs 2 or more disks in SCRATCH_DEV_POOL" + if [ "`echo $SCRATCH_DEV_POOL|wc -w`" -lt $ndevs ]; then + _notrun "btrfs and this test needs $ndevs or more disks in SCRATCH_DEV_POOL" fi ;; *) @@ -1963,17 +1971,15 @@ _require_scratch_dev_pool() done } -# We will check if the device is virtual (eg: loop device) since it does not -# have the delete entry-point. Otherwise SCSI and USB devices are fine. +# We will check if the device is deletable _require_deletable_scratch_dev_pool() { local i local x for i in $SCRATCH_DEV_POOL; do x=`echo $i | cut -d"/" -f 3` - ls -l /sys/class/block/${x} | grep -q "virtual" - if [ $? == "0" ]; then - _notrun "$i is a virtual device which is not deletable" + if [ ! -f /sys/class/block/${x}/device/delete ]; then + _notrun "$i is a device which is not deletable" fi done } diff --git a/tests/btrfs/003 b/tests/btrfs/003 index 9105d06..29f947b 100755 --- a/tests/btrfs/003 +++ b/tests/btrfs/003 @@ -49,7 +49,7 @@ _need_to_be_root _supported_fs btrfs _supported_os Linux _require_scratch -_require_scratch_dev_pool +_require_scratch_dev_pool 4 _require_deletable_scratch_dev_pool _require_command $WIPEFS_PROG diff --git a/tests/btrfs/011 b/tests/btrfs/011 index 71ff3de..faa0402 100755 --- a/tests/btrfs/011 +++ b/tests/btrfs/011 @@ -62,7 +62,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _need_to_be_root _supported_fs btrfs _require_scratch -_require_scratch_dev_pool +_require_scratch_dev_pool 4 _require_command $BTRFS_SHOW_SUPER_PROG btrfs-show-super rm -f $seqres.full