Thread (10 messages) 10 messages, 3 authors, 2017-06-27

Re: [PATCH blktests 1/2] rc: add helpers to handle PCI test devices

From: Omar Sandoval <osandov@osandov.com>
Date: 2017-06-26 21:31:41

On Fri, Jun 23, 2017 at 04:29:50PM +0200, Johannes Thumshirn wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
 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"
+}
No need to do pdev=$(blah) and then echo $pdev, you can just do

_get_pci_dev_from_blkdev() {
	readlink -f "$TEST_DEV_SYSFS/device" | grep -Eo '[0-9a-f]{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f]'
}

I'll fix that up when I commit it. Looks good otherwise.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help