pytest Command Line Parameters¶
The pytest-libiio plugin extends the pytest cli with a few options to help with debugging tests, accessing specific hardware, and adding hardware maps between drivers and tests.
Available CLI options¶
Flag |
Default |
Description |
|---|---|---|
|
(scan) |
Skip the scan and use this libiio URI directly. See URI. |
|
off |
Print details of every discovered context during scanning. |
|
off |
Use the bundled ADI hardware map. See Hardware maps. |
|
(none) |
Path to a custom hardware map YAML. See Hardware maps. |
|
(none) |
Treat the |
|
off |
Skip the Zeroconf/avahi scan. Typically used in CI together with |
|
off |
Launch iio-emu and run tests against the emulator. See Emulation and Scenario: emulation mode. |
|
(auto) |
Path or name of an iio-emu XML to load. Without it, XML files are picked from the hardware map. |
|
(bundled) |
Override the directory that holds emulator XML files (defaults to |
|
off |
Capture before/after telemetry for every test that uses |
|
|
Folder for telemetry pickle files. |
|
off |
Track IIO attribute reads/writes across the session. See Coverage tracking. |
|
|
Folder for per-context coverage JSON + the aggregated markdown report. |
|
off |
Also track IIO debug attributes. |
|
off |
Print the per-context attribute map to stdout after the session. |
URI¶
When –uri=<input uri> is used, scanning is skipped and that URI is checked for a context. The URI can be in any form supported by the installed version of libiio:
Network: ip:192.168.2.1
USB: usb:1.2.3 or usb:
Local: local:
Serial: serial:/dev/ttyUSB0,115200
When a URI is not supplied a scan is performed and all found contexts are used to determine which tests to enable.
Hardware maps¶
pytest-libiio allows tests to be filtered based on markers with specific hardware maps. These maps are essentially a list of IIO device names and attributes which make up or identify a specific platform or board. These are defined in a yaml file which will have contents similar to the one below:
pluto:
- adm1177
- ad9361-phy
- cf-ad9361-lpc,2
pluto_rev_c:
- ad9361-phy
- cf-ad9361-lpc,2
- ctx_attr:
- hw_model: Analog Devices PlutoSDR Rev.C
fmcomms5:
- ad9361-phy
- ad9361-phy-b
- cf-ad9361-lpc,8
These are arranged in the form:
<platform name>:
- <driver 1>,<number of channels of driver 1 (optional)>
- <driver 2>,<number of channels of driver 2 (optional)>
- ctx_attr:
- <context attribute name>: <value>
...
When the decorator @pytest.mark.iio_hardware(hardware) is used, any tests using this decorator will be used where hardware is a string or list of strings that match anything in the hardware map. Otherwise the test is filtered. Note that contexts must be found with matching hardware for the test to not be filtered as well.
By default, all devices are labeled as unknown if no map exists or they are not found in the current map. If the decorator is not used, the test will not be filtered based on these criteria.
When the flag –adi-hw-map is used the provided map from plugin itself is used. Alternatively, a custom map can be used by supply the path with –custom-hw-map=<path to yaml>.
If the flag –hw=
Telemetry¶
When the flag –telm is used, hardware telemetry is collected on each test. This enables a fixture that is autouse, meaning it is automatically used by all tests. The telemetry is collected in a folder defined by –telm-data-folder=<path>. The folder is created if it does not exist. Telemetry data is stored in individual files that are specific to a URI. So after a test suite run there should one file for every hardware platform under test. The test files are generated at pickle files and contain different metadata. This is primarily just IIO based information. However, if the optional SSH dependency is installed, additional metadata is collected from the target hardware if it uses an IP context.
For a worked example see Scenario: telemetry capture.
Coverage tracking¶
When –iio-coverage is set, pytest-libiio monkey-patches both
iio.ChannelAttr and iio.DeviceAttr to record every attribute read and write
performed by your tests, grouped by the matched hardware context. Both
device-level attributes and per-channel attributes are tracked by default. The
iio_uri fixture installs the per-context tracker automatically — no per-test
plumbing is required.
After the session finishes the plugin writes:
One
<hw>_coverage.jsonfile per context with the raw per-attribute counts, split intodevice_attr_reads_writesandchannel_attr_reads_writessections (plusdebug_attr_reads_writeswhen –iio-coverage-debug-props is set).One
iio_coverage_report.mdaggregating coverage percentages across all contexts, with a row per system fordevice_coverage,channel_coverage, andtotal_coverage.
Both land in the directory named by –iio-coverage-folder (default
iio_coverage_results). Pass –iio-coverage-print-results to also dump the
per-context attribute map to stdout, or –iio-coverage-debug-props to
include debug attributes in the tally.
For a worked example see Scenario: attribute coverage.