From: Hannes Reinecke <hare@suse.de>
To: Omar Sandoval <osandov@fb.com>
Cc: linux-scsi@vger.kernel.org, Johannes Thumshirn <jth@kernel.org>,
Hannes Reinecke <hare@suse.de>, Hannes Reinecke <hare@suse.com>
Subject: [PATCH 2/2] tests/scsi/0001: Regression test for SCSI device blacklisting
Date: Wed, 9 Aug 2017 12:50:06 +0200 [thread overview]
Message-ID: <1502275806-27972-2-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1502275806-27972-1-git-send-email-hare@suse.de>
SCSI device blacklisting seems to be a tricky subject, with
lots of potential for messing up the selection algorithm.
This adds a test for catching regressions here.
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
tests/scsi/001 | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/scsi/001.out | 10 ++++++++
2 files changed, 79 insertions(+)
create mode 100644 tests/scsi/001
create mode 100644 tests/scsi/001.out
diff --git a/tests/scsi/001 b/tests/scsi/001
new file mode 100644
index 0000000..374a458
--- /dev/null
+++ b/tests/scsi/001
@@ -0,0 +1,69 @@
+#!/bin/bash
+#
+# Regression test for scsi device blacklisting
+#
+# Copyright (C) 2017 Hannes Reinecke, SUSE Linux GmbH
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+DESCRIPTION="SCSI device blacklisting"
+
+QUICK=1
+
+CHECK_DMESG=0
+
+requires() {
+ if modinfo scsi_debug | grep -q inq_vendor ; then
+ return 0
+ fi
+ return 1
+}
+
+test() {
+ local inq vendor model host dev blacklist
+
+ echo "Running ${TEST_NAME}"
+
+ for inq in \
+ " " \
+ "AAAAAAAABBBBBBBBBBBBBBBB" \
+ "HITACHI OPEN-V " \
+ " Scanner " \
+ "Inateck " \
+ "Promise STEX " \
+ "HITA OPEN-V " \
+ "ABCD Scanner " ; do
+ vendor=${inq:0:8}
+ model=${inq:8:16}
+ modprobe scsi_debug inq_vendor="$vendor" inq_product="$model"
+ host=$(lsscsi -H | sed -n 's/.\([0-9]*\).*scsi_debug/\1/p')
+ if [ -z "$host" ] ; then
+ echo "Test failed, scsi_debug could not be loaded"
+ return 1
+ fi
+ dev=$(lsscsi | grep $host | sed -n 's/.*\/dev\/\(sd[a-z]*\).*/\1/p')
+ if [ -z "$dev" ] ; then
+ echo "Test failed, SCSI device not found"
+ rmmod scsi_debug
+ return 1
+ fi
+ vendor=$(cat /sys/block/$dev/device/vendor)
+ model=$(cat /sys/block/$dev/device/model)
+ blacklist=$(cat /sys/block/$dev/device/blacklist)
+ echo "$vendor $model $blacklist"
+ rmmod scsi_debug
+ done
+ echo "Test complete"
+ return 0
+}
diff --git a/tests/scsi/001.out b/tests/scsi/001.out
new file mode 100644
index 0000000..64db97c
--- /dev/null
+++ b/tests/scsi/001.out
@@ -0,0 +1,10 @@
+Running scsi/001
+ 0x0
+AAAAAAAA BBBBBBBBBBBBBBBB 0x0
+HITACHI OPEN-V 0x20000
+ Scanner 0x1
+Inateck 0x0
+Promise STEX 0x40
+HITA OPEN-V 0x0
+ABCD Scanner 0x0
+Test complete
--
1.8.5.6
next prev parent reply other threads:[~2017-08-09 10:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-09 10:50 [PATCH 1/2] tests/scsi: add SCSI midlayer test group Hannes Reinecke
2017-08-09 10:50 ` Hannes Reinecke [this message]
2017-08-15 23:13 ` [PATCH 2/2] tests/scsi/0001: Regression test for SCSI device blacklisting Bart Van Assche
2017-08-16 6:00 ` Omar Sandoval
2017-12-13 9:29 ` Omar Sandoval
2017-08-16 1:14 ` [PATCH 1/2] tests/scsi: add SCSI midlayer test group Omar Sandoval
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1502275806-27972-2-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=hare@suse.com \
--cc=jth@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=osandov@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.