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.

class hw_tests.labgrid.LabgridClient(context)

Select a labgrid place for a test and acquire it.

The coordinator is labgrid_coordinator from the context or LG_COORDINATOR. The place is selected on creation: the first free place, by name, whose tags include all needs from the context. If labgrid_target is set, only that place is considered. If all matches are acquired, waits up to one hour.

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.

acquire()

Acquire the place and yield its labgrid target.

Writes the SSH config for the exporter and target hosts and checks SSH access. On exit, cleans up the target and releases the place if it was acquired here.

hw_tests.labgrid.exporter_http_server(ssh, files)

Serve files over HTTP from a remote host.

Copies files to a temporary directory on the host, starts python3 -m http.server on a free port, and removes everything on exit.

Parameters:
  • ssh – Labgrid SSHDriver of 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.