@@ -213,7 +213,6 @@ gcov-files-pci-y += hw/net/pcnet-pci.c
check-qtest-pci-y += tests/eepro100-test$(EXESUF)
gcov-files-pci-y += hw/net/eepro100.c
gcov-files-pci-y += hw/net/ne2000.c
-check-qtest-pci-y += tests/nvme-test$(EXESUF)
gcov-files-pci-y += hw/block/nvme.c
gcov-files-pci-y += hw/audio/ac97.c
check-qtest-pci-y += tests/es1370-test$(EXESUF)
@@ -793,6 +792,7 @@ libqgraph-tests-obj-y += tests/ac97-test.o
libqgraph-tests-obj-y += tests/tpci200-test.o
libqgraph-tests-obj-y += tests/ipoctal232-test.o
libqgraph-tests-obj-y += tests/ne2000-test.o
+libqgraph-tests-obj-y += tests/nvme-test.o
check-unit-y += tests/test-qgraph$(EXESUF)
tests/test-qgraph$(EXESUF): tests/test-qgraph.o $(libqgraph-obj-y)
@@ -841,7 +841,6 @@ tests/test-hmp$(EXESUF): tests/test-hmp.o
tests/machine-none-test$(EXESUF): tests/machine-none-test.o
tests/drive_del-test$(EXESUF): tests/drive_del-test.o $(libqos-virtio-obj-y)
tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-obj-y)
-tests/nvme-test$(EXESUF): tests/nvme-test.o
tests/pvpanic-test$(EXESUF): tests/pvpanic-test.o
tests/i82801b11-test$(EXESUF): tests/i82801b11-test.o
tests/es1370-test$(EXESUF): tests/es1370-test.o
@@ -9,24 +9,47 @@
#include "qemu/osdep.h"
#include "libqtest.h"
+#include "libqos/qgraph.h"
+
+typedef struct QNvme QNvme;
+
+struct QNvme {
+ QOSGraphObject obj;
+};
/* Tests only initialization so far. TODO: Replace with functional tests */
-static void nop(void)
+static void nop(void *obj, void *data, QGuestAllocator *alloc)
+{
+}
+
+static void nvme_destructor(QOSGraphObject *obj)
{
+ QNvme *nvme = (QNvme *)obj;
+ g_free(nvme);
}
-int main(int argc, char **argv)
+static void *nvme_create(void *pci_bus, QGuestAllocator *alloc, void *addr)
{
- int ret;
+ QNvme *nvme = g_new0(QNvme, 1);
+ nvme->obj.destructor = nvme_destructor;
- g_test_init(&argc, &argv, NULL);
- qtest_add_func("/nvme/nop", nop);
+ return &nvme->obj;
+}
- qtest_start("-drive id=drv0,if=none,file=null-co://,format=raw "
- "-device nvme,drive=drv0,serial=foo");
- ret = g_test_run();
+static void nvme_register_nodes(void)
+{
+ qos_node_create_driver("nvme", nvme_create);
+ qos_node_consumes("nvme", "pci-bus", &(QOSGraphEdgeOptions) {
+ .extra_device_opts = "drive=drv0,serial=foo",
+ .before_cmd_line = "-drive id=drv0,if=none,file=null-co://,format=raw",
+ });
+}
- qtest_end();
+libqos_init(nvme_register_nodes);
- return ret;
+static void register_nvme_test(void)
+{
+ qos_add_test("nvme-test", "nvme", nop, NULL);
}
+
+libqos_init(register_nvme_test);
Convert tests/nvme-test in qgraph test node, nvme-test. Since it's a nop test, node creation and initialization is made in the same file. Signed-off-by: Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com> --- tests/Makefile.include | 3 +-- tests/nvme-test.c | 43 ++++++++++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 12 deletions(-)