-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Proposed changes to split tests into separate binaries for efr32 [Version 2] #33790
Changes from all commits
25ebd41
9e1a79e
6aea2b2
c26ff71
8a40d80
570763a
939e516
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,12 +12,28 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
enable_efr32_build_per_testsource = true #++++ TODO: Figure out how to enable things based on `chip_device_platform == "efr32"` which is not currently in scope. | ||
|
||
import("//build_overrides/build.gni") | ||
import("//build_overrides/chip.gni") | ||
if (enable_efr32_build_per_testsource) { | ||
import("//build_overrides/efr32_sdk.gni") # Defines efr32_sdk_build_root | ||
import("//build_overrides/nlunit_test.gni") # Defines nlunit_test_root | ||
} | ||
|
||
import("${chip_root}/build/chip/chip_test.gni") | ||
import("${chip_root}/build/chip/tests.gni") | ||
import("${dir_pw_unit_test}/test.gni") | ||
if (enable_efr32_build_per_testsource) { | ||
import("${efr32_sdk_build_root}/efr32_sdk.gni") | ||
import("${efr32_sdk_build_root}/silabs_executable.gni") | ||
#import("$dir_pw_protobuf_compiler/proto.gni") | ||
|
||
#++++ TODO: Figure out how to get access to these variables from src/test_driver/efr32/BUILD.gn so we don't have to set them explicitly here. | ||
examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" | ||
examples_common_plat_dir = "${chip_root}/examples/platform/silabs" | ||
#efr32_project_dir = "${chip_root}/src/test_driver/efr32" | ||
} | ||
|
||
assert(chip_build_tests) | ||
|
||
|
@@ -99,7 +115,7 @@ template("chip_test_suite") { | |
public_deps += [ "${chip_root}/src/platform/logging:force_stdio" ] | ||
} | ||
} | ||
if (chip_link_tests) { | ||
if (chip_link_tests || enable_efr32_build_per_testsource) { #++++ Temporary workaround rather than changing `chip_link_tests` and `chip_build_tests` in `tests.gni` | ||
tests = [] | ||
|
||
if (defined(invoker.test_sources)) { | ||
|
@@ -111,6 +127,82 @@ template("chip_test_suite") { | |
_test_output_dir = invoker.output_dir | ||
} | ||
|
||
if (enable_efr32_build_per_testsource) { | ||
|
||
# Since target_name is usually "tests", we need a unique name to use in the executable target. | ||
if (defined(invoker.output_name)) { | ||
# Get it from the suite's output_name. | ||
_unique_suite_name = invoker.output_name | ||
} else { | ||
# Some test suites don't have output_name defined. Use the first source file. | ||
_unique_suite_name = string_replace(string_join("-", invoker.test_sources), ".cpp", "") | ||
} | ||
|
||
silabs_executable("efr32_device_tests--${_unique_suite_name}--${_test_name}") { | ||
output_name = "matter-silabs-device_tests--${_unique_suite_name}--${_test_name}.out" | ||
|
||
defines = [ "PW_RPC_ENABLED" ] | ||
sources = [ | ||
"${chip_root}/examples/common/pigweed/RpcService.cpp", | ||
"${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", | ||
"${chip_root}/src/test_driver/efr32/src/main.cpp", #++++ replace absolute path | ||
"${examples_common_plat_dir}/PigweedLogger.cpp", | ||
"${examples_common_plat_dir}/heap_4_silabs.c", | ||
"${examples_common_plat_dir}/syscalls_stubs.cpp", | ||
"${examples_plat_dir}/uart.cpp", | ||
] | ||
|
||
deps = [ | ||
#++++ DEBUG: Disabled code that was used for testing an alternative implementaiton. | ||
# "${chip_root}/src/test_driver/efr32:nl_test_service.nanopb_rpc", #++++ replace absolute path | ||
# "${chip_root}/src/test_driver/efr32:sdk", #++++ replace absolute path | ||
#":nl_test_service--${_unique_suite_name}--${_test_name}.nanopb_rpc", | ||
#":sdk--${_unique_suite_name}--${_test_name}", | ||
|
||
"$dir_pw_unit_test:rpc_service", | ||
"${chip_root}/config/efr32/lib/pw_rpc:pw_rpc", | ||
"${chip_root}/examples/common/pigweed:system_rpc_server", | ||
"${chip_root}/src/lib", | ||
"${chip_root}/src/lib/support:pw_tests_wrapper", | ||
"${chip_root}/src/lib/support:testing_nlunit", | ||
"${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs", | ||
"${nlunit_test_root}:nlunit-test", | ||
] | ||
|
||
# OpenThread Settings | ||
if (chip_enable_openthread) { | ||
deps += [ | ||
"${chip_root}/third_party/openthread:openthread", | ||
"${chip_root}/third_party/openthread:openthread-platform", | ||
"${examples_plat_dir}:efr-matter-shell", | ||
] | ||
} | ||
|
||
# Attestation Credentials | ||
deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] | ||
|
||
# Factory Data Provider | ||
if (use_efr32_factory_data_provider) { | ||
deps += [ "${examples_plat_dir}:silabs-factory-data-provider" ] | ||
} | ||
|
||
deps += pw_build_LINK_DEPS | ||
|
||
include_dirs = [ "${chip_root}/examples/common/pigweed/efr32" ] | ||
|
||
ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" | ||
|
||
inputs = [ ldscript ] | ||
|
||
ldflags = [ | ||
"-T" + rebase_path(ldscript, root_build_dir), | ||
"-Wl,--no-warn-rwx-segment", | ||
] | ||
|
||
output_dir = root_out_dir | ||
} | ||
} | ||
|
||
pw_test(_test_name) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
forward_variables_from(invoker, | ||
[ | ||
|
@@ -122,6 +214,9 @@ template("chip_test_suite") { | |
public_deps += [ ":${_suite_name}.lib" ] | ||
sources = [ _test ] | ||
output_dir = _test_output_dir | ||
if (enable_efr32_build_per_testsource) { | ||
deps = [ ":efr32_device_tests--${_unique_suite_name}--${_test_name}" ] | ||
} | ||
} | ||
tests += [ _test_name ] | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bunch of stuff needs importing into here since it is used by
silabs_executable
. Eventually I'll find a cleaner way to do this.