Skip to content

Commit 9e1a79e

Browse files
committed
Fixed the build process for the test runner, updated the test runner to use glob, and updated the test runner to use the flash_image parameter for directories
1 parent 25ebd41 commit 9e1a79e

File tree

7 files changed

+47
-36
lines changed

7 files changed

+47
-36
lines changed

scripts/build/builders/efr32.py

+5
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,11 @@ def build_outputs(self):
270270

271271
if self.app == Efr32App.UNIT_TEST:
272272
# Include test runner python wheels
273+
for root, dirs, files in os.walk(os.path.join(self.output_dir, 'chip_pw_test_runner_wheels')):
274+
for file in files:
275+
items["chip_pw_test_runner_wheels/" +
276+
file] = os.path.join(root, file)
277+
# TODO [PW_MIGRATION]: remove the nl wheels once transition away from nlunit-test is completed
273278
for root, dirs, files in os.walk(os.path.join(self.output_dir, 'chip_nl_test_runner_wheels')):
274279
for file in files:
275280
items["chip_nl_test_runner_wheels/" +

scripts/build/builders/host.py

+1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def OutputNames(self):
215215
elif self == HostApp.PYTHON_BINDINGS:
216216
yield 'controller/python' # Directory containing WHL files
217217
elif self == HostApp.EFR32_TEST_RUNNER:
218+
yield 'chip_pw_test_runner_wheels'
218219
yield 'chip_nl_test_runner_wheels'
219220
elif self == HostApp.TV_CASTING:
220221
yield 'chip-tv-casting-app'

src/BUILD.gn

+15-9
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,23 @@ if (chip_build_tests) {
5959
"${chip_root}/src/access/tests",
6060
"${chip_root}/src/crypto/tests",
6161
"${chip_root}/src/inet/tests",
62-
"${chip_root}/src/lib/address_resolve/tests",
63-
"${chip_root}/src/lib/asn1/tests",
64-
"${chip_root}/src/lib/core/tests",
65-
"${chip_root}/src/messaging/tests",
66-
"${chip_root}/src/protocols/bdx/tests",
67-
"${chip_root}/src/protocols/interaction_model/tests",
68-
"${chip_root}/src/protocols/user_directed_commissioning/tests",
69-
"${chip_root}/src/transport/retransmit/tests",
70-
"${chip_root}/src/app/icd/server/tests",
7162
]
7263

64+
# Skip on efr32 due to flash limitations.
65+
if (chip_device_platform != "efr32") {
66+
tests += [
67+
"${chip_root}/src/lib/address_resolve/tests",
68+
"${chip_root}/src/lib/asn1/tests",
69+
"${chip_root}/src/lib/core/tests",
70+
"${chip_root}/src/messaging/tests",
71+
"${chip_root}/src/protocols/bdx/tests",
72+
"${chip_root}/src/protocols/interaction_model/tests",
73+
"${chip_root}/src/protocols/user_directed_commissioning/tests",
74+
"${chip_root}/src/transport/retransmit/tests",
75+
"${chip_root}/src/app/icd/server/tests",
76+
]
77+
}
78+
7379
# Skip DNSSD tests for Mbed platform due to flash memory size limitations
7480
if (current_os != "mbed") {
7581
tests += [

src/test_driver/efr32/BUILD.gn

+3
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ group("efr32") {
130130

131131
group("runner") {
132132
deps = [
133+
"${efr32_project_dir}/py:pw_test_runner.install",
134+
"${efr32_project_dir}/py:pw_test_runner_wheel",
135+
# TODO [PW_MIGRATION]: remove the following when transition from nlunit-test is complete.
133136
"${efr32_project_dir}/py:nl_test_runner.install",
134137
"${efr32_project_dir}/py:nl_test_runner_wheel",
135138
]

src/test_driver/efr32/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#CHIP EFR32 Test Driver
22

3-
This builds and runs the NLUnitTest on the efr32 device
3+
This builds and runs the PW Unit Tests on the efr32 device
44

55
<hr>
66

@@ -14,7 +14,7 @@ This builds and runs the NLUnitTest on the efr32 device
1414

1515
## Introduction
1616

17-
This builds a test binary which contains the NLUnitTests and can be flashed onto
17+
This builds a test binary which contains the pw_unit_test and can be flashed onto
1818
a device. The device is controlled using the included RPCs, through the python
1919
test runner.
2020

@@ -99,7 +99,7 @@ Or build using build script from the root
9999

100100
```
101101
cd <connectedhomeip>
102-
./scripts/build/build_examples.py --target linux-x64-nl-test-runner build
102+
./scripts/build/build_examples.py --target linux-x64-pw-test-runner build
103103
```
104104

105105
The runner will be installed into the venv and python wheels will be packaged in
@@ -108,7 +108,7 @@ the output folder for deploying.
108108
Then the python wheels need to installed using pip3.
109109

110110
```
111-
pip3 install out/debug/chip_nl_test_runner_wheels/*.whl
111+
pip3 install out/debug/chip_pw_test_runner_wheels/*.whl
112112
```
113113

114114
Other python libraries may need to be installed such as
@@ -117,8 +117,8 @@ Other python libraries may need to be installed such as
117117
pip3 install pyserial
118118
```
119119

120-
- To run the tests:
120+
To run all tests:
121121

122122
```
123-
python -m nl_test_runner.nl_test_runner -d /dev/ttyACM1 -f out/debug/matter-silabs-device_tests.s37 -o out.log
123+
python -m pw_test_runner.pw_test_runner -d /dev/ttyACM1 -f out/debug -o out.log
124124
```

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

+16-20
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#
1717

1818
import argparse
19+
import glob
1920
import logging
2021
import os
2122
import subprocess
@@ -60,12 +61,7 @@ def _parse_args():
6061
parser.add_argument(
6162
"-f",
6263
"--flash_image",
63-
help="a firmware image which will be flashed berfore runnning the test",
64-
)
65-
parser.add_argument(
66-
"-y",
67-
"--flash_directory",
68-
help="A directory containing image files, each of which will be flashed and then run.",
64+
help="A firmware image which will be flashed berfore runnning the test. Or a directory containing firmware images, each of which will be flashed and then run.",
6965
)
7066
parser.add_argument(
7167
"-o",
@@ -80,7 +76,7 @@ def _parse_args():
8076
return parser.parse_args()
8177

8278

83-
def flash_device(device: str, flash_image: str, **kwargs):
79+
def flash_device(device: str, flash_image: str):
8480
"""flashes the EFR32 device using commander"""
8581
err = subprocess.call(
8682
["commander", "flash", "--device", "EFR32", flash_image])
@@ -108,31 +104,31 @@ def run(args) -> int:
108104
return len(test_records.failing_tests)
109105

110106

111-
def list_images(flash_directory: str, **kwargs) -> list[str]:
112-
filenames: list[str] = os.listdir(flash_directory)
113-
# filenames = filter(lambda x: not x.endswith('.map'), filenames)
107+
def list_images(flash_directory: str) -> list[str]:
108+
filenames: list[str] = glob.glob(os.path.join(flash_directory, "*.s37"))
114109
return list(map(lambda x: os.path.join(flash_directory, x), filenames))
115110

116111

117112
def main() -> int:
118113
args = _parse_args()
119114

120-
images: list[str] = None
121-
if args.flash_directory:
122-
images = list_images(**vars(args))
123-
if not images:
124-
raise Exception(f"No images found in `{args.flash_directory}`")
125-
elif args.flash_image:
126-
images = [args.flash_image]
115+
failures = 0
116+
if args.flash_image:
117+
if os.path.isdir(args.flash_image):
118+
images = list_images(args.flash_image)
119+
if not images:
120+
raise Exception(f"No images found in `{args.flash_image}`")
121+
elif os.path.isdir(args.flash_image):
122+
images = [args.flash_image]
123+
else:
124+
raise Exception(f"File or directory not found `{args.flash_image}`")
127125

128-
failures: int = 0
129-
if images:
130126
for image in images:
131127
flash_device(args.device, image)
132128
time.sleep(1) # Give time for device to boot
133129

134130
failures += run(args)
135-
else: # No image provided. Just run.
131+
else: # No image provided. Just run what's on the device.
136132
failures += run(args)
137133

138134
return failures

src/test_driver/efr32/py/setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
[metadata]
15-
name = nl_test_runner
15+
name = pw_test_runner
1616
version = 0.0.1
1717

1818
[options]

0 commit comments

Comments
 (0)