Convert tests/tpci200-test in qgraph test node, tpci200-test. Since it's a nop test, node creation and initialization is made in the same file.
Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuse...@gmail.com> --- tests/Makefile.include | 2 +- tests/tpci200-test.c | 60 +++++++++++++++++++++++++++++++++++------- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index 3e5964263e..1daee93de5 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -792,6 +792,7 @@ libqgraph-tests-obj-y += tests/virtio-blk-test.o libqgraph-tests-obj-y += tests/virtio-net-test.o libqgraph-tests-obj-y += tests/virtio-scsi-test.o libqgraph-tests-obj-y += tests/ac97-test.o +libqgraph-tests-obj-y += tests/tpci200-test.o check-unit-y += tests/test-qgraph$(EXESUF) tests/test-qgraph$(EXESUF): tests/test-qgraph.o $(libqgraph-obj-y) @@ -835,7 +836,6 @@ tests/ne2000-test$(EXESUF): tests/ne2000-test.o tests/wdt_ib700-test$(EXESUF): tests/wdt_ib700-test.o tests/tco-test$(EXESUF): tests/tco-test.o $(libqos-pc-obj-y) tests/virtio-ccw-test$(EXESUF): tests/virtio-ccw-test.o -tests/tpci200-test$(EXESUF): tests/tpci200-test.o tests/display-vga-test$(EXESUF): tests/display-vga-test.o tests/ipoctal232-test$(EXESUF): tests/ipoctal232-test.o tests/qom-test$(EXESUF): tests/qom-test.o diff --git a/tests/tpci200-test.c b/tests/tpci200-test.c index 0321ec27ec..a0e1785e50 100644 --- a/tests/tpci200-test.c +++ b/tests/tpci200-test.c @@ -9,23 +9,65 @@ #include "qemu/osdep.h" #include "libqtest.h" +#include "libqos/qgraph.h" + +typedef struct QTpci200 QTpci200; +typedef struct QIpack QIpack; + +struct QIpack { + +}; +struct QTpci200 { + QOSGraphObject obj; + QIpack ipack; +}; /* Tests only initialization so far. TODO: Replace with functional tests */ -static void nop(void) +static void nop(void *obj, void *data, QGuestAllocator *alloc) { } -int main(int argc, char **argv) +/* tpci200 */ +static void *tpci200_get_driver(void *obj, const char *interface) { - int ret; + QTpci200 *tpci200 = obj; + if (!g_strcmp0(interface, "ipack")) { + return &tpci200->ipack; + } - g_test_init(&argc, &argv, NULL); - qtest_add_func("/tpci200/nop", nop); + fprintf(stderr, "%s not present in tpci200\n", interface); + g_assert_not_reached(); +} - qtest_start("-device tpci200"); - ret = g_test_run(); +static void tpci200_destructor(QOSGraphObject *obj) +{ + QTpci200 *tpci200 = (QTpci200 *) obj; + g_free(tpci200); +} - qtest_end(); +static void *tpci200_create(void *pci_bus, QGuestAllocator *alloc, void *addr) +{ + QTpci200 *tpci200 = g_new0(QTpci200, 1); + tpci200->obj.destructor = tpci200_destructor; + tpci200->obj.get_driver = tpci200_get_driver; - return ret; + return &tpci200->obj; } + +static void tpci200_register_nodes(void) +{ + qos_node_create_driver("tpci200", tpci200_create); + qos_node_consumes("tpci200", "pci-bus", &(QOSGraphEdgeOptions) { + .extra_device_opts = "id=ipack0", + }); + qos_node_produces("tpci200", "ipack"); +} + +libqos_init(tpci200_register_nodes); + +static void register_tpci200_test(void) +{ + qos_add_test("tpci200-test", "tpci200", nop, NULL); +} + +libqos_init(register_tpci200_test); -- 2.17.1