From 87e6da0e0c7af5d9161f70943b400f9a3945d3ab Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 17 Jan 2024 13:13:17 -0500 Subject: [PATCH] Fix the error code returned when writing global list attributes. (#31454) * Fix the error code returned when writing global list attributes. It should be UNSUPPORTED_WRITE, not UNSUPPORTED_ATTRIBUTE. Fixes https://github.com/project-chip/connectedhomeip/issues/31448 * Address review comment. --- .../templates/tests/ciTests.json | 2 + .../tests/suites/TestBasicInformation.yaml | 40 + .../util/ember-compatibility-functions.cpp | 50 +- .../zap-generated/test/Commands.h | 810 ------------------ 4 files changed, 73 insertions(+), 829 deletions(-) diff --git a/examples/darwin-framework-tool/templates/tests/ciTests.json b/examples/darwin-framework-tool/templates/tests/ciTests.json index ccec8bf6b985ef..a9c54d4bb43193 100644 --- a/examples/darwin-framework-tool/templates/tests/ciTests.json +++ b/examples/darwin-framework-tool/templates/tests/ciTests.json @@ -3,6 +3,8 @@ "disable": [ "Test_TC_SC_4_1", "Test_TC_SC_5_2", + "TestBasicInformation disabled because codegen test don't support writing readonly attributes", + "TestBasicInformation", "TestClusterComplexTypes", "TestEvents", "TestDiscovery", diff --git a/src/app/tests/suites/TestBasicInformation.yaml b/src/app/tests/suites/TestBasicInformation.yaml index 7db46f10030999..3a61329188f80d 100644 --- a/src/app/tests/suites/TestBasicInformation.yaml +++ b/src/app/tests/suites/TestBasicInformation.yaml @@ -215,3 +215,43 @@ tests: response: # For now all-clusters-app only supports 1 max paths per invoke. value: 1 + + - label: "Write global ClusterRevision attribute" + command: "writeAttribute" + attribute: "ClusterRevision" + arguments: + value: 1 + response: + error: UNSUPPORTED_WRITE + + - label: "Write global FeatureMap attribute" + command: "writeAttribute" + attribute: "FeatureMap" + arguments: + value: 1 + response: + error: UNSUPPORTED_WRITE + + - label: "Write global AttributeList attribute" + command: "writeAttribute" + attribute: "AttributeList" + arguments: + value: [] + response: + error: UNSUPPORTED_WRITE + + - label: "Write global GeneratedCommandList attribute" + command: "writeAttribute" + attribute: "GeneratedCommandList" + arguments: + value: [] + response: + error: UNSUPPORTED_WRITE + + - label: "Write global AcceptedCommandList attribute" + command: "writeAttribute" + attribute: "AcceptedCommandList" + arguments: + value: [] + response: + error: UNSUPPORTED_WRITE diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index 6a3c6fd5b0ada0..8ce6c7bbc2a674 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -503,6 +503,28 @@ Protocols::InteractionModel::Status UnsupportedAttributeStatus(const ConcreteAtt return Status::UnsupportedAttribute; } +// Will set at most one of the out-params (aAttributeCluster or +// aAttributeMetadata) to non-null. Both null means attribute not supported, +// aAttributeCluster non-null means this is a supported global attribute that +// does not have metadata. +void FindAttributeMetadata(const ConcreteAttributePath & aPath, const EmberAfCluster ** aAttributeCluster, + const EmberAfAttributeMetadata ** aAttributeMetadata) +{ + *aAttributeCluster = nullptr; + *aAttributeMetadata = nullptr; + + for (auto & attr : GlobalAttributesNotInMetadata) + { + if (attr == aPath.mAttributeId) + { + *aAttributeCluster = emberAfFindServerCluster(aPath.mEndpointId, aPath.mClusterId); + return; + } + } + + *aAttributeMetadata = emberAfLocateAttributeMetadata(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId); +} + } // anonymous namespace bool ConcreteAttributePathExists(const ConcreteAttributePath & aPath) @@ -530,22 +552,7 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b const EmberAfCluster * attributeCluster = nullptr; const EmberAfAttributeMetadata * attributeMetadata = nullptr; - - bool isGlobalAttributeNotInMetadata = false; - for (auto & attr : GlobalAttributesNotInMetadata) - { - if (attr == aPath.mAttributeId) - { - isGlobalAttributeNotInMetadata = true; - attributeCluster = emberAfFindServerCluster(aPath.mEndpointId, aPath.mClusterId); - break; - } - } - - if (!isGlobalAttributeNotInMetadata) - { - attributeMetadata = emberAfLocateAttributeMetadata(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId); - } + FindAttributeMetadata(aPath, &attributeCluster, &attributeMetadata); if (attributeCluster == nullptr && attributeMetadata == nullptr) { @@ -972,14 +979,19 @@ const EmberAfAttributeMetadata * GetAttributeMetadata(const ConcreteAttributePat CHIP_ERROR WriteSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, const ConcreteDataAttributePath & aPath, TLV::TLVReader & aReader, WriteHandler * apWriteHandler) { - const EmberAfAttributeMetadata * attributeMetadata = GetAttributeMetadata(aPath); + // Check attribute existence. This includes attributes with registered metadata, but also specially handled + // mandatory global attributes (which just check for cluster on endpoint). + const EmberAfCluster * attributeCluster = nullptr; + const EmberAfAttributeMetadata * attributeMetadata = nullptr; + FindAttributeMetadata(aPath, &attributeCluster, &attributeMetadata); - if (attributeMetadata == nullptr) + if (attributeCluster == nullptr && attributeMetadata == nullptr) { return apWriteHandler->AddStatus(aPath, UnsupportedAttributeStatus(aPath)); } - if (attributeMetadata->IsReadOnly()) + // All the global attributes we don't have metadata for are readonly. + if (attributeMetadata == nullptr || attributeMetadata->IsReadOnly()) { return apWriteHandler->AddStatus(aPath, Protocols::InteractionModel::Status::UnsupportedWrite); } diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 1e5f6e0136611b..f1221333410d6b 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -262,7 +262,6 @@ class TestList : public Command { printf("TestSaveAs\n"); printf("TestConfigVariables\n"); printf("TestDescriptorCluster\n"); - printf("TestBasicInformation\n"); printf("TestFabricRemovalWhileSubscribed\n"); printf("TestGeneralCommissioning\n"); printf("TestIdentifyCluster\n"); @@ -151078,814 +151077,6 @@ class TestDescriptorCluster : public TestCommandBridge { } }; -class TestBasicInformation : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestBasicInformation() - : TestCommandBridge("TestBasicInformation") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestBasicInformation() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestBasicInformation\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestBasicInformation\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read location\n"); - err = TestReadLocation_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Write location\n"); - err = TestWriteLocation_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read back location\n"); - err = TestReadBackLocation_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Restore initial location value\n"); - err = TestRestoreInitialLocationValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read AttributeList value\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestReadAttributeListValue_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read AttributeList value\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestReadAttributeListValue_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read NodeLabel\n"); - err = TestReadNodeLabel_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Write NodeLabel\n"); - err = TestWriteNodeLabel_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read back NodeLabel\n"); - err = TestReadBackNodeLabel_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read LocalConfigDisabled\n"); - err = TestReadLocalConfigDisabled_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Write LocalConfigDisabled\n"); - err = TestWriteLocalConfigDisabled_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read back LocalConfigDisabled\n"); - err = TestReadBackLocalConfigDisabled_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Reboot the device\n"); - err = TestRebootTheDevice_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Connect to the device again\n"); - err = TestConnectToTheDeviceAgain_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read back NodeLabel after reboot\n"); - err = TestReadBackNodeLabelAfterReboot_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Restore initial NodeLabel value\n"); - err = TestRestoreInitialNodeLabelValue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read back LocalConfigDisabled after reboot\n"); - err = TestReadBackLocalConfigDisabledAfterReboot_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Restore initial LocalConfigDisabled value\n"); - err = TestRestoreInitialLocalConfigDisabledValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read the ProductAppearance value\n"); - err = TestReadTheProductAppearanceValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read the Specification Version value\n"); - err = TestReadTheSpecificationVersionValue_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read the Max Paths Per Invoke value\n"); - err = TestReadTheMaxPathsPerInvokeValue_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadLocation_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read location: Error: %@", err); - } else { - NSLog(@"Read location: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, @"XX")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteLocation_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"US"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write location: Error: %@", err); - } else { - NSLog(@"Write location: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocation_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back location: Error: %@", err); - } else { - NSLog(@"Read back location: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, @"US")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreInitialLocationValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Restore initial location value: Error: %@", err); - } else { - NSLog(@"Restore initial location value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListValue_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read AttributeList value: Error: %@", err); - } else { - NSLog(@"Read AttributeList value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(28))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 2UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 3UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 4UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 5UL)); - VerifyOrReturn(CheckValue("", actualValue[6], 6UL)); - VerifyOrReturn(CheckValue("", actualValue[7], 7UL)); - VerifyOrReturn(CheckValue("", actualValue[8], 8UL)); - VerifyOrReturn(CheckValue("", actualValue[9], 9UL)); - VerifyOrReturn(CheckValue("", actualValue[10], 10UL)); - VerifyOrReturn(CheckValue("", actualValue[11], 11UL)); - VerifyOrReturn(CheckValue("", actualValue[12], 12UL)); - VerifyOrReturn(CheckValue("", actualValue[13], 13UL)); - VerifyOrReturn(CheckValue("", actualValue[14], 14UL)); - VerifyOrReturn(CheckValue("", actualValue[15], 15UL)); - VerifyOrReturn(CheckValue("", actualValue[16], 16UL)); - VerifyOrReturn(CheckValue("", actualValue[17], 18UL)); - VerifyOrReturn(CheckValue("", actualValue[18], 19UL)); - VerifyOrReturn(CheckValue("", actualValue[19], 20UL)); - VerifyOrReturn(CheckValue("", actualValue[20], 21UL)); - VerifyOrReturn(CheckValue("", actualValue[21], 22UL)); - VerifyOrReturn(CheckValue("", actualValue[22], 65528UL)); - VerifyOrReturn(CheckValue("", actualValue[23], 65529UL)); - VerifyOrReturn(CheckValue("", actualValue[24], 65530UL)); - VerifyOrReturn(CheckValue("", actualValue[25], 65531UL)); - VerifyOrReturn(CheckValue("", actualValue[26], 65532UL)); - VerifyOrReturn(CheckValue("", actualValue[27], 65533UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListValue_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read AttributeList value: Error: %@", err); - } else { - NSLog(@"Read AttributeList value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(27))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 2UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 3UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 4UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 5UL)); - VerifyOrReturn(CheckValue("", actualValue[6], 6UL)); - VerifyOrReturn(CheckValue("", actualValue[7], 7UL)); - VerifyOrReturn(CheckValue("", actualValue[8], 8UL)); - VerifyOrReturn(CheckValue("", actualValue[9], 9UL)); - VerifyOrReturn(CheckValue("", actualValue[10], 10UL)); - VerifyOrReturn(CheckValue("", actualValue[11], 11UL)); - VerifyOrReturn(CheckValue("", actualValue[12], 12UL)); - VerifyOrReturn(CheckValue("", actualValue[13], 13UL)); - VerifyOrReturn(CheckValue("", actualValue[14], 14UL)); - VerifyOrReturn(CheckValue("", actualValue[15], 15UL)); - VerifyOrReturn(CheckValue("", actualValue[16], 16UL)); - VerifyOrReturn(CheckValue("", actualValue[17], 18UL)); - VerifyOrReturn(CheckValue("", actualValue[18], 19UL)); - VerifyOrReturn(CheckValue("", actualValue[19], 20UL)); - VerifyOrReturn(CheckValue("", actualValue[20], 21UL)); - VerifyOrReturn(CheckValue("", actualValue[21], 22UL)); - VerifyOrReturn(CheckValue("", actualValue[22], 65528UL)); - VerifyOrReturn(CheckValue("", actualValue[23], 65529UL)); - VerifyOrReturn(CheckValue("", actualValue[24], 65531UL)); - VerifyOrReturn(CheckValue("", actualValue[25], 65532UL)); - VerifyOrReturn(CheckValue("", actualValue[26], 65533UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNodeLabel_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read NodeLabel: Error: %@", err); - } else { - NSLog(@"Read NodeLabel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNodeLabel_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"My node"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write NodeLabel: Error: %@", err); - } else { - NSLog(@"Write NodeLabel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackNodeLabel_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back NodeLabel: Error: %@", err); - } else { - NSLog(@"Read back NodeLabel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"My node")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLocalConfigDisabled_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocalConfigDisabledWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read LocalConfigDisabled: Error: %@", err); - } else { - NSLog(@"Read LocalConfigDisabled: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LocalConfigDisabled", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteLocalConfigDisabled_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id localConfigDisabledArgument; - localConfigDisabledArgument = - [NSNumber numberWithBool:true]; - [cluster writeAttributeLocalConfigDisabledWithValue:localConfigDisabledArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write LocalConfigDisabled: Error: %@", err); - } else { - NSLog(@"Write LocalConfigDisabled: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocalConfigDisabled_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocalConfigDisabledWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back LocalConfigDisabled: Error: %@", err); - } else { - NSLog(@"Read back LocalConfigDisabled: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LocalConfigDisabled", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTheDevice_13() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestConnectToTheDeviceAgain_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadBackNodeLabelAfterReboot_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back NodeLabel after reboot: Error: %@", err); - } else { - NSLog(@"Read back NodeLabel after reboot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"My node")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreInitialNodeLabelValue_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @""; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Restore initial NodeLabel value: Error: %@", err); - } else { - NSLog(@"Restore initial NodeLabel value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocalConfigDisabledAfterReboot_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocalConfigDisabledWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back LocalConfigDisabled after reboot: Error: %@", err); - } else { - NSLog(@"Read back LocalConfigDisabled after reboot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LocalConfigDisabled", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreInitialLocalConfigDisabledValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id localConfigDisabledArgument; - localConfigDisabledArgument = - [NSNumber numberWithBool:false]; - [cluster writeAttributeLocalConfigDisabledWithValue:localConfigDisabledArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Restore initial LocalConfigDisabled value: Error: %@", err); - } else { - NSLog(@"Restore initial LocalConfigDisabled value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheProductAppearanceValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeProductAppearanceWithCompletion:^(MTRBasicInformationClusterProductAppearanceStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ProductAppearance value: Error: %@", err); - } else { - NSLog(@"Read the ProductAppearance value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Finish", ((MTRBasicInformationClusterProductAppearanceStruct *) actualValue).finish, 2U)); - VerifyOrReturn(CheckValueNonNull("PrimaryColor", ((MTRBasicInformationClusterProductAppearanceStruct *) actualValue).primaryColor)); - VerifyOrReturn(CheckValue("PrimaryColor", ((MTRBasicInformationClusterProductAppearanceStruct *) actualValue).primaryColor, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheSpecificationVersionValue_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpecificationVersionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the Specification Version value: Error: %@", err); - } else { - NSLog(@"Read the Specification Version value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SpecificationVersion", actualValue, 16973824UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheMaxPathsPerInvokeValue_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxPathsPerInvokeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the Max Paths Per Invoke value: Error: %@", err); - } else { - NSLog(@"Read the Max Paths Per Invoke value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("MaxPathsPerInvoke", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - class TestFabricRemovalWhileSubscribed : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced @@ -195210,7 +194401,6 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), - make_unique(), make_unique(), make_unique(), make_unique(),