diff options
author | Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> | 2018-08-17 15:47:17 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-03-07 17:28:46 +0100 |
commit | fb7e0b48bde03a3bf07c9682bebdf57f3e448e2a (patch) | |
tree | d110c9015c220ac77de30b79dd2d13e1aa0eb1c0 /tests/usb-hcd-ohci-test.c | |
parent | dca063065a5687cbcc2118f5d5bce8f7654cae54 (diff) |
qos-test: usb-hcd-ohci test node
Convert tests/usb-hcd-ohci-test to a driver node; currently it runs
the PCI nop test only, therefore we're not placing it in tests/libqos.
Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/usb-hcd-ohci-test.c')
-rw-r--r-- | tests/usb-hcd-ohci-test.c | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/tests/usb-hcd-ohci-test.c b/tests/usb-hcd-ohci-test.c index 48ddbfd26d..98af02e898 100644 --- a/tests/usb-hcd-ohci-test.c +++ b/tests/usb-hcd-ohci-test.c @@ -10,30 +10,58 @@ #include "qemu/osdep.h" #include "libqtest.h" #include "libqos/usb.h" +#include "libqos/qgraph.h" +#include "libqos/pci.h" +typedef struct QOHCI_PCI QOHCI_PCI; -static void test_ohci_init(void) -{ +struct QOHCI_PCI { + QOSGraphObject obj; + QPCIDevice dev; +}; +static void test_ohci_hotplug(void *obj, void *data, QGuestAllocator *alloc) +{ + usb_test_hotplug("ohci", "1", NULL); } -static void test_ohci_hotplug(void) +static void *ohci_pci_get_driver(void *obj, const char *interface) { - usb_test_hotplug("ohci", "1", NULL); + QOHCI_PCI *ohci_pci = obj; + + if (!g_strcmp0(interface, "pci-device")) { + return &ohci_pci->dev; + } + + fprintf(stderr, "%s not present in pci-ohci\n", interface); + g_assert_not_reached(); } -int main(int argc, char **argv) +static void *ohci_pci_create(void *pci_bus, QGuestAllocator *alloc, void *addr) { - int ret; + QOHCI_PCI *ohci_pci = g_new0(QOHCI_PCI, 1); + ohci_pci->obj.get_driver = ohci_pci_get_driver; - g_test_init(&argc, &argv, NULL); + return &ohci_pci->obj; +} + +static void ohci_pci_register_nodes(void) +{ + QOSGraphEdgeOptions opts = { + .extra_device_opts = "addr=04.0,id=ohci", + }; + add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) }); - qtest_add_func("/ohci/pci/init", test_ohci_init); - qtest_add_func("/ohci/pci/hotplug", test_ohci_hotplug); + qos_node_create_driver("pci-ohci", ohci_pci_create); + qos_node_consumes("pci-ohci", "pci-bus", &opts); + qos_node_produces("pci-ohci", "pci-device"); +} - qtest_start("-device pci-ohci,id=ohci"); - ret = g_test_run(); - qtest_end(); +libqos_init(ohci_pci_register_nodes); - return ret; +static void register_ohci_pci_test(void) +{ + qos_add_test("ohci_pci-test-hotplug", "pci-ohci", test_ohci_hotplug, NULL); } + +libqos_init(register_ohci_pci_test); |