Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EFR32 unit test #11073

Merged
merged 1 commit into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions examples/common/pigweed/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ pw_source_set("system_rpc_server") {
sources = [ "system_rpc_server.cc" ]

deps = [
"$dir_pw_rpc/system_server:facade",
dir_pw_log,
]

public_deps = [
"$dir_pw_hdlc:pw_rpc",
"$dir_pw_hdlc:rpc_channel_output",
"$dir_pw_rpc/system_server:facade",
"$dir_pw_stream:sys_io_stream",
dir_pw_log,
]

public_configs = [ ":default_config" ]
Expand Down
6 changes: 3 additions & 3 deletions integrations/cloudbuild/smoke-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ steps:
args:
- >-
./scripts/build/build_examples.py --enable-flashbundle
--target-glob '*-nrf52840-{lock,light}' build --create-archives
--target-glob '*-nrf52840-{lock,light}*' build --create-archives
/workspace/artifacts/
waitFor:
- Bootstrap
Expand All @@ -52,8 +52,8 @@ steps:
args:
- >-
./scripts/build/build_examples.py --enable-flashbundle
--target-glob '*-brd4161a-{lock,light}' build --create-archives
/workspace/artifacts/
--target-glob '*-brd4161a-{lock,light,unit-test}*' build
--create-archives /workspace/artifacts/
waitFor:
- Bootstrap
- NRFConnect
Expand Down
1 change: 1 addition & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def Efr32Targets():

yield efr_target.Extend('window-covering', app=Efr32App.WINDOW_COVERING)
yield efr_target.Extend('lock', app=Efr32App.LOCK)
yield efr_target.Extend('unit-test', app=Efr32App.UNIT_TEST)

rpc_aware_targets = [
efr_target.Extend('light', app=Efr32App.LIGHT),
Expand Down
18 changes: 17 additions & 1 deletion scripts/build/builders/efr32.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Efr32App(Enum):
LIGHT = auto()
LOCK = auto()
WINDOW_COVERING = auto()
UNIT_TEST = auto()

def ExampleName(self):
if self == Efr32App.LIGHT:
Expand All @@ -40,6 +41,8 @@ def AppNamePrefix(self):
return 'chip-efr32-lock-example'
elif self == Efr32App.WINDOW_COVERING:
return 'chip-efr32-window-example'
elif self == Efr32App.UNIT_TEST:
return 'chip-efr32-device_tests'
else:
raise Exception('Unknown app type: %r' % self)

Expand All @@ -50,9 +53,17 @@ def FlashBundleName(self):
return 'lock_app.flashbundle.txt'
elif self == Efr32App.WINDOW_COVERING:
return 'window_app.flashbundle.txt'
elif self == Efr32App.UNIT_TEST:
return 'efr32_device_tests.flashbundle.txt'
else:
raise Exception('Unknown app type: %r' % self)

def BuildRoot(self, root):
if self == Efr32App.UNIT_TEST:
return os.path.join(root, 'src', 'test_driver', 'efr32')
else:
return os.path.join(root, 'examples', self.ExampleName(), 'efr32')


class Efr32Board(Enum):
BRD4161A = 1
Expand All @@ -71,7 +82,7 @@ def __init__(self,
board: Efr32Board = Efr32Board.BRD4161A,
enable_rpcs: bool = False):
super(Efr32Builder, self).__init__(
root=os.path.join(root, 'examples', app.ExampleName(), 'efr32'),
root=app.BuildRoot(root),
runner=runner)
self.app = app
self.board = board
Expand All @@ -93,6 +104,11 @@ def build_outputs(self):
'%s.out.map' % self.app.AppNamePrefix()),
}

if self.app == Efr32App.UNIT_TEST:
# Include test runner python wheels
items["chip_nl_test_runner_wheels"] = os.path.join(
self.output_dir, 'chip_nl_test_runner_wheels')

# Figure out flash bundle files and build accordingly
with open(os.path.join(self.output_dir, self.app.FlashBundleName())) as f:
for line in f.readlines():
Expand Down
1 change: 1 addition & 0 deletions scripts/build/testdata/all_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ android-x86-chip-tool
efr32-brd4161a-light
efr32-brd4161a-light-rpc
efr32-brd4161a-lock
efr32-brd4161a-unit-test
efr32-brd4161a-window-covering
esp32-c3devkit-all-clusters
esp32-devkitc-all-clusters
Expand Down
6 changes: 6 additions & 0 deletions scripts/build/testdata/build_all_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/efr32 '
# Generating efr32-brd4161a-lock
gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-lock

# Generating efr32-brd4161a-unit-test
gn gen --check --fail-on-unused-args --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-unit-test

# Generating efr32-brd4161a-window-covering
gn gen --check --fail-on-unused-args --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-window-covering

Expand Down Expand Up @@ -546,6 +549,9 @@ ninja -C {out}/efr32-brd4161a-light-rpc
# Building efr32-brd4161a-lock
ninja -C {out}/efr32-brd4161a-lock

