]> git.proxmox.com Git - mirror_qemu.git/blobdiff - tests/e1000-test.c
i386: Remove unused host_cpudef variable
[mirror_qemu.git] / tests / e1000-test.c
index a8ba2fc0a84ab9f2e5e38e598050431bdbab65dc..c387984ef6d69dbf0361b83f19e96f00e5896775 100644 (file)
@@ -7,27 +7,62 @@
  * See the COPYING file in the top-level directory.
  */
 
-#include <glib.h>
-#include <string.h>
-#include "libqtest.h"
 #include "qemu/osdep.h"
+#include "libqtest.h"
+#include "qemu/module.h"
+#include "libqos/qgraph.h"
+#include "libqos/pci.h"
+
+typedef struct QE1000 QE1000;
+
+struct QE1000 {
+    QOSGraphObject obj;
+    QPCIDevice dev;
+};
+
+static const char *models[] = {
+    "e1000",
+    "e1000-82540em",
+    "e1000-82544gc",
+    "e1000-82545em",
+};
 
-/* Tests only initialization so far. TODO: Replace with functional tests */
-static void nop(void)
+static void *e1000_get_driver(void *obj, const char *interface)
 {
+    QE1000 *e1000 = obj;
+
+    if (!g_strcmp0(interface, "pci-device")) {
+        return &e1000->dev;
+    }
+
+    fprintf(stderr, "%s not present in e1000e\n", interface);
+    g_assert_not_reached();
 }
 
-int main(int argc, char **argv)
+static void *e1000_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
 {
-    int ret;
+    QE1000 *e1000 = g_new0(QE1000, 1);
+    QPCIBus *bus = pci_bus;
 
-    g_test_init(&argc, &argv, NULL);
-    qtest_add_func("/e1000/nop", nop);
+    qpci_device_init(&e1000->dev, bus, addr);
+    e1000->obj.get_driver = e1000_get_driver;
 
-    qtest_start("-device e1000");
-    ret = g_test_run();
+    return &e1000->obj;
+}
 
-    qtest_end();
+static void e1000_register_nodes(void)
+{
+    int i;
+    QOSGraphEdgeOptions opts = {
+        .extra_device_opts = "addr=04.0",
+    };
+    add_qpci_address(&opts, &(QPCIAddress) { .devfn = QPCI_DEVFN(4, 0) });
 
-    return ret;
+    for (i = 0; i < ARRAY_SIZE(models); i++) {
+        qos_node_create_driver(models[i], e1000_create);
+        qos_node_consumes(models[i], "pci-bus", &opts);
+        qos_node_produces(models[i], "pci-device");
+    }
 }
+
+libqos_init(e1000_register_nodes);