X-Git-Url: https://repo.jachan.dev/qemu.git/blobdiff_plain/09125c5e76923aa22a72f43cb34b6e74ae7fe17f..9b21a36cd333f3f9a1acb379f5f4f4928ad84a06:/tests/eepro100-test.c diff --git a/tests/eepro100-test.c b/tests/eepro100-test.c index e17eed0b7a..90b5c1afd9 100644 --- a/tests/eepro100-test.c +++ b/tests/eepro100-test.c @@ -8,25 +8,16 @@ */ #include "qemu/osdep.h" -#include #include "libqtest.h" +#include "libqos/qgraph.h" +#include "libqos/pci.h" -static void test_device(gconstpointer data) -{ - const char *model = data; - QTestState *s; - char *args; - - args = g_strdup_printf("-device %s", model); - s = qtest_start(args); - - /* Tests only initialization so far. TODO: Implement functional tests */ +typedef struct QEEPRO100 QEEPRO100; - if (s) { - qtest_quit(s); - } - g_free(args); -} +struct QEEPRO100 { + QOSGraphObject obj; + QPCIDevice dev; +}; static const char *models[] = { "i82550", @@ -44,18 +35,42 @@ static const char *models[] = { "i82801", }; -int main(int argc, char **argv) +static void *eepro100_get_driver(void *obj, const char *interface) { - int i; + QEEPRO100 *eepro100 = obj; - g_test_init(&argc, &argv, NULL); + if (!g_strcmp0(interface, "pci-device")) { + return &eepro100->dev; + } - for (i = 0; i < ARRAY_SIZE(models); i++) { - char *path; + fprintf(stderr, "%s not present in eepro100\n", interface); + g_assert_not_reached(); +} - path = g_strdup_printf("eepro100/%s", models[i]); - qtest_add_data_func(path, models[i], test_device); - } +static void *eepro100_create(void *pci_bus, QGuestAllocator *alloc, void *addr) +{ + QEEPRO100 *eepro100 = g_new0(QEEPRO100, 1); + QPCIBus *bus = pci_bus; + + qpci_device_init(&eepro100->dev, bus, addr); + eepro100->obj.get_driver = eepro100_get_driver; + + return &eepro100->obj; +} + +static void eepro100_register_nodes(void) +{ + int i; + QOSGraphEdgeOptions opts = { + .extra_device_opts = "addr=04.0", + }; - return g_test_run(); + add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) }); + for (i = 0; i < ARRAY_SIZE(models); i++) { + qos_node_create_driver(models[i], eepro100_create); + qos_node_consumes(models[i], "pci-bus", &opts); + qos_node_produces(models[i], "pci-device"); + } } + +libqos_init(eepro100_register_nodes);