# Building efr32-brd4161a-unit-test
ninja -C {out}/efr32-brd4161a-unit-test

# Building efr32-brd4161a-window-covering
ninja -C {out}/efr32-brd4161a-window-covering

Expand Down
1 change: 1 addition & 0 deletions scripts/build/testdata/glob_star_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ android-x86-chip-tool
efr32-brd4161a-light
efr32-brd4161a-light-rpc
efr32-brd4161a-lock
efr32-brd4161a-unit-test
efr32-brd4161a-window-covering
esp32-c3devkit-all-clusters
esp32-devkitc-all-clusters
Expand Down
7 changes: 5 additions & 2 deletions src/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ if (chip_build_tests) {
chip_test_group("tests") {
deps = [
"${chip_root}/src/access/tests",
"${chip_root}/src/app/tests",
"${chip_root}/src/crypto/tests",
"${chip_root}/src/inet/tests",
"${chip_root}/src/lib/asn1/tests",
Expand Down Expand Up @@ -74,6 +73,8 @@ if (chip_build_tests) {

if (chip_device_platform != "efr32") {
deps += [
# TODO(#10447): App test has HF on EFR32.
"${chip_root}/src/app/tests",
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
"${chip_root}/src/credentials/tests",
"${chip_root}/src/lib/support/tests",
"${chip_root}/src/protocols/secure_channel/tests",
Expand All @@ -97,7 +98,9 @@ if (chip_build_tests) {

# On nrfconnect, the controller tests run into
# https://github.com/project-chip/connectedhomeip/issues/9630
if (chip_device_platform != "nrfconnect") {
if (chip_device_platform != "nrfconnect" &&
chip_device_platform != "efr32") {
rgoliver marked this conversation as resolved.
Show resolved Hide resolved
# TODO(#10447): Controller test has HF on EFR32.
deps += [ "${chip_root}/src/controller/tests" ]
}

Expand Down
13 changes: 4 additions & 9 deletions src/app/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,19 @@ chip_test_suite("tests") {
"TestBuilderParser.cpp",
"TestCHIPDeviceCallbacksMgr.cpp",
"TestClusterInfo.cpp",
"TestCommandInteraction.cpp",
"TestCommandPathParams.cpp",
"TestDataModelSerialization.cpp",
"TestEventLogging.cpp",
"TestEventPathParams.cpp",
"TestInteractionModelEngine.cpp",
"TestMessageDef.cpp",
"TestReadInteraction.cpp",
"TestReportingEngine.cpp",
"TestStatusResponseMessage.cpp",
"TestWriteInteraction.cpp",
]

if (chip_device_platform != "efr32") {
test_sources += [
"TestCommandInteraction.cpp",
"TestReadInteraction.cpp",
"TestReportingEngine.cpp",
"TestWriteInteraction.cpp",
]
}

cflags = [ "-Wconversion" ]

public_deps = [
Expand Down
6 changes: 5 additions & 1 deletion src/messaging/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ chip_test_suite("tests") {
sources = [
"TestExchangeMgr.cpp",
"TestMessagingLayer.h",
"TestReliableMessageProtocol.cpp",
]

if (chip_device_platform != "efr32") {
# TODO(#10447): Test has HF on EFR32.
sources += [ "TestReliableMessageProtocol.cpp" ]
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
}

cflags = [ "-Wconversion" ]

public_deps = [
Expand Down
1 change: 1 addition & 0 deletions src/test_driver/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ group("efr32") {
deps = [
":efr32_device_tests",
"${efr32_project_dir}/py:nl_test_runner.install",
"${efr32_project_dir}/py:nl_test_runner_wheel",
]
}

Expand Down
6 changes: 6 additions & 0 deletions src/test_driver/efr32/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ pw_python_package("nl_test_runner") {
"${chip_root}/src/test_driver/efr32:nl_test_service.python",
]
}

pw_mirror_tree("nl_test_runner_wheel") {
path_data_keys = [ "pw_python_package_wheels" ]
deps = [ ":nl_test_runner.wheel" ]
directory = "$root_out_dir/chip_nl_test_runner_wheels"
}
10 changes: 5 additions & 5 deletions src/test_driver/efr32/py/nl_test_runner/nl_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ def read(): return serial_device.read(8192)

def runner(client) -> int:
""" Run the tests"""
status, result = client.client.channel(
1).rpcs.chip.rpc.NlTest.Run(pw_rpc_timeout_s=120)

if not status.ok():
def on_error_callback(call_object, error):
raise Exception("Error running test RPC: {}".format(status))

rpc = client.client.channel(1).rpcs.chip.rpc.NlTest.Run
invoke = rpc.invoke(rpc.request(), on_error=on_error_callback)

total_failed = 0
total_run = 0
for streamed_data in result:
for streamed_data in invoke.get_responses():
if streamed_data.HasField("test_suite_start"):
print("\n{}".format(
colors.HEADER + streamed_data.test_suite_start.suite_name) + colors.ENDC)
Expand Down