Testing Infrastructure

Helpers and utilities for various Bakeneko tests

class bakeneko.support.test.BakenekoRemoteTestCase(*args, **kwargs)

Run unitest based test cases that interact with a remote host over SSH.

Attributes:
  • REMOTE_HOST (str | None) – The remote host to connect to. If not overloaded it reads the value from the BAKENEKO_REMOTE_TEST_HOST environment variable if it exists, otherwise the value is None.

  • REMOTE_USER (str | None) – The user on the remote host to connect as. If not overloaded it reads the value from the BAKENEKO_REMOTE_TEST_USER environment variable if it exits, otherwise the value is None.

  • REMOTE_KEY (str | None) – The private key file to use for remote authentication. If not overloaded it reads the value from the BAKENEKO_REMOTE_TEST_KEY environment variable if it exits, otherwise the value is None.

  • LONG_LIVED (bool) – If the remote connection is long-lived. If set to true, the connection will be established on construction of the test class and live for every single test case run. Otherwise, the connection is established prior to each test_ case and torn down after. (default: True)

remote_put_file(file: Path | IOBase, dest: str)

Send a file to the remote system

Parameters:
  • file (Path | IOBase) – The file to upload.

  • dest (str) – The destination for the file.

Returns:

  • fabric.transfer.Result – If the connection is active and valid, the result of the file transfer.

  • None – If there is no remote connection.

Raises:

AssertionError – If the put on the remote connection fails for any reason.

remote_run_cmd(cmd: str, **kwargs)

Run a command on the remote system.

Parameters:

cmd (str) – The command to run on the remote system.

Returns:

  • invoke.runners.Result – If the connection is active and valid, the result of the command.

  • None – If there is no remote connection.

Raises:

AssertionError – If the run on the remote connection fails for any reason.

assertRemoteConnected()

Assert that we are connected to the remote session

setUp() None

Hook method for setting up the test fixture before exercising it.

Return type:

None

tearDown() None

Hook method for deconstructing the test fixture after testing it.

Return type:

None

class bakeneko.support.test.BakenekoSerialTestCase(methodName: str = 'runTest', **kwargs) None

Run unitest based test cases that interact with a DUT over serial

Attributes:
  • SERIAL_PORT (str | None) – The serial port to connect to. If not overloaded it reads the value from the BAKENEKO_SERIAL_TEST_PORT environment variable if it exists, otherwise the value is None.

  • REMOTE_USER (int) – The user on the remote host to connect as. If not overloaded it reads the value from the BAKENEKO_SERIAL_TEST_BAUD environment variable if it exists. (default: 115200)

LONG_LIVEDbool

If the serial connection is long-lived. If set to true, the connection will be established on construction of the test class and live for every single test case run. Otherwise, the connection is established prior to each test_ case and torn down after. (default: True)

setUp() None

Hook that runs prior to a test running

Checks the value of LONG_LIVED, and if it is not set then it sets up the Serial connection to the remote DUT.

Note

If your test needs specialized setup code and you overload this make sure you call super().setUp()!

Return type:

None

tearDown() None

Hook that runs when a test is completed.

Checks the value of LONG_LIVED, and if it is not set then it cleans up the Serial connection to the remote DUT.

Note

If your test needs specialized teardown code and you overload this make sure you call super().tearDown()!

Return type:

None

class bakeneko.support.test.PCIeGatewareTestCase(*args, **kwargs) None

A specialization of the torii.test.ToriiTestCase for the Bakeneko PCIe gateware.

It primarily provides helper asserts for various things related to PCIe traffic and symbols.