Lines Matching +full:test +full:- +full:path
6 In order to test a specific driver, plain libqos tests need to
8 This makes each test "hardcoded" for a specific configuration, reducing
12 therefore a generic sdhci test should test all machines and drivers that
14 Using only libqos APIs, the test has to manually take care of
22 a test aimed to a certain driver does not have to care of
29 so the sdhci-test should only care of linking its qgraph node with
34 ---------------
45 - **QNODE_MACHINE**: for example ``arm/raspi2b``
46 - **QNODE_DRIVER**: for example ``generic-sdhci``
47 - **QNODE_INTERFACE**: for example ``sdhci`` (interface for all ``-sdhci``
54 - **QNODE_TEST**: for example ``sdhci-test``. A test consumes an interface
59 - QNODE_MACHINE: each machine struct must have a ``QGuestAllocator`` and
63 - QNODE_DRIVER: driver names must be unique, and machines and nodes
72 - ``X CONSUMES Y``: ``Y`` can be plugged into ``X``
73 - ``X PRODUCES Y``: ``X`` provides the interface ``Y``
74 - ``X CONTAINS Y``: ``Y`` is part of ``X`` component
81 - All nodes and edges are created in their respective
82 machine/driver/test files
83 - The framework starts QEMU and asks for a list of available devices
86 - The framework walks the graph starting from the available machines and
88 - Once a test is found, the path is walked again and all drivers are
89 allocated accordingly and the final interface is passed to the test
90 - The test is executed
91 - Unused objects are cleaned and the path discovery is continued
94 available and only test that are reached by them will be executed.
104 - ``in node`` : created from the node name. For example, machines will
105 have ``-M <machine>`` to its command line, while devices
106 ``-device <device>``. It is automatically done by the framework.
107 - ``after node`` : added as additional argument to the node name.
118 - ``before node`` : added as additional argument to the node name.
124 helpful to commands that are not node-representable,
125 such as ``-fdsev`` or ``-netdev``.
128 used in every path walk: this is because the contained or produced ones
137 .before_cmd_line = "-drive id=drv0,if=none,file=null-co://,"
138 "file.read-zeroes=on,format=raw",
139 .after_cmd_line = "-device scsi-hd,bus=vs0.0,drive=drv0",
144 qos_node_create_driver("virtio-scsi-device",
146 qos_node_consumes("virtio-scsi-device", "virtio-bus", &opts);
149 ``-drive id=drv0,if=none,file=null-co://, -device virtio-scsi-device,id=vs0 -device scsi-hd,bus=vs0…
154 If there is no path from an available machine to a test then that test will be
155 unavailable and won't execute. This can happen if a test or driver did not set
162 $ QTEST_QEMU_BINARY=build/qemu-system-x86_64 build/tests/qtest/qos-test --verbose
164 # src='virtio-net'
165 # |-> dest='virtio-net-tests/vhost-user/multiqueue' type=2 (node=0x559142109e30)
166 # |-> dest='virtio-net-tests/vhost-user/migrate' type=2 (node=0x559142109d00)
167 # src='virtio-net-pci'
168 # |-> dest='virtio-net' type=1 (node=0x55914210d740)
169 # src='pci-bus'
170 # |-> dest='virtio-net-pci' type=2 (node=0x55914210d880)
171 # src='pci-bus-pc'
172 # |-> dest='pci-bus' type=1 (node=0x559142103f40)
173 # src='i440FX-pcihost'
174 # |-> dest='pci-bus-pc' type=0 (node=0x55914210ac70)
176 # |-> dest='i440FX-pcihost' type=0 (node=0x5591421117f0)
178 # |-> dest='x86_64/pc' type=0 (node=0x559142111600)
179 # |-> dest='arm/raspi2b' type=0 (node=0x559142110740)
183 # name='virtio-net-tests/announce-self' type=3 cmd_line='(null)' [available]
184 # name='arm/raspi2b' type=0 cmd_line='-M raspi2b ' [UNAVAILABLE]
188 The ``virtio-net-tests/announce-self`` test is listed as "available" in the
189 "ALL QGRAPH NODES" output. This means the test will execute. We can follow the
190 qgraph path in the "ALL QGRAPH EDGES" output as follows: '' -> 'x86_64/pc' ->
191 'i440FX-pcihost' -> 'pci-bus-pc' -> 'pci-bus' -> 'virtio-net-pci' ->
192 'virtio-net'. The root of the qgraph is '' and the depth first search begins
196 reachable from the root via '' -> 'arm/raspi2b' the node is unavailable because
198 because we used the ``qemu-system-x86_64`` binary which does not support ARM
201 If a test is unexpectedly listed as "UNAVAILABLE", first check that the "ALL
202 QGRAPH EDGES" output reports edge connectivity from the root ('') to the test.
204 the driver or test code is incorrect. If there is connectivity, check the
205 availability of each node in the path in the "ALL QGRAPH NODES" output. The
206 first unavailable node in the path is the reason why the test is unavailable.
211 ---------------------------------------
215 - ``sdhci-test`` aims to test the ``read[q,w], writeq`` functions
217 - The current ``sdhci`` device is supported by both ``x86_64/pc`` and ``ARM``
218 (in this example we focus on the ``arm-raspi2b``) machines.
219 - QEMU offers 2 types of drivers: ``QSDHCI_MemoryMapped`` for ``ARM`` and
223 In order to implement such scenario in qgraph, the test developer needs to:
225 - Create the ``x86_64/pc`` machine node. This machine uses the
226 ``pci-bus`` architecture so it ``contains`` a PCI driver,
227 ``pci-bus-pc``. The actual path is
229 ``x86_64/pc --contains--> 1440FX-pcihost --contains-->
230 pci-bus-pc --produces--> pci-bus``.
234 - Create the ``sdhci-pci`` driver node, representing ``QSDHCI_PCI``.
236 so it must ``consume`` the ``pci-bus`` generic interface (which abstracts
239 ``sdhci-pci --consumes--> pci-bus``
240 - Create an ``arm/raspi2b`` machine node. This machine ``contains``
241 a ``generic-sdhci`` memory mapped ``sdhci`` driver node, representing
244 ``arm/raspi2b --contains--> generic-sdhci``
245 - Create the ``sdhci`` interface node. This interface offers the
247 The interface is produced by ``sdhci-pci`` and ``generic-sdhci``,
248 the available architecture-specific drivers.
250 ``sdhci-pci --produces--> sdhci``
252 ``generic-sdhci --produces--> sdhci``
253 - Create the ``sdhci-test`` test node. The test ``consumes`` the
257 ``sdhci-test --consumes--> sdhci``
259 ``arm-raspi2b`` machine, simplified from
260 ``tests/qtest/libqos/arm-raspi2-machine.c``::
274 return &machine->alloc;
285 if (!g_strcmp0(device, "generic-sdhci")) {
286 return &machine->sdhci.obj;
297 alloc_init(&machine->alloc, ...);
300 machine->obj.get_device = raspi2_get_device;
303 machine->obj.get_driver = raspi2_get_driver;
306 machine->obj.destructor = raspi2_destructor;
307 qos_init_sdhci_mm(&machine->sdhci, ...);
308 return &machine->obj;
313 /* arm/raspi2b --contains--> generic-sdhci */
316 qos_node_contains("arm/raspi2b", "generic-sdhci", NULL);
322 ``tests/qtest/libqos/x86_64_pc-machine.c``::
343 if (!g_strcmp0(device, "pci-bus-pc")) {
344 return &host->pci.obj;
346 fprintf(stderr, "%s not present in i440FX-pcihost\n", device);
356 return &machine->alloc;
366 if (!g_strcmp0(device, "i440FX-pcihost")) {
367 return &machine->bridge.obj;
379 machine->obj.get_device = pc_get_device;
382 machine->obj.get_driver = pc_get_driver;
385 machine->obj.destructor = pc_destructor;
386 pc_alloc_init(&machine->alloc, qts, ALLOC_NO_FLAGS);
389 machine->bridge.obj.get_device = i440FX_host_get_device;
391 return &machine->obj;
396 /* x86_64/pc --contains--> 1440FX-pcihost --contains-->
397 * pci-bus-pc [--produces--> pci-bus (in pci.h)] */
399 qos_node_contains("x86_64/pc", "i440FX-pcihost", NULL);
403 qos_node_create_driver("i440FX-pcihost", NULL);
404 qos_node_contains("i440FX-pcihost", "pci-bus-pc", NULL);
423 /* other driver-specific fields */
430 /* other driver-specific fields */
439 return &smm->sdhci;
441 fprintf(stderr, "%s not present in generic-sdhci\n", interface);
449 sdhci->obj.get_driver = sdhci_mm_get_driver;
452 sdhci->sdhci.readw = sdhci_mm_readw;
453 sdhci->sdhci.readq = sdhci_mm_readq;
454 sdhci->sdhci.writeq = sdhci_mm_writeq;
455 sdhci->qts = qts;
465 return &spci->sdhci;
468 fprintf(stderr, "%s not present in sdhci-pci\n", interface);
480 qpci_device_init(&spci->dev, bus, addr);
483 spci->sdhci.readw = sdhci_pci_readw;
484 spci->sdhci.readq = sdhci_pci_readq;
485 spci->sdhci.writeq = sdhci_pci_writeq;
488 spci->obj.get_driver = sdhci_pci_get_driver;
490 spci->obj.start_hw = sdhci_pci_start_hw;
491 spci->obj.destructor = sdhci_destructor;
492 return &spci->obj;
501 /* generic-sdhci */
502 /* generic-sdhci --produces--> sdhci */
503 qos_node_create_driver("generic-sdhci", NULL);
504 qos_node_produces("generic-sdhci", "sdhci");
506 /* sdhci-pci */
507 /* sdhci-pci --produces--> sdhci
508 * sdhci-pci --consumes--> pci-bus */
509 qos_node_create_driver("sdhci-pci", sdhci_pci_create);
510 qos_node_produces("sdhci-pci", "sdhci");
511 qos_node_consumes("sdhci-pci", "pci-bus", &opts);
518 x86_64/pc --contains--> 1440FX-pcihost --contains--> pci-bus-pc
520 sdhci-pci --consumes--> pci-bus <--produces--+
522 +--produces--+
528 +--produces-- +
530 arm/raspi2b --contains--> generic-sdhci
534 x86_64/pc --contains--> 1440FX-pcihost --contains--> pci-bus-pc
536 sdhci-pci <--consumed by-- pci-bus <--produces--+
538 +--produces--+
544 +--produces-- +
546 arm/raspi2b --contains--> generic-sdhci
548 Adding a new test
549 -----------------
551 Given the above setup, adding a new test is very simple.
552 ``sdhci-test``, taken from ``tests/qtest/sdhci-test.c``::
558 capab = s->readq(s, SDHC_CAPAB);
568 /* example test */
569 check_capab_sdma(s, s->props.capab.sdma);
574 /* sdhci-test --consumes--> sdhci */
580 Here a new test is created, consuming ``sdhci`` interface node
581 and creating a valid path from both machines to a test.
584 x86_64/pc --contains--> 1440FX-pcihost --contains--> pci-bus-pc
586 sdhci-pci --consumes--> pci-bus <--produces--+
588 +--produces--+
591 sdhci <--consumes-- sdhci-test
594 +--produces-- +
596 arm/raspi2b --contains--> generic-sdhci
600 x86_64/pc --contains--> 1440FX-pcihost --contains--> pci-bus-pc
602 sdhci-pci <--consumed by-- pci-bus <--produces--+
604 +--produces--+
607 sdhci --consumed by--> sdhci-test
610 +--produces-- +
612 arm/raspi2b --contains--> generic-sdhci
615 ``QTEST_QEMU_BINARY=./qemu-system-x86_64``
616 a valid test path will be:
617 ``/x86_64/pc/1440FX-pcihost/pci-bus-pc/pci-bus/sdhci-pc/sdhci/sdhci-test``
619 and for the binary ``QTEST_QEMU_BINARY=./qemu-system-arm``:
621 ``/arm/raspi2b/generic-sdhci/sdhci/sdhci-test``
623 Additional examples are also in ``test-qgraph.c``
626 --------------------
628 .. kernel-doc:: tests/qtest/libqos/qgraph.h