On 17.01.2014 11:39, Jiri Denemark wrote:
Especially for devices that are not bound to any driver.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
tests/virpcimock.c | 3 +
tests/virpcitest.c | 157 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 159 insertions(+), 1 deletion(-)
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index bf56143..f8ea9c7 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -809,6 +809,9 @@ init_env(void)
MAKE_PCI_DEVICE("0005:90:01.0", 0x1033, 0x0035);
MAKE_PCI_DEVICE("0005:90:01.1", 0x1033, 0x0035);
MAKE_PCI_DEVICE("0005:90:01.2", 0x1033, 0x00e0);
+ MAKE_PCI_DEVICE("0000:0a:01.0", 0x8086, 0x0047);
+ MAKE_PCI_DEVICE("0000:0a:02.0", 0x8286, 0x0048);
+ MAKE_PCI_DEVICE("0000:0a:03.0", 0x8386, 0x0048);
}
diff --git a/tests/virpcitest.c b/tests/virpcitest.c
index e96d7c0..848014d 100644
--- a/tests/virpcitest.c
+++ b/tests/virpcitest.c
@@ -34,6 +34,30 @@
# define VIR_FROM_THIS VIR_FROM_NONE
static int
+testVirPCIDeviceCheckDriver(virPCIDevicePtr dev, const char *expected)
+{
+ char *path = NULL;
+ char *driver = NULL;
+ int ret = -1;
+
+ if (virPCIDeviceGetDriverPathAndName(dev, &path, &driver) < 0)
+ goto cleanup;
+
+ if (STRNEQ_NULLABLE(driver, expected)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "PCI device %s driver mismatch: %s, expecting %s",
+ virPCIDeviceGetName(dev), driver, expected);
NULLSTR()
+ goto cleanup;
+ }
+
+ ret = 0;
+cleanup:
+ VIR_FREE(path);
+ VIR_FREE(driver);
+ return ret;
+}
ACK with that fixed.
Michal