diff --git a/.github/workflows/unit_integration_test.yaml b/.github/workflows/unit_integration_test.yaml index 8462af98bd72c0..6f9a1117e412ec 100644 --- a/.github/workflows/unit_integration_test.yaml +++ b/.github/workflows/unit_integration_test.yaml @@ -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 @@ -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 diff --git a/.gitmodules b/.gitmodules index e2163ae52ce266..2b0b2f79ef6655 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/BUILD.gn b/BUILD.gn index a777fa84b32c99..9f57b05c0cf659 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -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" ] @@ -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") { diff --git a/build/chip/tests.gni b/build/chip/tests.gni index 57d0311694f9be..c932439d87066e 100755 --- a/build/chip/tests.gni +++ b/build/chip/tests.gni @@ -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 diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index bac4016e6c1094..1653c5b589bcd3 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -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 diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 527f83b6a86b5b..41ab6b62573fd3 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -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 @@ -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" ] @@ -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) { diff --git a/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp b/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp deleted file mode 100644 index 4d99346b4e5831..00000000000000 --- a/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * Copyright (c) 2023 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "SilabsTestEventTriggerDelegate.h" -#include - -using namespace ::chip::DeviceLayer; - -namespace chip { - -bool SilabsTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const -{ - uint8_t storedEnableKey[TestEventTriggerDelegate::kEnableKeyLength]; - MutableByteSpan enableKeySpan(storedEnableKey); - - // Return false if we were not able to get the enableKey - VerifyOrReturnValue( - Silabs::Provision::Manager::GetInstance().GetStorage().GetTestEventTriggerKey(enableKeySpan) == CHIP_NO_ERROR, false); - - return (!enableKeySpan.empty() && enableKeySpan.data_equal(enableKey)); -} - -} // namespace chip diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index 25d0156d271a91..1f7c7288e849a4 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -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") @@ -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" ] @@ -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) { diff --git a/examples/platform/silabs/provision/BUILD.gn b/examples/platform/silabs/provision/BUILD.gn index 79931e3c609568..bdfe33abaa6032 100644 --- a/examples/platform/silabs/provision/BUILD.gn +++ b/examples/platform/silabs/provision/BUILD.gn @@ -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" ] } } diff --git a/examples/platform/silabs/provision/ProvisionStorageDefault.cpp b/examples/platform/silabs/provision/ProvisionStorageDefault.cpp index c395e2858effea..63345c64f2059c 100644 --- a/examples/platform/silabs/provision/ProvisionStorageDefault.cpp +++ b/examples/platform/silabs/provision/ProvisionStorageDefault.cpp @@ -34,9 +34,9 @@ #include #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 -#endif // OTA_ENCRYPTION_ENABLE +#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION #ifndef SLI_SI91X_MCU_INTERFACE #include #endif @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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; @@ -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) { @@ -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 diff --git a/examples/platform/silabs/provision/ProvisionStorageFlash.cpp b/examples/platform/silabs/provision/ProvisionStorageFlash.cpp index ebfd3ec53124cf..bce7cb323cb2bf 100644 --- a/examples/platform/silabs/provision/ProvisionStorageFlash.cpp +++ b/examples/platform/silabs/provision/ProvisionStorageFlash.cpp @@ -25,9 +25,9 @@ #include #include #include -#ifdef OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION #include -#endif // OTA_ENCRYPTION_ENABLE +#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION using namespace chip::Credentials; @@ -578,13 +578,13 @@ CHIP_ERROR Storage::GetCertificationDeclaration(MutableByteSpan & value) { size_t size = 0; CHIP_ERROR err = (Flash::Get(Parameters::ID::kCertification, value.data(), value.size(), size)); -#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS +#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS if (CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND == err) { // Example CD return Examples::GetExampleDACProvider()->GetCertificationDeclaration(value); } -#endif // CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS +#endif // SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS ReturnErrorOnFailure(err); value.reduce_size(size); return CHIP_NO_ERROR; @@ -599,13 +599,13 @@ CHIP_ERROR Storage::GetProductAttestationIntermediateCert(MutableByteSpan & valu { size_t size = 0; CHIP_ERROR err = (Flash::Get(Parameters::ID::kPaiCert, value.data(), value.size(), size)); -#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS +#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS if (CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND == err) { // Example PAI return Examples::GetExampleDACProvider()->GetProductAttestationIntermediateCert(value); } -#endif // CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS +#endif // SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS ReturnErrorOnFailure(err); value.reduce_size(size); return CHIP_NO_ERROR; @@ -620,13 +620,13 @@ CHIP_ERROR Storage::GetDeviceAttestationCert(MutableByteSpan & value) { size_t size = 0; CHIP_ERROR err = (Flash::Get(Parameters::ID::kDacCert, value.data(), value.size(), size)); -#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS +#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS if (CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND == err) { // Example DAC return Examples::GetExampleDACProvider()->GetDeviceAttestationCert(value); } -#endif // CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS +#endif // SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS ReturnErrorOnFailure(err); value.reduce_size(size); return CHIP_NO_ERROR; @@ -652,13 +652,13 @@ CHIP_ERROR Storage::SignWithDeviceAttestationKey(const ByteSpan & message, Mutab uint8_t temp[kDeviceAttestationKeySizeMax] = { 0 }; size_t size = 0; CHIP_ERROR err = Flash::Get(Parameters::ID::kDacKey, temp, sizeof(temp), size); -#ifdef CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS +#ifdef SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS if (CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND == err) { // Example DAC key return Examples::GetExampleDACProvider()->SignWithDeviceAttestationKey(message, signature); } -#endif // CHIP_DEVICE_CONFIG_ENABLE_EXAMPLE_CREDENTIALS +#endif // SL_MATTER_ENABLE_EXAMPLE_CREDENTIALS ReturnErrorOnFailure(err); #if (defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE) uint8_t key_buffer[kDeviceAttestationKeySizeMax] = { 0 }; @@ -719,16 +719,22 @@ CHIP_ERROR Storage::GetProvisionRequest(bool & value) // return Flash::Set(Parameters::ID::kProvisionRequest, value); return CHIP_ERROR_NOT_IMPLEMENTED; } -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION CHIP_ERROR Storage::SetOtaTlvEncryptionKey(const ByteSpan & value) { return CHIP_ERROR_NOT_IMPLEMENTED; } -#endif // OTA_ENCRYPTION_ENABLE +#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION CHIP_ERROR Storage::GetTestEventTriggerKey(MutableByteSpan & keySpan) { +#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED + // TODO: Implement Getter + // Adding the same return twice to have the function structure return CHIP_ERROR_NOT_IMPLEMENTED; +#else + return CHIP_ERROR_NOT_IMPLEMENTED; +#endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLED } } // namespace Provision diff --git a/examples/platform/silabs/test-event-trigger/BUILD.gn b/examples/platform/silabs/test-event-trigger/BUILD.gn new file mode 100644 index 00000000000000..73b2be753377ea --- /dev/null +++ b/examples/platform/silabs/test-event-trigger/BUILD.gn @@ -0,0 +1,48 @@ +# Copyright (c) 2025 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") +import("${chip_root}/third_party/silabs/matter_support/provision/args.gni") + +declare_args() { + # 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" +} + +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}\"" ] + } + + include_dirs = [ "." ] +} + +source_set("sources") { + sources = [ + "SilabsTestEventTriggerDelegate.cpp", + "SilabsTestEventTriggerDelegate.h", + ] + + 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", + "${sl_provision_root}:headers", + ] +} diff --git a/examples/platform/silabs/test-event-trigger/SilabsTestEventTriggerDelegate.cpp b/examples/platform/silabs/test-event-trigger/SilabsTestEventTriggerDelegate.cpp new file mode 100644 index 00000000000000..b86bf0f193fdd4 --- /dev/null +++ b/examples/platform/silabs/test-event-trigger/SilabsTestEventTriggerDelegate.cpp @@ -0,0 +1,59 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +using namespace ::chip::DeviceLayer; + +namespace chip { + +CHIP_ERROR SilabsTestEventTriggerDelegate::Init(DeviceLayer::Silabs::Provision::ProvisionedDataProvider * provider) +{ + VerifyOrReturnError(provider != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + mProvider = provider; + + return CHIP_NO_ERROR; +} + +bool SilabsTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const +{ + CHIP_ERROR error = CHIP_NO_ERROR; + + uint8_t storedEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0 }; + MutableByteSpan storedEnableKeySpan(storedEnableKey); + + // If mProvider is equal to nullptr, we still continue in the function to check if the requested enableKey matches the zero + // key. + if (mProvider != nullptr) + { + error = mProvider->GetTestEventTriggerKey(storedEnableKeySpan); + } + + if (error != CHIP_NO_ERROR) + { + // If we fail to read the enableKey from storage, the MutableByteSpan is not modified by the getter which leaves the span + // equal to a zero bytepsan (size = 0). This guarantees that we will be able to inform the stack that the test event trigger + // is not enabled when the stack tries to match the zero bytespan to our enableKey. + ChipLogError(DeviceLayer, "Failed to get test event trigger key: %s", ErrorStr(error)); + } + + return storedEnableKeySpan.data_equal(enableKey); +} + +} // namespace chip diff --git a/examples/platform/silabs/SilabsTestEventTriggerDelegate.h b/examples/platform/silabs/test-event-trigger/SilabsTestEventTriggerDelegate.h similarity index 69% rename from examples/platform/silabs/SilabsTestEventTriggerDelegate.h rename to examples/platform/silabs/test-event-trigger/SilabsTestEventTriggerDelegate.h index c691c0eff9759b..9b4a7ebd414e13 100644 --- a/examples/platform/silabs/SilabsTestEventTriggerDelegate.h +++ b/examples/platform/silabs/test-event-trigger/SilabsTestEventTriggerDelegate.h @@ -18,9 +18,8 @@ #pragma once -#include - #include +#include #include #include #include @@ -32,12 +31,25 @@ class SilabsTestEventTriggerDelegate : public TestEventTriggerDelegate public: explicit SilabsTestEventTriggerDelegate() = default; + /** + * @brief Configures the Silabs Test Event trigger + * + * @param provider pointer to the silabs provisionned data provider + * + * @return CHIP_ERROR CHIP_NO_ERROR, if the init was succesful + * CHIP_ERROR_INVALID_ARGUMENT, if the manager input is equal to nullptr + */ + CHIP_ERROR Init(DeviceLayer::Silabs::Provision::ProvisionedDataProvider * provider); + /** * @brief Checks to see if `enableKey` provided matches value chosen by the manufacturer. * @param enableKey Buffer of the key to verify. * @return True or False. */ bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; + +private: + DeviceLayer::Silabs::Provision::ProvisionedDataProvider * mProvider = nullptr; }; } // namespace chip diff --git a/examples/platform/silabs/tests/BUILD.gn b/examples/platform/silabs/tests/BUILD.gn new file mode 100644 index 00000000000000..2b6e19b99f461d --- /dev/null +++ b/examples/platform/silabs/tests/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") +import("${chip_root}/build/chip/chip_test_group.gni") +import("${chip_root}/build/chip/chip_test_suite.gni") +import("${chip_root}/src/platform/silabs/tests/args.gni") + +chip_test_suite("examples_tests") { + output_name = "libSilabsExamplesPlatformTests" + + test_sources = [ "TestSilabsTestEventTrigger.cpp" ] + + public_deps = [ + "${chip_root}/examples/platform/silabs/test-event-trigger:sources", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/core:string-builder-adapters", + "${chip_root}/src/lib/support", + "${chip_root}/src/lib/support:testing", + ] + + cflags = [ "-Wconversion" ] +} diff --git a/examples/platform/silabs/tests/TestSilabsTestEventTrigger.cpp b/examples/platform/silabs/tests/TestSilabsTestEventTrigger.cpp new file mode 100644 index 00000000000000..45248220219938 --- /dev/null +++ b/examples/platform/silabs/tests/TestSilabsTestEventTrigger.cpp @@ -0,0 +1,217 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include + +#include +#include +#include + +using namespace chip; +using namespace chip::DeviceLayer::Silabs::Provision; + +namespace { +const uint8_t kTestEnableKey1[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; +const uint8_t kTestEnableKey2[TestEventTriggerDelegate::kEnableKeyLength] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 }; +const uint8_t kInvalidEnableKey[TestEventTriggerDelegate::kEnableKeyLength - 1] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; +const uint8_t kZeroEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0 }; + +class ProviderStub : public ProvisionedDataProvider +{ +public: + CHIP_ERROR GetTestEventTriggerKey(MutableByteSpan & keySpan) override + { + VerifyOrReturnError(!forceError, CHIP_ERROR_INTERNAL); + + ByteSpan enableKeySpan = ByteSpan(mEnableKey, TestEventTriggerDelegate::kEnableKeyLength); + CopySpanToMutableSpan(enableKeySpan, keySpan); + return CHIP_NO_ERROR; + } + + void SetEnableKey(const uint8_t * key, size_t length) + { + if (length == sizeof(mEnableKey)) + { + memcpy(mEnableKey, key, length); + } + } + + void SetForceError(bool value) { forceError = value; } + +private: + uint8_t mEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0 }; + bool forceError = false; +}; + +} // namespace + +// Test that a valid key matches +TEST(TestSilabsTestEventTriggerDelegate, TestDoesEnableKeyMatch_ValidKey) +{ + ProviderStub provider; + provider.SetEnableKey(kTestEnableKey1, TestEventTriggerDelegate::kEnableKeyLength); + + SilabsTestEventTriggerDelegate delegate; + delegate.Init(&provider); + + ByteSpan validKeySpan(kTestEnableKey1); + EXPECT_TRUE(delegate.DoesEnableKeyMatch(validKeySpan)); +} + +// Test that an invalid key does not match +TEST(TestSilabsTestEventTriggerDelegate, TestDoesEnableKeyMatch_InvalidKey) +{ + ProviderStub provider; + provider.SetEnableKey(kTestEnableKey1, TestEventTriggerDelegate::kEnableKeyLength); + + SilabsTestEventTriggerDelegate delegate; + delegate.Init(&provider); + + ByteSpan invalidKeySpan(kInvalidEnableKey, TestEventTriggerDelegate::kEnableKeyLength - 1); + EXPECT_FALSE(delegate.DoesEnableKeyMatch(invalidKeySpan)); +} + +// Test that an empty key does not match +TEST(TestSilabsTestEventTriggerDelegate, TestDoesEnableKeyMatch_EmptyKey) +{ + ProviderStub provider; + provider.SetEnableKey(kTestEnableKey1, TestEventTriggerDelegate::kEnableKeyLength); + + SilabsTestEventTriggerDelegate delegate; + delegate.Init(&provider); + + EXPECT_FALSE(delegate.DoesEnableKeyMatch(ByteSpan(kZeroEnableKey))); +} + +// Test that a different valid key does not match +TEST(TestSilabsTestEventTriggerDelegate, TestDoesEnableKeyMatch_DifferentValidKey) +{ + ProviderStub provider; + provider.SetEnableKey(kTestEnableKey1, TestEventTriggerDelegate::kEnableKeyLength); + + SilabsTestEventTriggerDelegate delegate; + delegate.Init(&provider); + + ByteSpan differentValidKeySpan(kTestEnableKey2); + EXPECT_FALSE(delegate.DoesEnableKeyMatch(differentValidKeySpan)); +} + +// Test that an empty key matchs when no enable key is set +TEST(TestSilabsTestEventTriggerDelegate, TestDoesEnableKeyMatch_NoKeySet_EmptyKey) +{ + ProviderStub provider; + + SilabsTestEventTriggerDelegate delegate; + delegate.Init(&provider); + + EXPECT_TRUE(delegate.DoesEnableKeyMatch(ByteSpan(kZeroEnableKey))); +} + +// Test that a valid key does not match when no enable key is set +TEST(TestSilabsTestEventTriggerDelegate, TestDoesEnableKeyMatch_NoKeySet_ValidKey) +{ + ProviderStub provider; + + SilabsTestEventTriggerDelegate delegate; + delegate.Init(&provider); + + ByteSpan validKeySpan(kTestEnableKey1); + EXPECT_FALSE(delegate.DoesEnableKeyMatch(validKeySpan)); +} + +// Test that a valid key does not match when provider is not set +TEST(TestSilabsTestEventTriggerDelegate, TestDoesEnableKeyMatch_NoStorage_ValidKey) +{ + SilabsTestEventTriggerDelegate delegate; + + ByteSpan validKeySpan(kTestEnableKey1); + EXPECT_FALSE(delegate.DoesEnableKeyMatch(validKeySpan)); +} + +// Test that an invalid key does not match when provider is not set +TEST(TestSilabsTestEventTriggerDelegate, TestDoesEnableKeyMatch_NoStorage_InvalidKey) +{ + SilabsTestEventTriggerDelegate delegate; + + ByteSpan invalidKeySpan(kInvalidEnableKey); + EXPECT_FALSE(delegate.DoesEnableKeyMatch(invalidKeySpan)); +} + +// Test that an empty key matchs when provider is not set +TEST(TestSilabsTestEventTriggerDelegate, TestDoesEnableKeyMatch_NoStorage_EmptyKey) +{ + SilabsTestEventTriggerDelegate delegate; + + EXPECT_TRUE(delegate.DoesEnableKeyMatch(ByteSpan(kZeroEnableKey))); +} + +// Test that a valid key does not match when GetTestEventTriggerKey returns an error +TEST(TestSilabsTestEventTriggerDelegate, TestDoesEnableKeyMatch_GetKeyError_ValidKey) +{ + ProviderStub provider; + provider.SetForceError(true); + + SilabsTestEventTriggerDelegate delegate; + delegate.Init(&provider); + + ByteSpan validKeySpan(kTestEnableKey1); + EXPECT_FALSE(delegate.DoesEnableKeyMatch(validKeySpan)); +} + +// Test that an invalid key does not match when GetTestEventTriggerKey returns an error +TEST(TestSilabsTestEventTriggerDelegate, TestDoesEnableKeyMatch_GetKeyError_InvalidKey) +{ + ProviderStub provider; + provider.SetForceError(true); + + SilabsTestEventTriggerDelegate delegate; + delegate.Init(&provider); + + ByteSpan invalidKeySpan(kInvalidEnableKey); + EXPECT_FALSE(delegate.DoesEnableKeyMatch(invalidKeySpan)); +} + +// Test that an empty key matchs when GetTestEventTriggerKey returns an error +TEST(TestSilabsTestEventTriggerDelegate, TestDoesEnableKeyMatch_GetKeyError_EmptyKey) +{ + ProviderStub provider; + provider.SetForceError(true); + + SilabsTestEventTriggerDelegate delegate; + delegate.Init(&provider); + + EXPECT_TRUE(delegate.DoesEnableKeyMatch(ByteSpan(kZeroEnableKey))); +} + +// Test that Init function initializes the delegate with a valid provider +TEST(TestSilabsTestEventTriggerDelegate, TestInit_ValidProvider) +{ + ProviderStub provider; + SilabsTestEventTriggerDelegate delegate; + EXPECT_EQ(delegate.Init(&provider), CHIP_NO_ERROR); +} + +// Test that Init function returns an error when initialized with a null provider +TEST(TestSilabsTestEventTriggerDelegate, TestInit_NullProvider) +{ + SilabsTestEventTriggerDelegate delegate; + EXPECT_EQ(delegate.Init(nullptr), CHIP_ERROR_INVALID_ARGUMENT); +} diff --git a/scripts/checkout_submodules.py b/scripts/checkout_submodules.py index 78b51435eb64c1..878f8ab1bda7a0 100755 --- a/scripts/checkout_submodules.py +++ b/scripts/checkout_submodules.py @@ -51,6 +51,7 @@ 'genio', 'openiotsdk', 'silabs_docker', + 'unit_tests' ]) Module = namedtuple('Module', 'name path platforms recursive') diff --git a/src/platform/silabs/efr32/efr32-psa-crypto-config.h b/src/platform/silabs/efr32/efr32-psa-crypto-config.h index 0d80b59be9be99..6bf099dcb1457c 100644 --- a/src/platform/silabs/efr32/efr32-psa-crypto-config.h +++ b/src/platform/silabs/efr32/efr32-psa-crypto-config.h @@ -34,9 +34,9 @@ #endif // SL_USE_COAP_CONFIG // Multi-chip OTA encryption processing -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION #define PSA_WANT_ALG_CTR -#endif // OTA_ENCRYPTION_ENABLE +#endif // SL_MATTER_ENABLE_OTA_ENCRYPTION // Include Generated fies #include "psa_crypto_config.h" diff --git a/src/platform/silabs/multi-ota/OTAFactoryDataProcessor.cpp b/src/platform/silabs/multi-ota/OTAFactoryDataProcessor.cpp index a39a39b8f3aa87..4419660c65d006 100644 --- a/src/platform/silabs/multi-ota/OTAFactoryDataProcessor.cpp +++ b/src/platform/silabs/multi-ota/OTAFactoryDataProcessor.cpp @@ -45,7 +45,7 @@ CHIP_ERROR OTAFactoryDataProcessor::ProcessInternal(ByteSpan & block) CHIP_ERROR error = CHIP_NO_ERROR; ReturnErrorOnFailure(mAccumulator.Accumulate(block)); -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION MutableByteSpan mBlock = MutableByteSpan(mAccumulator.data(), mAccumulator.GetThreshold()); OTATlvProcessor::vOtaProcessInternalEncryption(mBlock); #endif diff --git a/src/platform/silabs/multi-ota/OTAFirmwareProcessor.cpp b/src/platform/silabs/multi-ota/OTAFirmwareProcessor.cpp index 19abb72585da3a..8ffd81c38dde11 100644 --- a/src/platform/silabs/multi-ota/OTAFirmwareProcessor.cpp +++ b/src/platform/silabs/multi-ota/OTAFirmwareProcessor.cpp @@ -46,7 +46,7 @@ CHIP_ERROR OTAFirmwareProcessor::Init() { VerifyOrReturnError(mCallbackProcessDescriptor != nullptr, CHIP_OTA_PROCESSOR_CB_NOT_REGISTERED); mAccumulator.Init(sizeof(Descriptor)); -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION mUnalignmentNum = 0; #endif @@ -58,7 +58,7 @@ CHIP_ERROR OTAFirmwareProcessor::Clear() OTATlvProcessor::ClearInternal(); mAccumulator.Clear(); mDescriptorProcessed = false; -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION mUnalignmentNum = 0; #endif @@ -71,12 +71,12 @@ CHIP_ERROR OTAFirmwareProcessor::ProcessInternal(ByteSpan & block) if (!mDescriptorProcessed) { ReturnErrorOnFailure(ProcessDescriptor(block)); -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION /* 16 bytes to used to store undecrypted data because of unalignment */ mAccumulator.Init(requestedOtaMaxBlockSize + 16); #endif } -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION MutableByteSpan mBlock = MutableByteSpan(mAccumulator.data(), mAccumulator.GetThreshold()); memcpy(&mBlock[0], &mBlock[requestedOtaMaxBlockSize], mUnalignmentNum); memcpy(&mBlock[mUnalignmentNum], block.data(), block.size()); diff --git a/src/platform/silabs/multi-ota/OTAFirmwareProcessor.h b/src/platform/silabs/multi-ota/OTAFirmwareProcessor.h index c383e7497b8b1a..25ed325c0f4af2 100644 --- a/src/platform/silabs/multi-ota/OTAFirmwareProcessor.h +++ b/src/platform/silabs/multi-ota/OTAFirmwareProcessor.h @@ -44,7 +44,7 @@ class OTAFirmwareProcessor : public OTATlvProcessor OTADataAccumulator mAccumulator; bool mDescriptorProcessed = false; -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION uint32_t mUnalignmentNum; #endif static constexpr size_t kAlignmentBytes = 64; diff --git a/src/platform/silabs/multi-ota/OTATlvProcessor.cpp b/src/platform/silabs/multi-ota/OTATlvProcessor.cpp index e6601449faf63a..6b679eb9c09b3d 100644 --- a/src/platform/silabs/multi-ota/OTATlvProcessor.cpp +++ b/src/platform/silabs/multi-ota/OTATlvProcessor.cpp @@ -22,7 +22,7 @@ #include #include -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION #include #include #endif @@ -31,7 +31,7 @@ using namespace ::chip::DeviceLayer::Internal; namespace chip { -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION constexpr uint8_t au8Iv[] = { 0x00, 0x00, 0x00, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x00, 0x00, 0x00, 0x00 }; #endif CHIP_ERROR OTATlvProcessor::Process(ByteSpan & block) @@ -66,7 +66,7 @@ void OTATlvProcessor::ClearInternal() mLength = 0; mProcessedLength = 0; mWasSelected = false; -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION mIVOffset = 0; #endif } @@ -105,7 +105,7 @@ CHIP_ERROR OTADataAccumulator::Accumulate(ByteSpan & block) return CHIP_NO_ERROR; } -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION CHIP_ERROR OTATlvProcessor::vOtaProcessInternalEncryption(MutableByteSpan & block) { uint32_t keyId; diff --git a/src/platform/silabs/multi-ota/OTATlvProcessor.h b/src/platform/silabs/multi-ota/OTATlvProcessor.h index fe2070b75e5634..a14c2f2442c07c 100644 --- a/src/platform/silabs/multi-ota/OTATlvProcessor.h +++ b/src/platform/silabs/multi-ota/OTATlvProcessor.h @@ -99,7 +99,7 @@ class OTATlvProcessor void SetLength(uint32_t length) { mLength = length; } void SetWasSelected(bool selected) { mWasSelected = selected; } bool WasSelected() { return mWasSelected; } -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION CHIP_ERROR vOtaProcessInternalEncryption(MutableByteSpan & block); #endif @@ -133,7 +133,7 @@ class OTATlvProcessor bool IsError(CHIP_ERROR & status); -#if OTA_ENCRYPTION_ENABLE +#ifdef SL_MATTER_ENABLE_OTA_ENCRYPTION /*ota decryption*/ uint32_t mIVOffset = 0; /* Expected byte size of the OTAEncryptionKeyLength */ diff --git a/src/platform/silabs/tests/BUILD.gn b/src/platform/silabs/tests/BUILD.gn new file mode 100644 index 00000000000000..3d98396cdc4d7e --- /dev/null +++ b/src/platform/silabs/tests/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2025 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") +import("${chip_root}/build/chip/chip_test_group.gni") +import("${chip_root}/build/chip/chip_test_suite.gni") +import("${chip_root}/src/platform/silabs/tests/args.gni") + +chip_test_group("silabs_platform_tests") { + tests = [] + + if (sl_build_unit_tests) { + tests += [ "${chip_root}/examples/platform/silabs/tests:examples_tests" ] + } +} diff --git a/src/platform/silabs/tests/args.gni b/src/platform/silabs/tests/args.gni new file mode 100644 index 00000000000000..1886b258120ab7 --- /dev/null +++ b/src/platform/silabs/tests/args.gni @@ -0,0 +1,20 @@ +# Copyright (c) 2025 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/chip/tests.gni") + +declare_args() { + # Build argument to enable Silabs specific unit tests + sl_build_unit_tests = chip_build_all_platform_tests +} diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 742da0a3b3dda4..644057e2a388c9 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -547,7 +547,7 @@ template("efr32_sdk") { } if (chip_enable_multi_ota_encryption && chip_enable_multi_ota_requestor) { - defines += [ "OTA_ENCRYPTION_ENABLE=1" ] + defines += [ "SL_MATTER_ENABLE_OTA_ENCRYPTION=1" ] } if (chip_enable_ota_custom_tlv_testing && chip_enable_multi_ota_requestor) { diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 2db499924fd24a..65ed5229f159f8 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 2db499924fd24a9ff045ad5831438ee79e46a8ac +Subproject commit 65ed5229f159f88490a8938538768b692b6173fb diff --git a/third_party/silabs/silabs_board.gni b/third_party/silabs/silabs_board.gni index 6385a880a47ff6..0cdcf7747d155e 100644 --- a/third_party/silabs/silabs_board.gni +++ b/third_party/silabs/silabs_board.gni @@ -51,9 +51,6 @@ declare_args() { # Disable AWS SDK OTA by default aws_sdk_ota = false - # Self-provision enabled - use_provision_channel = false - # Temperature Sensor support sl_enable_si70xx_sensor = false