-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[skip ci]
- Loading branch information
Showing
1 changed file
with
41 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,70 @@ | ||
# Run Tests | ||
# Tests | ||
|
||
This section provides documentation on running tests and various scenarios. | ||
Refer below for instructions on running the snap tests. | ||
There are two different testing suites with different hardware requirements and inputs. | ||
|
||
## Environment Variables | ||
## Run WiFi tests | ||
|
||
The WiFi tests run the Matter controller along with this snap on the same machine. | ||
The machine should be a compatible Raspberry Pi, unless the GPIO is mocked. | ||
|
||
To run the tests, you must set the following environment variables: | ||
|
||
- `SERVICE_CHANNEL`: The channel from which the snap will be downloaded if not using a local snap file. The default option is `latest/edge`. | ||
- `SERVICE_CHANNEL`: The channel from which the snap will be downloaded. The default value is `latest/edge`. This is ignored when using a locally built snap. | ||
- `LOCAL_SERVICE_SNAP`: Path to the local service snap to be tested instead of downloading from a channel. | ||
- `SKIP_TEARDOWN_REMOVAL`: Skip the removal of snaps during teardown (useful when running on CI machines). The default option is `false`. | ||
- `MOCK_GPIO`: This is used to determine whether you wish to use gpio-mock to test the application instead of a physical gpiochip. Possible values are `true` or `false`. Important note: the usage of gpio-mock will only work if the snap is being installed from a local file; in other words, `LOCAL_SERVICE_SNAP` must be defined. | ||
- `GPIO_CHIP`: The GPIO chip number; accepted values are `0` (for legacy Raspberry Pis) or `4` for the Raspberry Pi 5. This doesn't need to be specified if using `USE_GPIO_MOCK`. | ||
- `GPIO_LINE`: This is the line offset to be used to test the selected gpiochip. The number of available lines can be checked with the `gpiodetect` and `gpioinfo` commands from the Debian package `gpiod`. This doesn't need to be specified if using `USE_GPIO_MOCK`. | ||
|
||
**Note:** The `USE_GPIO_MOCK` takes precedence over the specific `GPIO_CHIP` and `GPIO_LINE` settings if the former is set to "1"; thus, the other two are ignored. | ||
- `SKIP_TEARDOWN_REMOVAL`: Skip the removal of snaps during teardown (useful when running on CI machines). The default value is `false`. | ||
- `MOCK_GPIO`: Use gpio-mock to test the application instead of a physical gpiochip. The default value is `false`. The GPIO mocking logic works by modifying a local snap; the path to which must be set in `LOCAL_SERVICE_SNAP`. | ||
- `GPIO_CHIP`: The GPIO chip number; accepted values are `0` (for legacy Raspberry Pis) or `4` for the Raspberry Pi 5. This is ignored when mocking GPIO. | ||
- `GPIO_LINE`: This is the line offset to be used to test the selected gpiochip. The number of available lines can be checked with the `gpiodetect` and `gpioinfo` commands from the Debian package `gpiod`. This is ignored when mocking GPIO. | ||
|
||
## Running tests | ||
Example, for running tests on a Raspberry Pi 4: | ||
|
||
```bash | ||
GPIO_CHIP=0 \ | ||
GPIO_LINE=16 \ | ||
go test -v -failfast -count 1 | ||
``` | ||
|
||
where: | ||
- `-v` is to enable verbose output | ||
- `-failfast` makes the test stop after first failure | ||
- `-count 1` is to avoid Go test caching for example when testing a rebuilt snap | ||
- `-count 1` is to avoid Go test caching when repeating the unchanged tests, such when re-testing a rebuilt snap. | ||
|
||
# Thread Tests | ||
# Run Thread tests | ||
|
||
These tests are meant to be run manually; therefore, they are in this separate | ||
directory. | ||
These tests have additional hardware dependencies: | ||
- A nRF52480 dongle with OT RCP firmware - connected to the local machine | ||
- A compatible Raspberry Pi - used as the remote device | ||
- A second nRF52480 dongle with OT RCP firmware - connected to the Raspberry Pi | ||
|
||
## Environment Variables | ||
You can refer to [this guide][openthread-border-router-snap-guide-url] to learn how to build and flash an RCP firmware. | ||
|
||
Some environment variables are needed to run the tests. The main reason is that | ||
the tests actually run on two devices, each with two Radio Co-Processors (RCPs) | ||
(such as the nRF52480 dongle) attached to them, and they communicate using an | ||
SSH connection. The machine used to run the test will be referred to as | ||
"first machine" or **machine (A)**, and the machine accessed by SSH will be | ||
referred to as "second machine" or **machine (B)**. | ||
The tests will configure the remote device over SSH: an open SSH server with password-login on the Raspberry Pi is required. | ||
|
||
You can refer to [this guide][openthread-border-router-snap-guide-url] to learn | ||
how to build and flash an RCP firmware. | ||
Additional environment variables needed for these tests: | ||
* For the remote machine: | ||
* `REMOTE_HOST`: IP address or hostname | ||
* `REMOTE_USER`: username for SSH login | ||
* `REMOTE_PASSWORD`: password for the user | ||
* `REMOTE_INFRA_IF`: network interface name used for the main networking interface on the remote machine (usually the Wifi or Ethernet interface) | ||
* `REMOTE_GPIO_CHIP`: GPIO chip number | ||
* `REMOTE_GPIO_LINE`: GPIO line number | ||
* `REMOTE_SNAP_PATH`: path to the snap file. If doesn't specified, snap if fetched from store. | ||
* For the local machine: | ||
* `LOCAL_INFRA_IF`: network interface name used for the main networking interface on the local machine (usually the Wifi or Ethernet interface) | ||
|
||
* `REMOTE_USER` - The user to be logged in on the second machine **(B)**. | ||
* `REMOTE_PASSWORD` - The password for the second machine **(B)** user. | ||
* `REMOTE_HOST` - The IP address of the second machine **(B)**. | ||
* `REMOTE_INFRA_IF` - The network interface name for the second machine **(B)**. | ||
* `LOCAL_INFRA_IF` - The network interface name for the first machine **(A)**. | ||
* `REMOTE_SNAP_PATH` - The path to the snap file on the second machine **(B)**, | ||
if doesn't specified, snap if fetched from store. | ||
* `REMOTE_GPIO_CHIP` - The number for the GPIO chip to be used on **(B)**. | ||
* `REMOTE_GPIO_LINE` - The number for the GPIO line to be used on **(B)**. | ||
|
||
Example: | ||
Example, for testing a locally built snap, available on the remote machine at `~/matter-pi-gpio-commander_2.0.0_arm64.snap`: | ||
|
||
```bash | ||
REMOTE_SNAP_PATH="~/matter-pi-gpio-commander_2.0.0_arm64.snap" \ | ||
REMOTE_HOST="192.168.178.95" \ | ||
REMOTE_USER="ubuntu" \ | ||
REMOTE_PASSWORD="abcdef" \ | ||
REMOTE_INFRA_IF="eth0" \ | ||
REMOTE_GPIO_CHIP="0" \ | ||
REMOTE_GPIO_LINE="16" \ | ||
REMOTE_SNAP_PATH="~/matter-pi-gpio-commander_2.0.0_arm64.snap" \ | ||
LOCAL_INFRA_IF="eno1" \ | ||
REMOTE_INFRA_IF="eth0" \ | ||
REMOTE_USER="ubuntu" \ | ||
REMOTE_PASSWORD="abcdef" \ | ||
REMOTE_HOST="192.168.178.95" \ | ||
go test -v -failfast -count 1 ./thread_tests | ||
``` | ||
|
||
[openthread-border-router-snap-guide-url]: https://github.com/canonical/openthread-border-router-snap/wiki/Setup-OpenThread-Border-Router-with-nRF52840-Dongle#build-and-flash-rcp-firmware-on-nrf52480-dongle | ||
[openthread-border-router-snap-guide-url]: https://github.com/canonical/openthread-border-router-snap/wiki/Setup-OpenThread-Border-Router-with-nRF52840-Dongle |