Skip to content

Commit 6e77b54

Browse files
Updating unit test runner script for EFR32 and associated documentation. (#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 <commits@restyled.io>
1 parent c2e655c commit 6e77b54

File tree

3 files changed

+88
-68
lines changed

3 files changed

+88
-68
lines changed

.vscode/tasks.json

+45
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,30 @@
157157
]
158158
}
159159
},
160+
{
161+
"label": "Build EFR32 Unit Tests and Test Runner",
162+
"type": "shell",
163+
"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",
164+
"problemMatcher": []
165+
},
166+
{
167+
"label": "Rebuild EFR32 Unit Tests and Test Runner",
168+
"type": "shell",
169+
"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",
170+
"problemMatcher": []
171+
},
172+
{
173+
"label": "Clean EFR32 Unit Tests and Test Runner",
174+
"type": "shell",
175+
"command": "rm -rf out/efr32-brd*-unit-test out/linux-x64-efr32-test-runner",
176+
"problemMatcher": []
177+
},
178+
{
179+
"label": "Run EFR32 Unit Tests",
180+
"type": "shell",
181+
"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",
182+
"problemMatcher": []
183+
},
160184
{
161185
"label": "Flash EFR32 board",
162186
"type": "shell",
@@ -646,6 +670,27 @@
646670
"tizen-arm-light"
647671
]
648672
},
673+
{
674+
"type": "pickString",
675+
"id": "efr32Board",
676+
"description": "Which board",
677+
"options": [
678+
"brd2704b",
679+
"brd4316a",
680+
"brd4317a",
681+
"brd4318a",
682+
"brd4319a",
683+
"brd4186a",
684+
"brd4187a",
685+
"brd2601b",
686+
"brd4187c",
687+
"brd4186c",
688+
"brd2703a",
689+
"brd4338a",
690+
"brd2605a",
691+
"brd4343a"
692+
]
693+
},
649694
{
650695
"type": "promptString",
651696
"id": "tizenTargetDeviceAddress",

src/test_driver/efr32/README.md

+42-66
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,29 @@
1-
#CHIP EFR32 Test Driver
1+
This is a test driver for the Matter unit tests to be run on an EFR32 device. It
2+
builds a set of test binaries, each of which contains one directory of unit
3+
tests that can be flashed onto a device and run. The device is controlled using
4+
the included RPCs through the python test runner.
25

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

5-
<hr>
6-
7-
- [Introduction](#introduction)
8-
- [Building](#building)
9-
- [Running The Tests](#running-the-tests)
10-
11-
<hr>
12-
13-
<a name="introduction"></a>
14-
15-
## Introduction
16-
17-
This builds a set of test binaries which contain the unit tests and can be
18-
flashed onto a device. The device is controlled using the included RPCs, through
19-
the python test runner.
20-
21-
<a name="building"></a>
22-
23-
## Building
10+
## Prerequisites
2411

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

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

35-
- Install some additional tools(likely already present for CHIP developers):
22+
- Install some additional tools:
3623

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

39-
#Mac OS X `brew install ninja`
26+
For Mac OS: `brew install ninja`
4027

4128
- Supported hardware:
4229

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

52-
OR use GN/Ninja directly
39+
## Building and Running the Unit Tests
5340

54-
```
55-
cd ~/connectedhomeip/src/test_driver/efr32/
56-
git submodule update --init
57-
source third_party/connectedhomeip/scripts/activate.sh
58-
export SILABS_BOARD=BRD4187C
59-
gn gen out/debug
60-
ninja -C out/debug
61-
```
41+
### Building the Unit Tests
6242

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

65-
```
66-
cd ~/connectedhomeip/src/test_driver/efr32/
67-
rm -rf out/
68-
```
69-
70-
<a name="running-the-tests"></a>
45+
source scripts/activate.sh
46+
cd src/test_driver/efr32
47+
export SILABS_BOARD=BRD2703A
48+
gn gen out/debug
49+
ninja -C out/debug
7150

72-
## Running The Tests
51+
### Building and Installing the Runner
7352

74-
Build the runner using gn:
53+
The python wheels for the runner can be built and installed like this:
7554

76-
```
77-
cd <connectedhomeip>/src/test_driver/efr32
78-
gn gen out/debug
7955
ninja -C out/debug runner
80-
```
56+
pip3 install out/debug/chip_pw_test_runner_wheels/*.whl --force-reinstall
57+
58+
### Running the Unit Tests
59+
60+
The unit tests can be run using the test runner python script:
61+
62+
python -m py.pw_test_runner.pw_test_runner -d /dev/ttyACM1 -f out/debug/tests -o out.log
63+
64+
## Building and Running the Unit Tests with the build_examples Script
8165

82-
Or build using build script from the root
66+
### Building the Unit Tests
8367

84-
```
85-
cd <connectedhomeip>
86-
./scripts/build/build_examples.py --target linux-x64-pw-test-runner build
87-
```
68+
The unit tests can be built using the build_examples script. Set the appropriate
69+
board name.
8870

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

92-
Then the python wheels need to installed using pip3.
73+
### Building and Installing the Runner
9374

94-
```
95-
pip3 install out/debug/chip_pw_test_runner_wheels/*.whl
96-
```
75+
The python wheels for the runner can be built and installed like this:
9776

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

100-
```
101-
pip3 install pyserial
102-
```
80+
### Running the Unit Tests
10381

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

106-
```
107-
python -m pw_test_runner.pw_test_runner -d /dev/ttyACM1 -f out/debug/matter-silabs-device_tests.s37 -o out.log
108-
```
84+
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

src/test_driver/efr32/py/pw_test_runner/pw_test_runner.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ def run(args) -> int:
105105

106106

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

111110

112111
def main() -> int:

0 commit comments

Comments
 (0)