Skip to content

Commit 1b265c0

Browse files
Merge branch 'master' into idm-4.2-troubleshoot
2 parents c87de26 + b5d13a7 commit 1b265c0

26 files changed

+1175
-1458
lines changed

.gn

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ script_executable = "python3"
2525

2626
default_args = {
2727
pw_unit_test_AUTOMATIC_RUNNER = "$dir_pigweed/targets/host/run_test"
28+
pw_unit_test_CONFIG = "//config/pw_unit_test:define_overrides"
2829

2930
pw_build_PIP_CONSTRAINTS = [ "//scripts/setup/constraints.txt" ]
3031
pw_build_PIP_REQUIREMENTS = [ "//scripts/setup/requirements.build.txt" ]

config/pw_unit_test/BUILD.gn

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
import("//build_overrides/chip.gni")
17+
import("//build_overrides/pigweed.gni")
18+
19+
import("${chip_root}/build/chip/tests.gni")
20+
21+
import("$dir_pw_build/target_types.gni")
22+
pw_source_set("define_overrides") {
23+
public_configs = [ ":define_options" ]
24+
}
25+
26+
config("define_options") {
27+
if (chip_fake_platform && chip_link_tests) {
28+
defines = [ "PW_UNIT_TEST_CONFIG_MEMORY_POOL_SIZE=65536" ]
29+
} else {
30+
defines = [ "PW_UNIT_TEST_CONFIG_MEMORY_POOL_SIZE=16384" ]
31+
}
32+
}

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+2-2
Original file line numberDiff line numberDiff line change
@@ -3752,7 +3752,7 @@ cluster ActivatedCarbonFilterMonitoring = 114 {
37523752
}
37533753

37543754
/** This cluster is used to configure a boolean sensor. */
3755-
provisional cluster BooleanStateConfiguration = 128 {
3755+
cluster BooleanStateConfiguration = 128 {
37563756
revision 1;
37573757

37583758
bitmap AlarmModeBitmap : bitmap8 {
@@ -3810,7 +3810,7 @@ provisional cluster BooleanStateConfiguration = 128 {
38103810
}
38113811

38123812
/** This cluster is used to configure a valve. */
3813-
provisional cluster ValveConfigurationAndControl = 129 {
3813+
cluster ValveConfigurationAndControl = 129 {
38143814
revision 1;
38153815

38163816
enum StatusCodeEnum : enum8 {

src/app/zap-templates/zcl/data-model/chip/boolean-state-configuration-cluster.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ limitations under the License.
2828
<field name="GeneralFault" mask="0x1"/>
2929
</bitmap>
3030

31-
<cluster apiMaturity="provisional">
31+
<cluster>
3232
<domain>General</domain>
3333
<name>Boolean State Configuration</name>
3434
<code>0x0080</code>

src/app/zap-templates/zcl/data-model/chip/valve-configuration-and-control-cluster.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ limitations under the License.
4040
<item name="FailureDueToFault" value="0x02"/>
4141
</enum>
4242

43-
<cluster apiMaturity="provisional">
43+
<cluster>
4444
<domain>HVAC</domain>
4545
<name>Valve Configuration and Control</name>
4646
<code>0x0081</code>

src/controller/data_model/controller-clusters.matter

+2-2
Original file line numberDiff line numberDiff line change
@@ -3988,7 +3988,7 @@ cluster ActivatedCarbonFilterMonitoring = 114 {
39883988
}
39893989

39903990
/** This cluster is used to configure a boolean sensor. */
3991-
provisional cluster BooleanStateConfiguration = 128 {
3991+
cluster BooleanStateConfiguration = 128 {
39923992
revision 1;
39933993

39943994
bitmap AlarmModeBitmap : bitmap8 {
@@ -4046,7 +4046,7 @@ provisional cluster BooleanStateConfiguration = 128 {
40464046
}
40474047

40484048
/** This cluster is used to configure a valve. */
4049-
provisional cluster ValveConfigurationAndControl = 129 {
4049+
cluster ValveConfigurationAndControl = 129 {
40504050
revision 1;
40514051

40524052
enum StatusCodeEnum : enum8 {

src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm

+56-45
Original file line numberDiff line numberDiff line change
@@ -881,24 +881,21 @@ - (MTRDeviceController * _Nullable)maybeInitializeOTAProvider:(MTRDeviceControll
881881

882882
- (void)resetOperationalAdvertising
883883
{
884-
if (!_advertiseOperational) {
885-
// No need to reset anything; we are not advertising the things that
886-
// would need to get reset.
887-
return;
888-
}
884+
assertChipStackLockedByCurrentThread();
889885

890-
std::lock_guard lock(_controllersLock);
891-
if (_controllers.count != 0) {
892-
// We have a running controller. That means we likely need to reset
893-
// operational advertising for that controller.
894-
dispatch_async(_chipWorkQueue, ^{
895-
// StartServer() is the only API we have for resetting DNS-SD
896-
// advertising. It sure would be nice if there were a "restart"
897-
// that was a no-op if the DNS-SD server was not already
898-
// running.
899-
app::DnssdServer::Instance().StartServer();
900-
});
886+
// If we're not advertising, then there's no need to reset anything.
887+
VerifyOrReturn(_advertiseOperational);
888+
889+
// If there are no running controllers there will be no advertisements to reset.
890+
{
891+
std::lock_guard lock(_controllersLock);
892+
VerifyOrReturn(_controllers.count > 0);
901893
}
894+
895+
// StartServer() is the only API we have for resetting DNS-SD advertising.
896+
// It sure would be nice if there were a "restart" that was a no-op if the
897+
// DNS-SD server was not already running.
898+
app::DnssdServer::Instance().StartServer();
902899
}
903900

904901
- (void)controllerShuttingDown:(MTRDeviceController *)controller
@@ -1165,6 +1162,45 @@ - (MTRDeviceController * _Nullable)initializeController:(MTRDeviceController *)c
11651162
error:error];
11661163
}
11671164

1165+
- (void)setMessageReliabilityProtocolIdleRetransmitMs:(nullable NSNumber *)idleRetransmitMs
1166+
activeRetransmitMs:(nullable NSNumber *)activeRetransmitMs
1167+
activeThresholdMs:(nullable NSNumber *)activeThresholdMs
1168+
additionalRetransmitDelayMs:(nullable NSNumber *)additionalRetransmitDelayMs
1169+
{
1170+
[self _assertCurrentQueueIsNotMatterQueue];
1171+
dispatch_async(_chipWorkQueue, ^{
1172+
bool resetAdvertising;
1173+
if (idleRetransmitMs == nil && activeRetransmitMs == nil && activeThresholdMs == nil && additionalRetransmitDelayMs == nil) {
1174+
Messaging::ReliableMessageMgr::SetAdditionalMRPBackoffTime(NullOptional);
1175+
resetAdvertising = ReliableMessageProtocolConfig::SetLocalMRPConfig(NullOptional);
1176+
} else {
1177+
if (additionalRetransmitDelayMs != nil) {
1178+
System::Clock::Timeout additionalBackoff(additionalRetransmitDelayMs.unsignedLongValue);
1179+
Messaging::ReliableMessageMgr::SetAdditionalMRPBackoffTime(MakeOptional(additionalBackoff));
1180+
}
1181+
1182+
// Get current MRP parameters, then override the things we were asked to
1183+
// override.
1184+
ReliableMessageProtocolConfig mrpConfig = GetLocalMRPConfig().ValueOr(GetDefaultMRPConfig());
1185+
if (idleRetransmitMs != nil) {
1186+
mrpConfig.mIdleRetransTimeout = System::Clock::Milliseconds32(idleRetransmitMs.unsignedLongValue);
1187+
}
1188+
if (activeRetransmitMs != nil) {
1189+
mrpConfig.mActiveRetransTimeout = System::Clock::Milliseconds32(activeRetransmitMs.unsignedLongValue);
1190+
}
1191+
if (activeThresholdMs != nil) {
1192+
mrpConfig.mActiveThresholdTime = System::Clock::Milliseconds32(activeThresholdMs.unsignedLongValue);
1193+
}
1194+
1195+
resetAdvertising = ReliableMessageProtocolConfig::SetLocalMRPConfig(MakeOptional(mrpConfig));
1196+
}
1197+
1198+
if (resetAdvertising) {
1199+
[self resetOperationalAdvertising];
1200+
}
1201+
});
1202+
}
1203+
11681204
- (PersistentStorageDelegate *)storageDelegate
11691205
{
11701206
return _persistentStorageDelegate;
@@ -1327,33 +1363,8 @@ void MTRSetMessageReliabilityParameters(NSNumber * _Nullable idleRetransmitMs,
13271363
NSNumber * _Nullable activeThresholdMs,
13281364
NSNumber * _Nullable additionalRetransmitDelayMs)
13291365
{
1330-
bool resetAdvertising = false;
1331-
if (idleRetransmitMs == nil && activeRetransmitMs == nil && activeThresholdMs == nil && additionalRetransmitDelayMs == nil) {
1332-
Messaging::ReliableMessageMgr::SetAdditionalMRPBackoffTime(NullOptional);
1333-
resetAdvertising = ReliableMessageProtocolConfig::SetLocalMRPConfig(NullOptional);
1334-
} else {
1335-
if (additionalRetransmitDelayMs != nil) {
1336-
System::Clock::Timeout additionalBackoff(additionalRetransmitDelayMs.unsignedLongValue);
1337-
Messaging::ReliableMessageMgr::SetAdditionalMRPBackoffTime(MakeOptional(additionalBackoff));
1338-
}
1339-
1340-
// Get current MRP parameters, then override the things we were asked to
1341-
// override.
1342-
ReliableMessageProtocolConfig mrpConfig = GetLocalMRPConfig().ValueOr(GetDefaultMRPConfig());
1343-
if (idleRetransmitMs != nil) {
1344-
mrpConfig.mIdleRetransTimeout = System::Clock::Milliseconds32(idleRetransmitMs.unsignedLongValue);
1345-
}
1346-
if (activeRetransmitMs != nil) {
1347-
mrpConfig.mActiveRetransTimeout = System::Clock::Milliseconds32(activeRetransmitMs.unsignedLongValue);
1348-
}
1349-
if (activeThresholdMs != nil) {
1350-
mrpConfig.mActiveThresholdTime = System::Clock::Milliseconds32(activeThresholdMs.unsignedLongValue);
1351-
}
1352-
1353-
resetAdvertising = ReliableMessageProtocolConfig::SetLocalMRPConfig(MakeOptional(mrpConfig));
1354-
}
1355-
1356-
if (resetAdvertising) {
1357-
[[MTRDeviceControllerFactory sharedInstance] resetOperationalAdvertising];
1358-
}
1366+
[MTRDeviceControllerFactory.sharedInstance setMessageReliabilityProtocolIdleRetransmitMs:idleRetransmitMs
1367+
activeRetransmitMs:activeThresholdMs
1368+
activeThresholdMs:activeThresholdMs
1369+
additionalRetransmitDelayMs:additionalRetransmitDelayMs];
13591370
}

src/darwin/Framework/CHIPTests/MTRControllerTests.m

+7
Original file line numberDiff line numberDiff line change
@@ -1552,4 +1552,11 @@ - (void)testControllerCATs
15521552
XCTAssertFalse([factory isRunning]);
15531553
}
15541554

1555+
- (void)testSetMRPParameters
1556+
{
1557+
// Can be called before starting the factory
1558+
XCTAssertFalse(MTRDeviceControllerFactory.sharedInstance.running);
1559+
MTRSetMessageReliabilityParameters(@2000, @2000, @2000, @2000);
1560+
}
1561+
15551562
@end

src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m

+16
Original file line numberDiff line numberDiff line change
@@ -2035,6 +2035,22 @@ - (void)testControllerServer
20352035
[controllerServer shutdown];
20362036
}
20372037

2038+
- (void)testSetMRPParametersWithRunningController
2039+
{
2040+
NSError * error;
2041+
__auto_type * storageDelegate = [[MTRTestPerControllerStorage alloc] initWithControllerID:[NSUUID UUID]];
2042+
MTRDeviceController * controller = [self startControllerWithRootKeys:[[MTRTestKeys alloc] init]
2043+
operationalKeys:[[MTRTestKeys alloc] init]
2044+
fabricID:@555
2045+
nodeID:@888
2046+
storage:storageDelegate
2047+
error:&error];
2048+
XCTAssertNotNil(controller);
2049+
XCTAssertTrue(controller.running);
2050+
MTRSetMessageReliabilityParameters(@2000, @2000, @2000, @2000);
2051+
[controller shutdown];
2052+
}
2053+
20382054
static NSString * const kLocalTestUserDefaultDomain = @"org.csa-iot.matter.darwintest";
20392055
static NSString * const kLocalTestUserDefaultSubscriptionPoolSizeOverrideKey = @"subscriptionPoolSizeOverride";
20402056

src/lib/core/CHIPError.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class ChipError
132132
* The result is valid only if CanEncapsulate() is true.
133133
*/
134134
constexpr ChipError(Range range, ValueType value) : ChipError(range, value, /*file=*/nullptr, /*line=*/0) {}
135-
#if __cplusplus >= 202002L
135+
#if CHIP_CONFIG_ERROR_SOURCE && __cplusplus >= 202002L
136136
constexpr ChipError(Range range, ValueType value, const char * file, unsigned int line,
137137
std::source_location location = std::source_location::current()) :
138138
mError(MakeInteger(range, (value & MakeMask(0, kValueLength)))) CHIP_INITIALIZE_ERROR_SOURCE(file, line, location)
@@ -141,7 +141,7 @@ class ChipError
141141
constexpr ChipError(Range range, ValueType value, const char * file, unsigned int line) :
142142
mError(MakeInteger(range, (value & MakeMask(0, kValueLength)))) CHIP_INITIALIZE_ERROR_SOURCE(file, line, /*loc=*/nullptr)
143143
{}
144-
#endif // __cplusplus >= 202002L
144+
#endif // CHIP_CONFIG_ERROR_SOURCE && __cplusplus >= 202002L
145145

146146
/**
147147
* Construct a CHIP_ERROR for SdkPart @a part with @a code.
@@ -150,7 +150,7 @@ class ChipError
150150
* The macro version CHIP_SDK_ERROR checks that the numeric value is constant and well-formed.
151151
*/
152152
constexpr ChipError(SdkPart part, uint8_t code) : ChipError(part, code, /*file=*/nullptr, /*line=*/0) {}
153-
#if __cplusplus >= 202002L
153+
#if CHIP_CONFIG_ERROR_SOURCE && __cplusplus >= 202002L
154154
constexpr ChipError(SdkPart part, uint8_t code, const char * file, unsigned int line,
155155
std::source_location location = std::source_location::current()) :
156156
mError(MakeInteger(part, code)) CHIP_INITIALIZE_ERROR_SOURCE(file, line, location)
@@ -159,7 +159,7 @@ class ChipError
159159
constexpr ChipError(SdkPart part, uint8_t code, const char * file, unsigned int line) :
160160
mError(MakeInteger(part, code)) CHIP_INITIALIZE_ERROR_SOURCE(file, line, /*loc=*/nullptr)
161161
{}
162-
#endif // __cplusplus >= 202002L
162+
#endif // CHIP_CONFIG_ERROR_SOURCE && __cplusplus >= 202002L
163163

164164
/**
165165
* Construct a CHIP_ERROR constant for SdkPart @a part with @a code at the current source line.
@@ -180,7 +180,7 @@ class ChipError
180180
* This is intended to be used only in foreign function interfaces.
181181
*/
182182
explicit constexpr ChipError(StorageType error) : ChipError(error, /*file=*/nullptr, /*line=*/0) {}
183-
#if __cplusplus >= 202002L
183+
#if CHIP_CONFIG_ERROR_SOURCE && __cplusplus >= 202002L
184184
explicit constexpr ChipError(StorageType error, const char * file, unsigned int line,
185185
std::source_location location = std::source_location::current()) :
186186
mError(error) CHIP_INITIALIZE_ERROR_SOURCE(file, line, location)
@@ -189,7 +189,7 @@ class ChipError
189189
explicit constexpr ChipError(StorageType error, const char * file, unsigned int line) :
190190
mError(error) CHIP_INITIALIZE_ERROR_SOURCE(file, line, /*loc=*/nullptr)
191191
{}
192-
#endif // __cplusplus >= 202002L
192+
#endif // CHIP_CONFIG_ERROR_SOURCE && __cplusplus >= 202002L
193193

194194
#undef CHIP_INITIALIZE_ERROR_SOURCE
195195

src/messaging/tests/BUILD.gn

+1-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
import("//build_overrides/build.gni")
1616
import("//build_overrides/chip.gni")
17-
import("//build_overrides/nlunit_test.gni")
1817

1918
import("${chip_root}/build/chip/chip_test_suite.gni")
2019
import("${chip_root}/src/app/icd/icd.gni")
@@ -38,15 +37,9 @@ static_library("helpers") {
3837
"${chip_root}/src/transport",
3938
"${chip_root}/src/transport/tests:helpers",
4039
]
41-
42-
# MessagingContext exposes nl-test compatible setup/teardown functions, specifically
43-
# they return nltest specific SUCCESS/FAILURE constants hence this dependency.
44-
#
45-
# Once all tests are moved to pw_unittest/gtest, this dependency should be removed
46-
public_deps = [ "${nlunit_test_root}:nlunit-test" ]
4740
}
4841

49-
chip_test_suite_using_nltest("tests") {
42+
chip_test_suite("tests") {
5043
output_name = "libMessagingLayerTests"
5144

5245
test_sources = [
@@ -73,12 +66,10 @@ chip_test_suite_using_nltest("tests") {
7366
"${chip_root}/src/lib/core",
7467
"${chip_root}/src/lib/support",
7568
"${chip_root}/src/lib/support:test_utils",
76-
"${chip_root}/src/lib/support:testing_nlunit",
7769
"${chip_root}/src/messaging",
7870
"${chip_root}/src/protocols",
7971
"${chip_root}/src/transport",
8072
"${chip_root}/src/transport/raw/tests:helpers",
81-
"${nlunit_test_root}:nlunit-test",
8273
]
8374

8475
if (chip_enable_icd_server) {

src/messaging/tests/MessagingContext.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#include <transport/tests/LoopbackTransportManager.h>
3333
#include <transport/tests/UDPTransportManager.h>
3434

35-
#include <nlunit-test.h>
36-
3735
#include <vector>
3836

3937
namespace chip {
@@ -98,6 +96,8 @@ class MessagingContext : public PlatformMemoryUser
9896
mInitialized(false), mAliceAddress(Transport::PeerAddress::UDP(GetAddress(), CHIP_PORT + 1)),
9997
mBobAddress(Transport::PeerAddress::UDP(GetAddress(), CHIP_PORT))
10098
{}
99+
// TODO Replace VerifyOrDie with Pigweed assert after transition app/tests to Pigweed.
100+
// TODO Currently src/app/icd/server/tests is using MessagingConetext as dependency.
101101
~MessagingContext() { VerifyOrDie(mInitialized == false); }
102102

103103
// Whether Alice and Bob are initialized, must be called before Init

0 commit comments

Comments
 (0)