From patchwork Fri May 19 13:55:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 9737321 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 365866041F for ; Fri, 19 May 2017 13:55:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A6E62888B for ; Fri, 19 May 2017 13:55:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F49428927; Fri, 19 May 2017 13:55:44 +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 783E328911 for ; Fri, 19 May 2017 13:55:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752560AbdESNzm (ORCPT ); Fri, 19 May 2017 09:55:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:49581 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751945AbdESNzk (ORCPT ); Fri, 19 May 2017 09:55:40 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 76304AE31; Fri, 19 May 2017 13:55:39 +0000 (UTC) From: Johannes Thumshirn To: Omar Sandoval Cc: Linux Block Layer Mailinglist , Linux SCSI Mailinglist , Johannes Thumshirn Subject: [PATCH blktests v2 2/3] tests/sg: add SCSI generic test grouop Date: Fri, 19 May 2017 15:55:30 +0200 Message-Id: X-Mailer: git-send-email 2.12.0 In-Reply-To: References: In-Reply-To: References: 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 a test group for tests of the SCSI generic driver and and functions common to the SCSI generic driver and it's test cases. Signed-off-by: Johannes Thumshirn --- common/sg | 41 +++++++++++++++++++++++++++++++++++++++++ tests/sg/group | 28 ++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 common/sg create mode 100644 tests/sg/group diff --git a/common/sg b/common/sg new file mode 100644 index 000000000000..123735178d96 --- /dev/null +++ b/common/sg @@ -0,0 +1,41 @@ +#!/bin/bash +# +# SCSI generic helper functions. +# +# Copyright (C) 2017 Johannes Thumshirn +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +_have_scsi_generic() { + _have_module sg +} + +_test_dev_is_scsi() { + + local DEV="$1" + + if [[ -d "/sys/block/$DEV/device/scsi_device" ]]; then + return 0 + else + return 1 + fi +} + +_get_sg_from_blockdev() +{ + local sg_path="/sys/block/$1/device/scsi_generic/" + local sg_dev=$(ls $sg_path | grep -E 'sg[0-9]+') + + echo "$sg_dev" +} diff --git a/tests/sg/group b/tests/sg/group new file mode 100644 index 000000000000..3121d799fe25 --- /dev/null +++ b/tests/sg/group @@ -0,0 +1,28 @@ +#!/bin/bash +# +# Regression tests for SCSI generic device +# +# Copyright (C) 2017 Johannes Thumshirn +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. common/sg + +group_requires() { + _have_scsi_generic +} + +group_device_requires() { + _test_dev_is_scsi +}