Skip to content

Commit afa80a5

Browse files
authoredFeb 12, 2025··
[Silabs] Fix Test Event Trigger processing (#36981)
* Refactor Test Event trigger support * fixup! Refactor Test Event trigger support * Fix ota encryption key preprocessor macro * Remove ProvisionManager header * Update submodule to the lastest * Pull matter_support changes * Add platform enable test build argument * Add silabs runner * Fix test event trigger function * Fix provision flash
1 parent d1ec1ac commit afa80a5

28 files changed

+499
-161
lines changed
 

‎.github/workflows/unit_integration_test.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- name: Checkout submodules & Bootstrap
5353
uses: ./.github/actions/checkout-submodules-and-bootstrap
5454
with:
55-
platform: linux
55+
platform: linux unit_tests
5656
bootstrap-log-name: bootstrap-logs-unittest-${{ matrix.type }}
5757
- name: Artifact suffix
5858
id: outsuffix
@@ -66,11 +66,11 @@ jobs:
6666
# TODO: If rotating_device_id is ever removed/combined, we have to cover boringssl otherwise
6767
run: |
6868
case $BUILD_TYPE in
69-
"main") GN_ARGS='';;
70-
"clang") GN_ARGS='is_clang=true';;
71-
"mbedtls") GN_ARGS='chip_crypto="mbedtls"';;
72-
"rotating_device_id") GN_ARGS='chip_crypto="boringssl" chip_enable_rotating_device_id=true';;
73-
"icd") GN_ARGS='chip_enable_icd_server=true chip_enable_icd_lit=true';;
69+
"main") GN_ARGS='chip_build_all_platform_tests=true';;
70+
"clang") GN_ARGS='is_clang=true chip_build_all_platform_tests=true';;
71+
"mbedtls") GN_ARGS='chip_crypto="mbedtls" chip_build_all_platform_tests=true';;
72+
"rotating_device_id") GN_ARGS='chip_crypto="boringssl" chip_enable_rotating_device_id=true chip_build_all_platform_tests=true';;
73+
"icd") GN_ARGS='chip_enable_icd_server=true chip_enable_icd_lit=true chip_build_all_platform_tests=true';;
7474
*) ;;
7575
esac
7676

‎.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
path = third_party/silabs/matter_support
210210
url = https://github.com/SiliconLabsSoftware/matter_support.git
211211
branch = main
212-
platforms = silabs,silabs_docker
212+
platforms = silabs,silabs_docker,unit_tests
213213
[submodule "third_party/silabs/simplicity_sdk"]
214214
path = third_party/silabs/simplicity_sdk
215215
url = https://github.com/SiliconLabs/simplicity_sdk.git

‎BUILD.gn

+10-2
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,13 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
163163
}
164164

