Features/qtest driver framework: Difference between revisions
(fix) |
No edit summary |
||
Line 15: | Line 15: | ||
(driver) (driver) (driver) (interface) (driver) | (driver) (driver) (driver) (interface) (driver) | ||
pc ────────→ i440FX-host ───────→ QPCIBusPC ───────→ QPCIBus ───────→ QSDHCIPCI | pc ────────→ i440FX-host ───────→ QPCIBusPC ───────→ QPCIBus ───────→ QSDHCIPCI | ||
produces produces | produces produces produces consumes │ produces | ||
↓ | ↓ | ||
(interface) | (interface) |
Revision as of 21:50, 21 March 2018
Through a driver framework, libqos can expose a description of QEMU's supported machine types and a set of drivers; unit tests can request a driver, and the framework takes care of starting QEMU with options that provide that driver.
For example, the framework could provide:
- an interface for SD-HCI (SD Host Controller Interface) devices (abstract class QSDHCI)
- a driver for PCI SD-HCI devices (a subclass of QSDHCI, for example QSDHCI_PCI)
- a description of how QEMU's "sdhci-pci" device maps to QSDHCI_PCI (for simplicity this can be part of QSDHCI_PCI)
- an interface for a PCI bus (abstract class QPCIBus)
- a driver for the PCI bus in an x86 PC machine (a subclass of QPCIBus, for example QPCIBusPC)
- a description of QEMU's "pc" machine (a subclass of QOSMachine) and its embedded devices (in this case a QPCIBusPC)
(Right now libqos provides items 4 and 5 only).
You can construct a graph where the nodes are interfaces, drivers and unit tests, connected by relations such as "X produces Y" or "X consumes Y":
(driver) (driver) (driver) (interface) (driver) pc ────────→ i440FX-host ───────→ QPCIBusPC ───────→ QPCIBus ───────→ QSDHCIPCI produces produces produces consumes │ produces ↓ (interface) QSDHCI │ consumes ↓ register-test
(The above is just a single path in a potentially very large graph, covering the whole "x86_64" QEMU target architecture!). The relations are hard-coded in the classes and in the tests. For example, a unit test for the SD-HCI device (let's call it "registers-test") would add itself to the graph like this:
qos_add_test("register-test", "sdhci"); │ ╰────── Interface consumed by the test ╰──────────────────── Test name
and likewise all the edges in the graph would be hard coded.
After the graph is built, tests can be discovered by walking the graph: each test to run corresponds to a path from the root of the graphs to a unit test. The above path could represent a test like "/x86_64/pc/i440FX-host/pcibus-pci/sdhci-pci/sdhci/registers-test":
/x86_64/pc/i440FX-host/pcibus-pc/sdhci-pci/sdhci/registers-test │ │ │ │ │ │ ╰────── Test name │ │ │ │ │ ╰────────────── Driver or interface provided by "sdhci-pci" │ │ │ │ ╰───────────────────── Device on the PCI bus │ │ │ ╰─────────────────────────────── Driver or interface provided by "i440FX-host" │ │ ╰────────────────────────────────────────── Device embedded by "pc" │ ╰────────────────────────────────────────────────── QEMU machine ╰───────────────────────────────────────────────────── Target architecture
or reading it in the other direction (right to left):
/x86_64/pc/i440FX-host/pcibus-pc/sdhci-pci/sdhci/registers-test │ │ │ │ │ │ ╰────── Test name │ │ │ │ │ ╰────────────── Driver or interface consumed by the test │ │ │ │ ╰───────────────────── Device providing the "sdhci-pci" interface │ │ │ ╰─────────────────────────────── Driver or interface consumed by "sdhci-pci" │ │ ╰────────────────────────────────────────── Device providing the "pcibus-pc" interface │ ╰────────────────────────────────────────────────── QEMU machine ╰───────────────────────────────────────────────────── Target architecture
At run-time, a lot of steps are hidden in the framework, and are realized by walking the path:
- QOSMachine walks the path to the device under test
- the machine itself adds "-M pc" to the command line
- QPCIBusPC need not add anything to the command line because the device is embedded
- QSDHCI_PCI adds "-device sdhci-pci" to the command line
- QOSMachine starts QEMU
- QOSMachine finally executes the code for the unit test
- The test asks QSDHCI_PCI to start the device
- QSDHCI_PCI sets up the PCI device using the methods of QPCIBus
- The test runs and tests the SDHCI device
- The test asks QSDHCI_PCI to start the device
Possible milestones
- Create graph framework and write unit tests
- Convert all PC-based PCI device tests to use the graph framework
- Convert all PCI device tests to use the graph framework, so that all PC-based PCI device tests can work on more than one machine
- Create more drivers (e.g. SD-HCI)