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

[Silabs] Fix Test Event Trigger processing #36981

Merged
merged 11 commits into from
Feb 12, 2025
12 changes: 6 additions & 6 deletions .github/workflows/unit_integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Checkout submodules & Bootstrap
uses: ./.github/actions/checkout-submodules-and-bootstrap
with:
platform: linux
platform: linux unit_tests
bootstrap-log-name: bootstrap-logs-unittest-${{ matrix.type }}
- name: Artifact suffix
id: outsuffix
Expand All @@ -66,11 +66,11 @@ jobs:
# TODO: If rotating_device_id is ever removed/combined, we have to cover boringssl otherwise
run: |
case $BUILD_TYPE in
"main") GN_ARGS='';;
"clang") GN_ARGS='is_clang=true';;
"mbedtls") GN_ARGS='chip_crypto="mbedtls"';;
"rotating_device_id") GN_ARGS='chip_crypto="boringssl" chip_enable_rotating_device_id=true';;
"icd") GN_ARGS='chip_enable_icd_server=true chip_enable_icd_lit=true';;
"main") GN_ARGS='chip_build_all_platform_tests=true';;
"clang") GN_ARGS='is_clang=true chip_build_all_platform_tests=true';;
"mbedtls") GN_ARGS='chip_crypto="mbedtls" chip_build_all_platform_tests=true';;
"rotating_device_id") GN_ARGS='chip_crypto="boringssl" chip_enable_rotating_device_id=true chip_build_all_platform_tests=true';;
"icd") GN_ARGS='chip_enable_icd_server=true chip_enable_icd_lit=true chip_build_all_platform_tests=true';;
*) ;;
esac

Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
path = third_party/silabs/matter_support
url = https://github.com/SiliconLabsSoftware/matter_support.git
branch = main
platforms = silabs,silabs_docker
platforms = silabs,silabs_docker,unit_tests
[submodule "third_party/silabs/simplicity_sdk"]
path = third_party/silabs/simplicity_sdk
url = https://github.com/SiliconLabs/simplicity_sdk.git
Expand Down
12 changes: 10 additions & 2 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,13 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
}