165165
if (chip_build_tests) {
166-
deps += [ "//src:tests" ]
167-
deps += [ "//examples:example_tests" ]
166+
deps += [
167+
"//examples:example_tests",
168+
"//src:tests",
169+
170+
# Platform test group locations.
171+
"//src/platform/silabs/tests:silabs_platform_tests",
172+
]
168173

169174
if (current_os == "android" && current_toolchain == default_toolchain) {
170175
deps += [ "${chip_root}/build/chip/java/tests:java_build_test" ]
@@ -251,6 +256,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
251256
"//scripts/py_matter_yamltests:matter_yamltests.tests",
252257
"//src:tests_run",
253258
"//src/python_testing/matter_testing_infrastructure:chip-testing.tests",
259+
260+
# Platform test group locations.
261+
"//src/platform/silabs/tests:silabs_platform_tests_run",
254262
]
255263

256264
if (current_os == "linux" || current_os == "mac") {

‎build/chip/tests.gni

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ declare_args() {
2727
# Enable building tests.
2828
chip_build_tests = current_os != "freertos"
2929

30+
# Enable building all platform specific tests.
31+
# This argument should set the default value for platform specific tests build arguments.
32+
# See src/platform/silabs/tests/args.gni as an example.
33+
chip_build_all_platform_tests = false
34+
3035
# Enabling useful support functions when building using GoogleTest framework (used in unit tests and pw_fuzzer FuzzTests)
3136
# For unit tests: this should only be enabled through build_examples.py, see PR #36268
3237
chip_build_tests_googletest = false

‎examples/platform/silabs/MatterConfig.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName)
264264

265265
#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
266266
static SilabsTestEventTriggerDelegate sTestEventTriggerDelegate;
267+
sTestEventTriggerDelegate.Init(&provision.GetStorage());
268+
267269
initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
268270
#endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
269271

‎examples/platform/silabs/SiWx917/BUILD.gn

+1-28
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ declare_args() {
3232

3333
# OTA timeout in seconds
3434
ota_periodic_query_timeout_sec = 86400
35-
36-
# The EnableKey in hex string format used by TestEventTrigger command in
37-
# GeneralDiagnostics cluster. The length of the string should be 16 bytes.
38-
sl_test_event_trigger_enable_key = "00112233445566778899AABBCCDDEEFF"
3935
}
4036

4137
# Sanity check
@@ -58,29 +54,6 @@ config("chip_examples_project_config") {
5854
]
5955
}
6056

61-
config("test-event-trigger-config") {
62-
defines = [ "SL_MATTER_TEST_EVENT_TRIGGER_ENABLED" ]
63-
64-
if (is_debug) {
65-
defines += [ "SL_MATTER_TEST_EVENT_TRIGGER_ENABLE_KEY=\"${sl_test_event_trigger_enable_key}\"" ]
66-
}
67-
}
68-
69-
source_set("test-event-trigger") {
70-
sources = [
71-
"${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.cpp",
72-
"${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.h",
73-
]
74-
75-
deps = [ "${sl_provision_root}:headers" ]
76-
public_configs = [ ":test-event-trigger-config" ]
77-
public_deps = [
78-
"${chip_root}/src/app:test-event-trigger",
79-
"${chip_root}/src/lib/core",
80-
"${chip_root}/src/lib/support",
81-
]
82-
}
83-
8457
source_set("matter-shell") {
8558
defines = [ "ENABLE_CHIP_SHELL" ]
8659

@@ -200,7 +173,7 @@ source_set("siwx917-common") {
200173
]
201174

202175
if (sl_enable_test_event_trigger) {
203-
public_deps += [ ":test-event-trigger" ]
176+
public_deps += [ "${silabs_common_plat_dir}/test-event-trigger:sources" ]
204177
}
205178

206179
if (sl_enable_si70xx_sensor) {

‎examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp

-38
This file was deleted.

‎examples/platform/silabs/efr32/BUILD.gn

+1-28
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ declare_args() {
3030

3131
# OTA timeout in seconds
3232
ota_periodic_query_timeout_sec = 86400
33-
34-
# The EnableKey in hex string format used by TestEventTrigger command in
35-
# GeneralDiagnostics cluster. The length of the string should be 16 bytes.
36-
sl_test_event_trigger_enable_key = "00112233445566778899AABBCCDDEEFF"
3733
}
3834

3935
import("${silabs_common_plat_dir}/args.gni")
@@ -61,29 +57,6 @@ config("chip_examples_project_config") {
6157
]
6258
}
6359

64-
config("test-event-trigger-config") {
65-
defines = [ "SL_MATTER_TEST_EVENT_TRIGGER_ENABLED" ]
66-
67-
if (is_debug) {
68-
defines += [ "SL_MATTER_TEST_EVENT_TRIGGER_ENABLE_KEY=\"${sl_test_event_trigger_enable_key}\"" ]
69-
}
70-
}
71-
72-
source_set("test-event-trigger") {
73-
sources = [
74-
"${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.cpp",
75-
"${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.h",
76-
]
77-
78-
deps = [ "${sl_provision_root}:headers" ]
79-
public_configs = [ ":test-event-trigger-config" ]
80-
public_deps = [
81-
"${chip_root}/src/app:test-event-trigger",
82-
"${chip_root}/src/lib/core",
83-
"${chip_root}/src/lib/support",
84-
]
85-
}
86-
8760
source_set("openthread_core_config_efr32_chip_examples") {
8861
if (chip_enable_openthread) {
8962
sources = [ "project_include/OpenThreadConfig.h" ]
@@ -229,7 +202,7 @@ source_set("efr32-common") {
229202
]
230203

231204
if (sl_enable_test_event_trigger) {
232-
public_deps += [ ":test-event-trigger" ]
205+
public_deps += [ "${silabs_common_plat_dir}/test-event-trigger:sources" ]
233206
}
234207

235208
if (sl_enable_si70xx_sensor) {

‎examples/platform/silabs/provision/BUILD.gn

+1-8
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ source_set("storage") {
5353
public_deps = [ "${sl_provision_root}:headers" ]
5454

5555
if (sl_enable_test_event_trigger) {
56-
# Temporary workaround since we have duplicated configurations
57-
if (wifi_soc) {
58-
public_configs = [ "${chip_root}/examples/platform/silabs/SiWx917:test-event-trigger-config" ]
59-
} else {
60-
public_configs = [
61-
"${chip_root}/examples/platform/silabs/efr32:test-event-trigger-config",
62-
]
63-
}
56+
public_configs = [ "${chip_root}/examples/platform/silabs/test-event-trigger:test-event-trigger-config" ]
6457
}
6558
}

‎examples/platform/silabs/provision/ProvisionStorageDefault.cpp

+15-17
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
#include <sl_matter_test_event_trigger_config.h>
3535
#endif // defined(SL_MATTER_TEST_EVENT_TRIGGER_ENABLED) && (SL_MATTER_GN_BUILD == 0)
3636
#endif // NDEBUG
37-
#ifdef OTA_ENCRYPTION_ENABLE
37+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
3838
#include <platform/silabs/multi-ota/OtaTlvEncryptionKey.h>
39-
#endif // OTA_ENCRYPTION_ENABLE
39+
#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION
4040
#ifndef SLI_SI91X_MCU_INTERFACE
4141
#include <psa/crypto.h>
4242
#endif
@@ -474,7 +474,7 @@ CHIP_ERROR Storage::GetCertificationDeclaration(MutableByteSpan & value)
474474
err = ReadFileByOffset(*this, "GetDeviceAttestationCert", SL_CREDENTIALS_CD_OFFSET, SL_CREDENTIALS_CD_SIZE, value);
475475
}
476476
#endif
477-
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
477+
#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS
478478
if (CHIP_ERROR_NOT_FOUND == err)
479479
{
480480
// Example CD
@@ -502,7 +502,7 @@ CHIP_ERROR Storage::GetProductAttestationIntermediateCert(MutableByteSpan & valu
502502
err = ReadFileByOffset(*this, "GetDeviceAttestationCert", SL_CREDENTIALS_PAI_OFFSET, SL_CREDENTIALS_PAI_SIZE, value);
503503
}
504504
#endif
505-
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
505+
#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS
506506
if (CHIP_ERROR_NOT_FOUND == err)
507507
{
508508
// Example PAI
@@ -530,7 +530,7 @@ CHIP_ERROR Storage::GetDeviceAttestationCert(MutableByteSpan & value)
530530
err = ReadFileByOffset(*this, "GetDeviceAttestationCert", SL_CREDENTIALS_DAC_OFFSET, SL_CREDENTIALS_DAC_SIZE, value);
531531
}
532532
#endif
533-
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
533+
#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS
534534
if (CHIP_ERROR_NOT_FOUND == err)
535535
{
536536
// Example DAC
@@ -569,7 +569,7 @@ CHIP_ERROR Storage::SignWithDeviceAttestationKey(const ByteSpan & message, Mutab
569569
}
570570
else
571571
{
572-
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
572+
#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS
573573
// Example DAC key
574574
return Examples::GetExampleDACProvider()->SignWithDeviceAttestationKey(message, signature);
575575
#else
@@ -605,7 +605,7 @@ CHIP_ERROR Storage::SignWithDeviceAttestationKey(const ByteSpan & message, Mutab
605605
AttestationKey key(kid);
606606
err = key.SignMessage(message, signature);
607607
}
608-
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
608+
#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS
609609
else
610610
{
611611
// Example DAC key
@@ -663,23 +663,18 @@ CHIP_ERROR Storage::GetProvisionRequest(bool & value)
663663
return SilabsConfig::ReadConfigValue(SilabsConfig::kConfigKey_Provision_Request, value);
664664
}
665665

666-
#if OTA_ENCRYPTION_ENABLE
666+
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
667667
CHIP_ERROR Storage::SetOtaTlvEncryptionKey(const ByteSpan & value)
668668
{
669669
chip::DeviceLayer::Silabs::OtaTlvEncryptionKey::OtaTlvEncryptionKey key;
670670
ReturnErrorOnFailure(key.Import(value.data(), value.size()));
671671
return SilabsConfig::WriteConfigValue(SilabsConfig::kOtaTlvEncryption_KeyId, key.GetId());
672672
}
673-
#endif // OTA_ENCRYPTION_ENABLE
673+
#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION
674674

675-
/**
676-
* @brief Reads the test event trigger key from NVM. If the key isn't present, returns default value if defined.
677-
*
678-
* @param[out] keySpan output buffer. Must be at least large enough for 16 bytes (ken length)
679-
* @return CHIP_ERROR
680-
*/
681675
CHIP_ERROR Storage::GetTestEventTriggerKey(MutableByteSpan & keySpan)
682676
{
677+
#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
683678
constexpr size_t kEnableKeyLength = 16; // Expected byte size of the EnableKey
684679
CHIP_ERROR err = CHIP_NO_ERROR;
685680
size_t keyLength = 0;
@@ -689,7 +684,7 @@ CHIP_ERROR Storage::GetTestEventTriggerKey(MutableByteSpan & keySpan)
689684
err = SilabsConfig::ReadConfigValueBin(SilabsConfig::kConfigKey_Test_Event_Trigger_Key, keySpan.data(), kEnableKeyLength,
690685
keyLength);
691686
#ifndef NDEBUG
692-
#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
687+
#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLE_KEY
693688
if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
694689
{
695690

@@ -702,11 +697,14 @@ CHIP_ERROR Storage::GetTestEventTriggerKey(MutableByteSpan & keySpan)
702697
}
703698
err = CHIP_NO_ERROR;
704699
}
705-
#endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
700+
#endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLE_KEY
706701
#endif // NDEBUG
707702

708703
keySpan.reduce_size(kEnableKeyLength);
709704
return err;
705+
#else
706+
return CHIP_ERROR_NOT_IMPLEMENTED;
707+
#endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
710708
}
711709

712710
} // namespace Provision

0 commit comments

Comments
 (0)
Please sign in to comment.