Skip to content

Commit

Permalink
Updating unit test runner script for EFR32 and associated documentati…
Browse files Browse the repository at this point in the history
…on. (#36893)

* Updating unit test runner script for EFR32 and associated documentation.

* Restyled by prettier-markdown

* Restyled by prettier-markdown

* Readme updates

* Readme updates

* Updated README and tasks.json

* Restyled

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
feasel0 and restyled-commits authored Jan 21, 2025
1 parent c2e655c commit 6e77b54
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 68 deletions.
45 changes: 45 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,30 @@
]
}
},
{
"label": "Build EFR32 Unit Tests and Test Runner",
"type": "shell",
"command": "source scripts/activate.sh; scripts/build/build_examples.py --target efr32-${input:efr32Board}-unit-test build; scripts/build/build_examples.py --target linux-x64-efr32-test-runner build; pip3 install out/linux-x64-efr32-test-runner/chip_pw_test_runner_wheels/*.whl --force-reinstall",
"problemMatcher": []
},
{
"label": "Rebuild EFR32 Unit Tests and Test Runner",
"type": "shell",
"command": "source scripts/activate.sh; rm -rf out/efr32-brd*-unit-test out/linux-x64-efr32-test-runner; scripts/build/build_examples.py --target efr32-${input:efr32Board}-unit-test build; scripts/build/build_examples.py --target linux-x64-efr32-test-runner build; pip3 install out/linux-x64-efr32-test-runner/chip_pw_test_runner_wheels/*.whl --force-reinstall",
"problemMatcher": []
},
{
"label": "Clean EFR32 Unit Tests and Test Runner",
"type": "shell",
"command": "rm -rf out/efr32-brd*-unit-test out/linux-x64-efr32-test-runner",
"problemMatcher": []
},
{
"label": "Run EFR32 Unit Tests",
"type": "shell",
"command": "source scripts/activate.sh; python -m src.test_driver.efr32.py.pw_test_runner.pw_test_runner -d /dev/ttyACM1 -f out/efr32-brd2703a-unit-test/tests -o out.log",
"problemMatcher": []
},
{
"label": "Flash EFR32 board",
"type": "shell",
Expand Down Expand Up @@ -646,6 +670,27 @@
"tizen-arm-light"
]
},
{
"type": "pickString",
"id": "efr32Board",
"description": "Which board",
"options": [
"brd2704b",
"brd4316a",
"brd4317a",
"brd4318a",
"brd4319a",
"brd4186a",
"brd4187a",
"brd2601b",
"brd4187c",
"brd4186c",
"brd2703a",
"brd4338a",
"brd2605a",
"brd4343a"
]
},
{
"type": "promptString",
"id": "tizenTargetDeviceAddress",
Expand Down
108 changes: 42 additions & 66 deletions src/test_driver/efr32/README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,29 @@
#CHIP EFR32 Test Driver
This is a test driver for the Matter unit tests to be run on an EFR32 device. It
builds a set of test binaries, each of which contains one directory of unit
tests that can be flashed onto a device and run. The device is controlled using
the included RPCs through the python test runner.

This builds and runs the unit tests on the efr32 device.
- [Prerequisites](#prerequisites)
- [Building and Running the Unit Tests](#building-and-running-the-unit-tests)
- [Building and Running the Unit Tests with the build_examples Script](#building-and-running-the-unit-tests-with-the-build_examples-script)

<hr>

- [Introduction](#introduction)
- [Building](#building)
- [Running The Tests](#running-the-tests)

<hr>

<a name="introduction"></a>

## Introduction

This builds a set of test binaries which contain the unit tests and can be
flashed onto a device. The device is controlled using the included RPCs, through
the python test runner.

<a name="building"></a>

## Building
## Prerequisites

- Download the
[Simplicity Commander](https://www.silabs.com/mcu/programming-options)
command line tool, and ensure that `commander` is your shell search path.
command line tool, and ensure that `commander` is in your shell search path.
(For Mac OS X, `commander` is located inside
`Commander.app/Contents/MacOS/`.)

- Download and install a suitable ARM gcc tool chain (For most Host, the
bootstrap already installs the toolchain):
[GNU Arm Embedded Toolchain 12.2 Rel1](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads)

- Install some additional tools(likely already present for CHIP developers):
- Install some additional tools:

#Linux `sudo apt-get install git libwebkitgtk-1.0-0 ninja-build`
For Linux: `sudo apt-get install git libwebkitgtk-1.0-0 ninja-build`

#Mac OS X `brew install ninja`
For Mac OS: `brew install ninja`

- Supported hardware:

Expand All @@ -49,60 +36,49 @@ the python test runner.
- BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm
- BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm

OR use GN/Ninja directly
## Building and Running the Unit Tests

```
cd ~/connectedhomeip/src/test_driver/efr32/
git submodule update --init
source third_party/connectedhomeip/scripts/activate.sh
export SILABS_BOARD=BRD4187C
gn gen out/debug
ninja -C out/debug
```
### Building the Unit Tests

- To delete generated executable, libraries and object files use:
The unit tests can be built using gn and ninja. Set the appropriate board name.

```
cd ~/connectedhomeip/src/test_driver/efr32/
rm -rf out/
```

<a name="running-the-tests"></a>
source scripts/activate.sh
cd src/test_driver/efr32
export SILABS_BOARD=BRD2703A
gn gen out/debug
ninja -C out/debug

## Running The Tests
### Building and Installing the Runner

Build the runner using gn:
The python wheels for the runner can be built and installed like this:

```
cd <connectedhomeip>/src/test_driver/efr32
gn gen out/debug
ninja -C out/debug runner
```
pip3 install out/debug/chip_pw_test_runner_wheels/*.whl --force-reinstall

### Running the Unit Tests

The unit tests can be run using the test runner python script:

python -m py.pw_test_runner.pw_test_runner -d /dev/ttyACM1 -f out/debug/tests -o out.log

## Building and Running the Unit Tests with the build_examples Script

Or build using build script from the root
### Building the Unit Tests

```
cd <connectedhomeip>
./scripts/build/build_examples.py --target linux-x64-pw-test-runner build
```
The unit tests can be built using the build_examples script. Set the appropriate
board name.

The runner will be installed into the venv and python wheels will be packaged in
the output folder for deploying.
scripts/build/build_examples.py --target efr32-brd2703a-unit-test build

Then the python wheels need to installed using pip3.
### Building and Installing the Runner

```
pip3 install out/debug/chip_pw_test_runner_wheels/*.whl
```
The python wheels for the runner can be built and installed like this:

Other python libraries may need to be installed such as
scripts/build/build_examples.py --target linux-x64-efr32-test-runner build
pip3 install out/linux-x64-efr32-test-runner/chip_pw_test_runner_wheels/*.whl --force-reinstall

```
pip3 install pyserial
```
### Running the Unit Tests

- To run all tests:
The unit tests can be run using the test runner python script:

```
python -m pw_test_runner.pw_test_runner -d /dev/ttyACM1 -f out/debug/matter-silabs-device_tests.s37 -o out.log
```
python -m src.test_driver.efr32.py.pw_test_runner.pw_test_runner -d /dev/ttyACM1 -f out/efr32-brd2703a-unit-test/tests -o out.log
3 changes: 1 addition & 2 deletions src/test_driver/efr32/py/pw_test_runner/pw_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ def run(args) -> int:


def list_images(flash_directory: str) -> list[str]:
filenames: list[str] = glob.glob(os.path.join(flash_directory, "*.s37"))
return list(map(lambda x: os.path.join(flash_directory, x), filenames))
return glob.glob(os.path.join(flash_directory, "*.s37"))


def main() -> int:
Expand Down

0 comments on commit 6e77b54

Please sign in to comment.