LabgridClient
To ensure the tests scope is to test a feature, the LabgridClient class
handles acquisition, authentication and lifespan. It picks a free place that
matches the needs of the test, acquires it, configures SSH, and releases.
- exception hw_tests.labgrid.LabError(msg: str | None = None, pytrace: bool = True, allow_module_level: bool = False, *, _use_item_location: bool = False)
The lab could not run the test, for example because no place is usable.
Raising it skips the test.
- class hw_tests.labgrid.LabgridClient(context)
Select a labgrid place for a test and acquire it.
The coordinator is
labgrid_coordinatorfrom the context orLG_COORDINATOR. The place is selected on creation: the first free place, by name, whose tags include allneedsfrom the context and whose resources are all available. Iflabgrid_targetis set, only that place is considered. If all usable places are acquired, waits up to one hour. If no place is usable, or none becomes free, skips the test withLabError.In GitHub Actions, the labgrid user is set to
labgrid-client-<run id>-<attempt>, so places left acquired by a previous attempt of the same run can be taken over.- Parameters:
context – Test context.
- hw_tests.labgrid.exporter_http_server(ssh, files)
Serve files over HTTP from a remote host.
Copies
filesto a temporary directory on the host, startspython3 -m http.serveron a free port, and removes everything on exit.- Parameters:
ssh – Labgrid
SSHDriverof the host.files – Maps paths relative to the HTTP root to local files.
- Returns:
Context manager yielding
(directory, port), the remote directory and the HTTP port.