aboutsummaryrefslogtreecommitdiff
path: root/tests/e1000-test.c
diff options
context:
space:
mode:
authorEmanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>2018-08-17 16:16:22 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2019-03-07 17:28:47 +0100
commita138f26623e15ec721489f3164fbd7eb03a6dc98 (patch)
tree84d2b486040893de69b6ad737694f148b7833ba0 /tests/e1000-test.c
parent0b477302343b8a981a9a7e01c1c1e7da323b991f (diff)
qos-test: e1000 test node
Convert tests/e1000-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/e1000-test.c')
-rw-r--r--tests/e1000-test.c64
1 files changed, 40 insertions, 24 deletions
diff --git a/tests/e1000-test.c b/tests/e1000-test.c
index 0c5fcdcc44..9e67916169 100644
--- a/tests/e1000-test.c
+++ b/tests/e1000-test.c
@@ -9,22 +9,15 @@
#include "qemu/osdep.h"
#include "libqtest.h"
+#include "libqos/qgraph.h"
+#include "libqos/pci.h"
-/* Tests only initialization so far. TODO: Replace with functional tests */
-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);
+typedef struct QE1000 QE1000;
- if (s) {
- qtest_quit(s);
- }
- g_free(args);
-}
+struct QE1000 {
+ QOSGraphObject obj;
+ QPCIDevice dev;
+};
static const char *models[] = {
"e1000",
@@ -33,19 +26,42 @@ static const char *models[] = {
"e1000-82545em",
};
-int main(int argc, char **argv)
+static void *e1000_get_driver(void *obj, const char *interface)
{
- int i;
+ QE1000 *e1000 = obj;
- g_test_init(&argc, &argv, NULL);
+ if (!g_strcmp0(interface, "pci-device")) {
+ return &e1000->dev;
+ }
- for (i = 0; i < ARRAY_SIZE(models); i++) {
- char *path;
+ fprintf(stderr, "%s not present in e1000e\n", interface);
+ g_assert_not_reached();
+}
- path = g_strdup_printf("e1000/%s", models[i]);
- qtest_add_data_func(path, models[i], test_device);
- g_free(path);
- }
+static void *e1000_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
+{
+ QE1000 *e1000 = g_new0(QE1000, 1);
+ QPCIBus *bus = pci_bus;
+
+ qpci_device_init(&e1000->dev, bus, addr);
+ e1000->obj.get_driver = e1000_get_driver;
+
+ return &e1000->obj;
+}
+
+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 g_test_run();
+ 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);