From patchwork Fri Jun 23 14:29:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 9806715 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 811DD60349 for ; Fri, 23 Jun 2017 14:30:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7126228778 for ; Fri, 23 Jun 2017 14:30:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65E0F28780; Fri, 23 Jun 2017 14:30:08 +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 7B59428791 for ; Fri, 23 Jun 2017 14:30:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751999AbdFWOaH (ORCPT ); Fri, 23 Jun 2017 10:30:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:38757 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751488AbdFWOaG (ORCPT ); Fri, 23 Jun 2017 10:30:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4DF50AAB6; Fri, 23 Jun 2017 14:30:05 +0000 (UTC) From: Johannes Thumshirn To: Omar Sandoval Cc: Linux Block Layer Mailinglist , Johannes Thumshirn Subject: [PATCH blktests 1/2] rc: add helpers to handle PCI test devices Date: Fri, 23 Jun 2017 16:29:50 +0200 Message-Id: <20170623142951.17189-1-jthumshirn@suse.de> X-Mailer: git-send-email 2.12.3 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add two helpers to check whether a device is attached via PCI and to get the PCI device from a TEST_DEV Signed-off-by: Johannes Thumshirn --- common/rc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/rc b/common/rc index b01f936b878b..497cf81ec475 100644 --- a/common/rc +++ b/common/rc @@ -120,3 +120,18 @@ _test_dev_queue_set() { fi echo "$2" >"${TEST_DEV_SYSFS}/queue/$1" } + +_test_dev_is_pci() { + if ! readlink -f "$TEST_DEV_SYSFS/device" | grep -q pci; then + SKIP_REASON="$TEST_DEV is not a PCI device" + return 1 + fi + return 0 +} + +_get_pci_dev_from_blkdev() { + pdev="$(readlink -f "$TEST_DEV_SYSFS/device" | \ + grep -Eo '[0-9a-f]{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f]')" + + echo "$pdev" +}