-
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
[Darwin] MTRDevice attribute cache persistent storage local test facility #32181
[Darwin] MTRDevice attribute cache persistent storage local test facility #32181
Conversation
PR #32181: Size comparison from 573511d to 664cd44 Decreases (2 builds for efr32)
Full report (73 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, stm32, telink)
|
PR #32181: Size comparison from 573511d to 2f3cf59 Decreases (2 builds for efr32)
Full report (73 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, stm32, telink)
|
PR #32181: Size comparison from 573511d to 3a95425 Decreases (7 builds for cc13x4_26x4, efr32)
Full report (73 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, stm32, telink)
|
PR #32181: Size comparison from 573511d to 1c95fd6 Increases (50 builds for cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, stm32, telink)
Decreases (7 builds for cc13x4_26x4, efr32, linux)
Full report (73 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, stm32, telink)
|
PR #32181: Size comparison from 573511d to 1b003b7 Increases (50 builds for cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, stm32, telink)
Decreases (7 builds for cc13x4_26x4, efr32, linux)
Full report (73 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, stm32, telink)
|
// | ||
/** | ||
* Copyright (c) 2023 Project CHIP Authors |
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.
What's with the stray comment at the top? And the incorrect copyright date?
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.
That's an Xcode bug in the handling of the "new source file" template and needs to be removed by hand.
|
||
MTR_EXTERN @interface MTRDeviceControllerLocalTestStorage : NSObject<MTRDeviceControllerStorageDelegate> | ||
|
||
// Setting this variable only affects subsequent MTRDeviceController initializations |
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.
This needs much better documentation. What does setting this variable to true actually do?
// | ||
/** | ||
* Copyright (c) 2023 Project CHIP Authors |
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.
Again, these comments look broken.
@@ -129,10 +118,19 @@ @interface MTRDeviceTests : XCTestCase | |||
|
|||
@implementation MTRDeviceTests | |||
|
|||
#if MTR_PER_CONTROLLER_STORAGE_ENABLED | |||
static BOOL slocalTestStorageEnabledBeforeUnitTest; |
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.
"sLocale", not "slocal"?
// affect this subscription erroring out correctly. | ||
// affect this subscription erroring out correctly. |
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.
This indent change looks wrong to me.
// affect this subscription erroring out correctly. | ||
// affect this subscription erroring out correctly. |
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.
Again, this indent change is broken.
{ | ||
dispatch_queue_t queue = dispatch_get_main_queue(); | ||
|
||
// First start with clean slate and |
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.
"and" what?
#pragma mark - Declarations for internal methods | ||
|
||
// MTRDeviceControllerDataStore.h includes C++ header, and so we need to declare the methods separately | ||
@protocol MTRDeviceControllerDataStoreAttributeStoreMethods |
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.
These bits used to be #ifdef DEBUG
. Why the change?
// | ||
/** | ||
* Copyright (c) 2023 Project CHIP Authors |
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.
Same issue as the other comments.
@@ -240,6 +240,8 @@ | |||
5ACDDD7D27CD16D200EFD68A /* MTRClusterStateCacheContainer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5ACDDD7C27CD16D200EFD68A /* MTRClusterStateCacheContainer.mm */; }; | |||
5ACDDD7E27CD3F3A00EFD68A /* MTRClusterStateCacheContainer_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5ACDDD7B27CD14AF00EFD68A /* MTRClusterStateCacheContainer_Internal.h */; }; | |||
5AE6D4E427A99041001F2493 /* MTRDeviceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AE6D4E327A99041001F2493 /* MTRDeviceTests.m */; }; | |||
75139A6F2B7FE5E900E3A919 /* MTRDeviceControllerLocalTestStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 75139A6E2B7FE5E900E3A919 /* MTRDeviceControllerLocalTestStorage.m */; }; | |||
75139A702B7FE68C00E3A919 /* MTRDeviceControllerLocalTestStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 75139A6D2B7FE5D600E3A919 /* MTRDeviceControllerLocalTestStorage.h */; settings = {ATTRIBUTES = (Private, ); }; }; |
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.
Why is this a private header? Things compile fine if I set it to be a project header....
{ | ||
if (sharingType == MTRStorageSharingTypeNotShared) { | ||
NSUserDefaults * defaults = [[NSUserDefaults alloc] initWithSuiteName:kLocalTestUserDefaultDomain]; | ||
NSData * storedData = [defaults dataForKey:key]; |
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.
As we figured out on Slack: this is going to cause anything that involves multiple controllers to break, because they will stomp on each other's storage.... Probably need to include the controller id in the key, but then the persistence aspect might break unless people use stable ids.
@@ -173,12 +174,31 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory | |||
return nil; | |||
} | |||
|
|||
id<MTRDeviceControllerStorageDelegate> storageDelegateToUse = storageDelegate; | |||
#if MTR_PER_CONTROLLER_STORAGE_ENABLED |
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.
This could be moved out of the real code by exposing _controllerDataStore
as writable to tests, or factoring this logic out into a internal createControllerDataStore
method that the test can override by sub-classing MTRDeviceController.
Fixes #31966
But mainly this PR adds a facility to test MTRDevice attribute cache persistent storage when the MTRDeviceController does not have a per controller storage delegate.
On macOS the storage can be turned on with the command:
and turned off with: