]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
rc: add helpers to handle PCI test devices
authorJohannes Thumshirn <jthumshirn@suse.de>
Tue, 27 Jun 2017 13:42:56 +0000 (15:42 +0200)
committerOmar Sandoval <osandov@fb.com>
Tue, 27 Jun 2017 16:52:34 +0000 (09:52 -0700)
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 <jthumshirn@suse.de>
common/rc

index 088422ce909b8e40eec2c4d2e991c6b754dcf5eb..28116b0fc30897f2f386f6610f6fbed178b08dae 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -127,3 +127,16 @@ _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() {
+       readlink -f "$TEST_DEV_SYSFS/device" | \
+               grep -Eo '[0-9a-f]{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f]'
+}