if (chip_build_tests) {
deps += [ "//src:tests" ]
deps += [ "//examples:example_tests" ]
deps += [
"//examples:example_tests",
"//src:tests",

# Platform test group locations.
"//src/platform/silabs/tests:silabs_platform_tests",
]

if (current_os == "android" && current_toolchain == default_toolchain) {
deps += [ "${chip_root}/build/chip/java/tests:java_build_test" ]
Expand Down Expand Up @@ -251,6 +256,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
"//scripts/py_matter_yamltests:matter_yamltests.tests",
"//src:tests_run",
"//src/python_testing/matter_testing_infrastructure:chip-testing.tests",

# Platform test group locations.
"//src/platform/silabs/tests:silabs_platform_tests_run",
]

if (current_os == "linux" || current_os == "mac") {
Expand Down
5 changes: 5 additions & 0 deletions build/chip/tests.gni
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ declare_args() {
# Enable building tests.
chip_build_tests = current_os != "freertos"

# Enable building all platform specific tests.
# This argument should set the default value for platform specific tests build arguments.
# See src/platform/silabs/tests/args.gni as an example.
chip_build_all_platform_tests = false

# Enabling useful support functions when building using GoogleTest framework (used in unit tests and pw_fuzzer FuzzTests)
# For unit tests: this should only be enabled through build_examples.py, see PR #36268
chip_build_tests_googletest = false
Expand Down
2 changes: 2 additions & 0 deletions examples/platform/silabs/MatterConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName)

#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
static SilabsTestEventTriggerDelegate sTestEventTriggerDelegate;
sTestEventTriggerDelegate.Init(&provision.GetStorage());

initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
#endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLED

Expand Down
29 changes: 1 addition & 28 deletions examples/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ declare_args() {

# OTA timeout in seconds
ota_periodic_query_timeout_sec = 86400

# The EnableKey in hex string format used by TestEventTrigger command in
# GeneralDiagnostics cluster. The length of the string should be 16 bytes.
sl_test_event_trigger_enable_key = "00112233445566778899AABBCCDDEEFF"
}

# Sanity check
Expand All @@ -58,29 +54,6 @@ config("chip_examples_project_config") {
]
}

config("test-event-trigger-config") {
defines = [ "SL_MATTER_TEST_EVENT_TRIGGER_ENABLED" ]

if (is_debug) {
defines += [ "SL_MATTER_TEST_EVENT_TRIGGER_ENABLE_KEY=\"${sl_test_event_trigger_enable_key}\"" ]
}
}

source_set("test-event-trigger") {
sources = [
"${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.cpp",
"${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.h",
]

deps = [ "${sl_provision_root}:headers" ]
public_configs = [ ":test-event-trigger-config" ]
public_deps = [
"${chip_root}/src/app:test-event-trigger",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
]
}

source_set("matter-shell") {
defines = [ "ENABLE_CHIP_SHELL" ]

Expand Down Expand Up @@ -200,7 +173,7 @@ source_set("siwx917-common") {
]

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

if (sl_enable_si70xx_sensor) {
Expand Down
38 changes: 0 additions & 38 deletions examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp

This file was deleted.

29 changes: 1 addition & 28 deletions examples/platform/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ declare_args() {

# OTA timeout in seconds
ota_periodic_query_timeout_sec = 86400

# The EnableKey in hex string format used by TestEventTrigger command in
# GeneralDiagnostics cluster. The length of the string should be 16 bytes.
sl_test_event_trigger_enable_key = "00112233445566778899AABBCCDDEEFF"
}

import("${silabs_common_plat_dir}/args.gni")
Expand Down Expand Up @@ -61,29 +57,6 @@ config("chip_examples_project_config") {
]
}

config("test-event-trigger-config") {
defines = [ "SL_MATTER_TEST_EVENT_TRIGGER_ENABLED" ]

if (is_debug) {
defines += [ "SL_MATTER_TEST_EVENT_TRIGGER_ENABLE_KEY=\"${sl_test_event_trigger_enable_key}\"" ]
}
}

source_set("test-event-trigger") {
sources = [
"${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.cpp",
"${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.h",
]

deps = [ "${sl_provision_root}:headers" ]
public_configs = [ ":test-event-trigger-config" ]
public_deps = [
"${chip_root}/src/app:test-event-trigger",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
]
}

source_set("openthread_core_config_efr32_chip_examples") {
if (chip_enable_openthread) {
sources = [ "project_include/OpenThreadConfig.h" ]
Expand Down Expand Up @@ -229,7 +202,7 @@ source_set("efr32-common") {
]

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

if (sl_enable_si70xx_sensor) {
Expand Down
9 changes: 1 addition & 8 deletions examples/platform/silabs/provision/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ source_set("storage") {
public_deps = [ "${sl_provision_root}:headers" ]

if (sl_enable_test_event_trigger) {
# Temporary workaround since we have duplicated configurations
if (wifi_soc) {
public_configs = [ "${chip_root}/examples/platform/silabs/SiWx917:test-event-trigger-config" ]
} else {
public_configs = [
"${chip_root}/examples/platform/silabs/efr32:test-event-trigger-config",
]
}
public_configs = [ "${chip_root}/examples/platform/silabs/test-event-trigger:test-event-trigger-config" ]
}
}
32 changes: 15 additions & 17 deletions examples/platform/silabs/provision/ProvisionStorageDefault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
#include <sl_matter_test_event_trigger_config.h>
#endif // defined(SL_MATTER_TEST_EVENT_TRIGGER_ENABLED) && (SL_MATTER_GN_BUILD == 0)
#endif // NDEBUG
#ifdef OTA_ENCRYPTION_ENABLE
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
#include <platform/silabs/multi-ota/OtaTlvEncryptionKey.h>
#endif // OTA_ENCRYPTION_ENABLE
#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION
#ifndef SLI_SI91X_MCU_INTERFACE
#include <psa/crypto.h>
#endif
Expand Down Expand Up @@ -474,7 +474,7 @@ CHIP_ERROR Storage::GetCertificationDeclaration(MutableByteSpan & value)
err = ReadFileByOffset(*this, "GetDeviceAttestationCert", SL_CREDENTIALS_CD_OFFSET, SL_CREDENTIALS_CD_SIZE, value);
}
#endif
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS
if (CHIP_ERROR_NOT_FOUND == err)
{
// Example CD
Expand Down Expand Up @@ -502,7 +502,7 @@ CHIP_ERROR Storage::GetProductAttestationIntermediateCert(MutableByteSpan & valu
err = ReadFileByOffset(*this, "GetDeviceAttestationCert", SL_CREDENTIALS_PAI_OFFSET, SL_CREDENTIALS_PAI_SIZE, value);
}
#endif
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS
if (CHIP_ERROR_NOT_FOUND == err)
{
// Example PAI
Expand Down Expand Up @@ -530,7 +530,7 @@ CHIP_ERROR Storage::GetDeviceAttestationCert(MutableByteSpan & value)
err = ReadFileByOffset(*this, "GetDeviceAttestationCert", SL_CREDENTIALS_DAC_OFFSET, SL_CREDENTIALS_DAC_SIZE, value);
}
#endif
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS
if (CHIP_ERROR_NOT_FOUND == err)
{
// Example DAC
Expand Down Expand Up @@ -569,7 +569,7 @@ CHIP_ERROR Storage::SignWithDeviceAttestationKey(const ByteSpan & message, Mutab
}
else
{
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS
// Example DAC key
return Examples::GetExampleDACProvider()->SignWithDeviceAttestationKey(message, signature);
#else
Expand Down Expand Up @@ -605,7 +605,7 @@ CHIP_ERROR Storage::SignWithDeviceAttestationKey(const ByteSpan & message, Mutab
AttestationKey key(kid);
err = key.SignMessage(message, signature);
}
#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS
#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS
else
{
// Example DAC key
Expand Down Expand Up @@ -663,23 +663,18 @@ CHIP_ERROR Storage::GetProvisionRequest(bool & value)
return SilabsConfig::ReadConfigValue(SilabsConfig::kConfigKey_Provision_Request, value);
}

#if OTA_ENCRYPTION_ENABLE
#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION
CHIP_ERROR Storage::SetOtaTlvEncryptionKey(const ByteSpan & value)
{
chip::DeviceLayer::Silabs::OtaTlvEncryptionKey::OtaTlvEncryptionKey key;
ReturnErrorOnFailure(key.Import(value.data(), value.size()));
return SilabsConfig::WriteConfigValue(SilabsConfig::kOtaTlvEncryption_KeyId, key.GetId());
}
#endif // OTA_ENCRYPTION_ENABLE
#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION

/**
* @brief Reads the test event trigger key from NVM. If the key isn't present, returns default value if defined.
*
* @param[out] keySpan output buffer. Must be at least large enough for 16 bytes (ken length)
* @return CHIP_ERROR
*/
CHIP_ERROR Storage::GetTestEventTriggerKey(MutableByteSpan & keySpan)
{
#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
constexpr size_t kEnableKeyLength = 16; // Expected byte size of the EnableKey
CHIP_ERROR err = CHIP_NO_ERROR;
size_t keyLength = 0;
Expand All @@ -689,7 +684,7 @@ CHIP_ERROR Storage::GetTestEventTriggerKey(MutableByteSpan & keySpan)
err = SilabsConfig::ReadConfigValueBin(SilabsConfig::kConfigKey_Test_Event_Trigger_Key, keySpan.data(), kEnableKeyLength,
keyLength);
#ifndef NDEBUG
#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLE_KEY
if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
{

Expand All @@ -702,11 +697,14 @@ CHIP_ERROR Storage::GetTestEventTriggerKey(MutableByteSpan & keySpan)
}
err = CHIP_NO_ERROR;
}
#endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
#endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLE_KEY
#endif // NDEBUG

keySpan.reduce_size(kEnableKeyLength);
return err;
#else
return CHIP_ERROR_NOT_IMPLEMENTED;
#endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
}

} // namespace Provision
Expand Down
Loading
Loading