From 82951054a64b15f08cf38c8841dbaf350d802375 Mon Sep 17 00:00:00 2001 From: jmartinez-silabs <67972863+jmartinez-silabs@users.noreply.github.com> Date: Mon, 4 Apr 2022 20:50:23 -0400 Subject: [PATCH] Add tests in Test_TC_OO_2_4 for OnOff StartupOnOff behaviours (#17012) * Implement test case oo 2_4. test startup on off with reboot * Wait for commissionned device discovery after reboot + save StartUpOnOff attribute in nvm for all-cluster-app * Restyled by whitespace * Restyled by clang-format * disable Test for Darwin as it does not support reboot command currently Co-authored-by: Restyled.io --- examples/chip-tool-darwin/templates/tests.js | 6 +- examples/chip-tool/templates/tests/tests.js | 6 +- .../suites/certification/Test_TC_OO_2_4.yaml | 257 +++--- .../Framework/CHIP/templates/tests/tests.js | 6 +- .../chip-tool/zap-generated/test/Commands.h | 752 ++++++++++++++++-- 5 files changed, 829 insertions(+), 198 deletions(-) diff --git a/examples/chip-tool-darwin/templates/tests.js b/examples/chip-tool-darwin/templates/tests.js index 9a5581a16cfcee..0c27c4e4b407b9 100644 --- a/examples/chip-tool-darwin/templates/tests.js +++ b/examples/chip-tool-darwin/templates/tests.js @@ -174,10 +174,8 @@ function getTests() ]; const OnOff = [ - 'Test_TC_OO_1_1', - 'Test_TC_OO_2_1', - 'Test_TC_OO_2_2', - 'Test_TC_OO_2_3', + 'Test_TC_OO_1_1', 'Test_TC_OO_2_1', 'Test_TC_OO_2_2', 'Test_TC_OO_2_3', + // 'Test_TC_OO_2_4', Disable this Test for now as Darwin does not support reboot commands currently ]; const PowerSource = [ diff --git a/examples/chip-tool/templates/tests/tests.js b/examples/chip-tool/templates/tests/tests.js index 1d763b12d46099..e4d69bd8e62c40 100644 --- a/examples/chip-tool/templates/tests/tests.js +++ b/examples/chip-tool/templates/tests/tests.js @@ -233,10 +233,6 @@ function getManualTests() 'Test_TC_OCC_3_1', ]; - const OnOff = [ - 'Test_TC_OO_2_4', - ]; - const PressureMeasurement = [ 'Test_TC_PRS_2_2', 'Test_TC_PRS_2_3', @@ -272,7 +268,6 @@ function getManualTests() WindowCovering, // FlowMeasurement, // OccupancySensing, // - OnOff, // PressureMeasurement, // PowerSource, // @@ -435,6 +430,7 @@ function getTests() 'Test_TC_OO_2_1', 'Test_TC_OO_2_2', 'Test_TC_OO_2_3', + 'Test_TC_OO_2_4', ]; const PowerSource = [ diff --git a/src/app/tests/suites/certification/Test_TC_OO_2_4.yaml b/src/app/tests/suites/certification/Test_TC_OO_2_4.yaml index 30ae5d5faa53be..34112e870a47bc 100644 --- a/src/app/tests/suites/certification/Test_TC_OO_2_4.yaml +++ b/src/app/tests/suites/certification/Test_TC_OO_2_4.yaml @@ -16,168 +16,209 @@ name: 3.2.4. [TC-OO-2.4] Startup functionality with server as DUT config: nodeId: 0x12344321 - cluster: "Basic" - endpoint: 0 + cluster: "On/Off" + endpoint: 1 + discriminator: + type: INT16U + defaultValue: 3840 tests: - - label: "Commission DUT to TH" - verification: | - - disabled: true + - label: "Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId - label: "TH sends On command to DUT" - verification: | - ./chip-tool onoff on 1 1 - - StatusIB = - { - status = 0x00, - }, - disabled: true + command: "On" - label: "TH writes a value of 0 to StartUpOnOff attribute of DUT" - verification: | - ./chip-tool onoff write start-up-on-off 0 1 1 + command: "writeAttribute" + attribute: "StartUpOnOff" + arguments: + value: 0 - StatusIB = - { - status = 0x00, - }, - disabled: true + - label: "TH reads the StartUpOnOff attribute from the DUT" + command: "readAttribute" + attribute: "StartUpOnOff" + response: + value: 0 - label: "Power off DUT" - verification: | - - disabled: true + cluster: "SystemCommands" + endpoint: 0 + command: "Reboot" + arguments: + values: + - name: "discriminator" + value: discriminator + + - label: "Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId - label: "Power on DUT" - verification: | - disabled: true - label: "TH reads the OnOff attribute from the DUT" - verification: | - ./chip-tool onoff read on-off 1 1 - - OnOff: FALSE - disabled: true + command: "readAttribute" + attribute: "OnOff" + response: + value: 0 - label: "TH writes a value of 1 to StartUpOnOff attribute of DUT" - verification: | - ./chip-tool onoff write start-up-on-off 1 1 1 - - StatusIB = - { - status = 0x00, - }, - disabled: true + command: "writeAttribute" + attribute: "StartUpOnOff" + arguments: + value: 1 - label: "Power off DUT" - verification: | - - disabled: true + cluster: "SystemCommands" + endpoint: 0 + command: "Reboot" + arguments: + values: + - name: "discriminator" + value: discriminator + + - label: "Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId - label: "Power on DUT" - verification: | - disabled: true - label: "TH reads the OnOff attribute from the DUT" - verification: | - ./chip-tool onoff read on-off 1 1 - - OnOff: TRUE - disabled: true + command: "readAttribute" + attribute: "OnOff" + response: + value: 1 - label: "TH writes a value of 2 to StartUpOnOff attribute of DUT" - verification: | - ./chip-tool onoff write start-up-on-off 2 1 1 - - StatusIB = - { - status = 0x00, - }, - disabled: true + command: "writeAttribute" + attribute: "StartUpOnOff" + arguments: + value: 2 - label: "Power off DUT" - verification: | - - disabled: true + cluster: "SystemCommands" + endpoint: 0 + command: "Reboot" + arguments: + values: + - name: "discriminator" + value: discriminator + + - label: "Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId - label: "Power on DUT" - verification: | - disabled: true - label: "TH reads the OnOff attribute from the DUT" - verification: | - ./chip-tool onoff read on-off 1 1 - - OnOff: FALSE - disabled: true + command: "readAttribute" + attribute: "OnOff" + response: + value: 0 - label: "Power off DUT" - verification: | - - disabled: true + cluster: "SystemCommands" + endpoint: 0 + command: "Reboot" + arguments: + values: + - name: "discriminator" + value: discriminator + + - label: "Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId - label: "Power on DUT" - verification: | - disabled: true - label: "TH reads the OnOff attribute from the DUT" - verification: | - ./chip-tool onoff read on-off 1 1 - - OnOff: TRUE - disabled: true + command: "readAttribute" + attribute: "OnOff" + response: + value: 1 - label: "TH writes NULL to StartUpOnOff attribute of DUT" - verification: | - (how to perform this in chip-tool?) - disabled: true + command: "writeAttribute" + attribute: "StartUpOnOff" + arguments: + value: null - label: "Power off DUT" - verification: | - - disabled: true + cluster: "SystemCommands" + endpoint: 0 + command: "Reboot" + arguments: + values: + - name: "discriminator" + value: discriminator + + - label: "Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId - label: "Power on DUT" - verification: | - disabled: true - label: "TH reads the OnOff attribute from the DUT" - verification: | - ./chip-tool onoff read on-off 1 1 - - OnOff: TRUE - disabled: true + command: "readAttribute" + attribute: "OnOff" + response: + value: 1 - label: "TH sends Off command to DUT" - verification: | - ./chip-tool onoff off 1 1 - - StatusIB = - { - status = 0x00, - }, - disabled: true + command: "Off" - label: "Power off DUT" - verification: | - - disabled: true + cluster: "SystemCommands" + endpoint: 0 + command: "Reboot" + arguments: + values: + - name: "discriminator" + value: discriminator + + - label: "Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId - label: "Power on DUT" - verification: | - disabled: true - label: "TH reads the OnOff attribute from the DUT" - verification: | - ./chip-tool onoff read on-off 1 1 - - OnOff: FALSE - disabled: true + command: "readAttribute" + attribute: "OnOff" + response: + value: 0 diff --git a/src/darwin/Framework/CHIP/templates/tests/tests.js b/src/darwin/Framework/CHIP/templates/tests/tests.js index dcf7bfcf6e6d00..4b60175369b9c6 100644 --- a/src/darwin/Framework/CHIP/templates/tests/tests.js +++ b/src/darwin/Framework/CHIP/templates/tests/tests.js @@ -174,10 +174,8 @@ function getTests() ]; const OnOff = [ - 'Test_TC_OO_1_1', - 'Test_TC_OO_2_1', - 'Test_TC_OO_2_2', - 'Test_TC_OO_2_3', + 'Test_TC_OO_1_1', 'Test_TC_OO_2_1', 'Test_TC_OO_2_2', 'Test_TC_OO_2_3', + // 'Test_TC_OO_2_4', Disable this Test for now as Darwin does not support reboot commands currently ]; const PowerSource = [ diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 81b354ddc91e44..ee51c2fc0e169b 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -130,6 +130,7 @@ class TestList : public Command printf("Test_TC_OO_2_1\n"); printf("Test_TC_OO_2_2\n"); printf("Test_TC_OO_2_3\n"); + printf("Test_TC_OO_2_4\n"); printf("Test_TC_PS_1_1\n"); printf("Test_TC_PS_2_1\n"); printf("Test_TC_PRS_1_1\n"); @@ -366,7 +367,6 @@ class ManualTestList : public Command printf("Test_TC_OCC_2_3\n"); printf("Test_TC_OCC_2_4\n"); printf("Test_TC_OCC_3_1\n"); - printf("Test_TC_OO_2_4\n"); printf("Test_TC_PRS_2_2\n"); printf("Test_TC_PRS_2_3\n"); printf("Test_TC_PS_2_2\n"); @@ -37357,6 +37357,679 @@ class Test_TC_OO_2_3Suite : public TestCommand void OnSuccessResponse_46() { NextTest(); } }; +class Test_TC_OO_2_4Suite : public TestCommand +{ +public: + Test_TC_OO_2_4Suite(CredentialIssuerCommands * credsIssuerConfig) : + TestCommand("Test_TC_OO_2_4", credsIssuerConfig), mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + + ~Test_TC_OO_2_4Suite() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_4\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_4\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 : TH sends On command to DUT\n"); + err = TestThSendsOnCommandToDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : TH writes a value of 0 to StartUpOnOff attribute of DUT\n"); + err = TestThWritesAValueOf0ToStartUpOnOffAttributeOfDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : TH reads the StartUpOnOff attribute from the DUT\n"); + err = TestThReadsTheStartUpOnOffAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Power off DUT\n"); + err = TestPowerOffDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : TH reads the OnOff attribute from the DUT\n"); + err = TestThReadsTheOnOffAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : TH writes a value of 1 to StartUpOnOff attribute of DUT\n"); + err = TestThWritesAValueOf1ToStartUpOnOffAttributeOfDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Power off DUT\n"); + err = TestPowerOffDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : TH reads the OnOff attribute from the DUT\n"); + err = TestThReadsTheOnOffAttributeFromTheDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : TH writes a value of 2 to StartUpOnOff attribute of DUT\n"); + err = TestThWritesAValueOf2ToStartUpOnOffAttributeOfDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Power off DUT\n"); + err = TestPowerOffDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : TH reads the OnOff attribute from the DUT\n"); + err = TestThReadsTheOnOffAttributeFromTheDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Power off DUT\n"); + err = TestPowerOffDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : TH reads the OnOff attribute from the DUT\n"); + err = TestThReadsTheOnOffAttributeFromTheDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : TH writes NULL to StartUpOnOff attribute of DUT\n"); + err = TestThWritesNullToStartUpOnOffAttributeOfDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Power off DUT\n"); + err = TestPowerOffDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : TH reads the OnOff attribute from the DUT\n"); + err = TestThReadsTheOnOffAttributeFromTheDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : TH sends Off command to DUT\n"); + err = TestThSendsOffCommandToDut_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Power off DUT\n"); + err = TestPowerOffDut_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : TH reads the OnOff attribute from the DUT\n"); + err = TestThReadsTheOnOffAttributeFromTheDut_25(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + 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 = 26; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mDiscriminator; + chip::Optional mTimeout; + + void OnDiscoveryCommandsResults(const DiscoveryCommandResult & value) override + { + bool isExpectedDnssdResult = false; + + VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); + NextTest(); + } + + static void OnFailureCallback_2(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_2(error); + } + + static void OnSuccessCallback_2(void * context) { (static_cast(context))->OnSuccessResponse_2(); } + + static void OnFailureCallback_3(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_3(error); + } + + static void + OnSuccessCallback_3(void * context, + const chip::app::DataModel::Nullable & startUpOnOff) + { + (static_cast(context))->OnSuccessResponse_3(startUpOnOff); + } + + static void OnFailureCallback_6(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_6(error); + } + + static void OnSuccessCallback_6(void * context, bool onOff) + { + (static_cast(context))->OnSuccessResponse_6(onOff); + } + + static void OnFailureCallback_7(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_7(error); + } + + static void OnSuccessCallback_7(void * context) { (static_cast(context))->OnSuccessResponse_7(); } + + static void OnFailureCallback_10(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_10(error); + } + + static void OnSuccessCallback_10(void * context, bool onOff) + { + (static_cast(context))->OnSuccessResponse_10(onOff); + } + + static void OnFailureCallback_11(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_11(error); + } + + static void OnSuccessCallback_11(void * context) { (static_cast(context))->OnSuccessResponse_11(); } + + static void OnFailureCallback_14(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_14(error); + } + + static void OnSuccessCallback_14(void * context, bool onOff) + { + (static_cast(context))->OnSuccessResponse_14(onOff); + } + + static void OnFailureCallback_17(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_17(error); + } + + static void OnSuccessCallback_17(void * context, bool onOff) + { + (static_cast(context))->OnSuccessResponse_17(onOff); + } + + static void OnFailureCallback_18(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_18(error); + } + + static void OnSuccessCallback_18(void * context) { (static_cast(context))->OnSuccessResponse_18(); } + + static void OnFailureCallback_21(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_21(error); + } + + static void OnSuccessCallback_21(void * context, bool onOff) + { + (static_cast(context))->OnSuccessResponse_21(onOff); + } + + static void OnFailureCallback_25(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_25(error); + } + + static void OnSuccessCallback_25(void * context, bool onOff) + { + (static_cast(context))->OnSuccessResponse_25(onOff); + } + + // + // Tests methods + // + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestThSendsOnCommandToDut_1() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::OnOff::Commands::On::Type; + + RequestType request; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_1(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_1(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_1(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_1() { NextTest(); } + + CHIP_ERROR TestThWritesAValueOf0ToStartUpOnOffAttributeOfDut_2() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::OnOffClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + chip::app::DataModel::Nullable startUpOnOffArgument; + startUpOnOffArgument.SetNonNull(); + startUpOnOffArgument.Value() = static_cast(0); + + ReturnErrorOnFailure(cluster.WriteAttribute( + startUpOnOffArgument, this, OnSuccessCallback_2, OnFailureCallback_2)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_2(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_2() { NextTest(); } + + CHIP_ERROR TestThReadsTheStartUpOnOffAttributeFromTheDut_3() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::OnOffClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_3, OnFailureCallback_3, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_3(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_3(const chip::app::DataModel::Nullable & startUpOnOff) + { + VerifyOrReturn(CheckValueNonNull("startUpOnOff", startUpOnOff)); + VerifyOrReturn(CheckValue("startUpOnOff.Value()", startUpOnOff.Value(), 0)); + + NextTest(); + } + + CHIP_ERROR TestPowerOffDut_4() + { + SetIdentity(kIdentityAlpha); + return Reboot(mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_5() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestThReadsTheOnOffAttributeFromTheDut_6() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::OnOffClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_6, OnFailureCallback_6, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_6(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_6(bool onOff) + { + VerifyOrReturn(CheckValue("onOff", onOff, 0)); + + NextTest(); + } + + CHIP_ERROR TestThWritesAValueOf1ToStartUpOnOffAttributeOfDut_7() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::OnOffClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + chip::app::DataModel::Nullable startUpOnOffArgument; + startUpOnOffArgument.SetNonNull(); + startUpOnOffArgument.Value() = static_cast(1); + + ReturnErrorOnFailure(cluster.WriteAttribute( + startUpOnOffArgument, this, OnSuccessCallback_7, OnFailureCallback_7)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_7(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_7() { NextTest(); } + + CHIP_ERROR TestPowerOffDut_8() + { + SetIdentity(kIdentityAlpha); + return Reboot(mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_9() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestThReadsTheOnOffAttributeFromTheDut_10() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::OnOffClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_10, OnFailureCallback_10, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_10(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_10(bool onOff) + { + VerifyOrReturn(CheckValue("onOff", onOff, 1)); + + NextTest(); + } + + CHIP_ERROR TestThWritesAValueOf2ToStartUpOnOffAttributeOfDut_11() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::OnOffClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + chip::app::DataModel::Nullable startUpOnOffArgument; + startUpOnOffArgument.SetNonNull(); + startUpOnOffArgument.Value() = static_cast(2); + + ReturnErrorOnFailure(cluster.WriteAttribute( + startUpOnOffArgument, this, OnSuccessCallback_11, OnFailureCallback_11)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_11(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_11() { NextTest(); } + + CHIP_ERROR TestPowerOffDut_12() + { + SetIdentity(kIdentityAlpha); + return Reboot(mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_13() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestThReadsTheOnOffAttributeFromTheDut_14() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::OnOffClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_14, OnFailureCallback_14, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_14(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_14(bool onOff) + { + VerifyOrReturn(CheckValue("onOff", onOff, 0)); + + NextTest(); + } + + CHIP_ERROR TestPowerOffDut_15() + { + SetIdentity(kIdentityAlpha); + return Reboot(mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_16() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestThReadsTheOnOffAttributeFromTheDut_17() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::OnOffClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_17, OnFailureCallback_17, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_17(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_17(bool onOff) + { + VerifyOrReturn(CheckValue("onOff", onOff, 1)); + + NextTest(); + } + + CHIP_ERROR TestThWritesNullToStartUpOnOffAttributeOfDut_18() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::OnOffClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + chip::app::DataModel::Nullable startUpOnOffArgument; + startUpOnOffArgument.SetNull(); + + ReturnErrorOnFailure(cluster.WriteAttribute( + startUpOnOffArgument, this, OnSuccessCallback_18, OnFailureCallback_18)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_18(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_18() { NextTest(); } + + CHIP_ERROR TestPowerOffDut_19() + { + SetIdentity(kIdentityAlpha); + return Reboot(mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_20() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestThReadsTheOnOffAttributeFromTheDut_21() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::OnOffClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_21, OnFailureCallback_21, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_21(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_21(bool onOff) + { + VerifyOrReturn(CheckValue("onOff", onOff, 1)); + + NextTest(); + } + + CHIP_ERROR TestThSendsOffCommandToDut_22() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + using RequestType = chip::app::Clusters::OnOff::Commands::Off::Type; + + RequestType request; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_22(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_22(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_22(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_22() { NextTest(); } + + CHIP_ERROR TestPowerOffDut_23() + { + SetIdentity(kIdentityAlpha); + return Reboot(mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_24() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + + CHIP_ERROR TestThReadsTheOnOffAttributeFromTheDut_25() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + chip::Controller::OnOffClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_25, OnFailureCallback_25, true)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_25(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_25(bool onOff) + { + VerifyOrReturn(CheckValue("onOff", onOff, 0)); + + NextTest(); + } +}; + class Test_TC_PS_1_1Suite : public TestCommand { public: @@ -119242,81 +119915,6 @@ class Test_TC_OCC_3_1Suite : public TestCommand // }; -class Test_TC_OO_2_4Suite : public TestCommand -{ -public: - Test_TC_OO_2_4Suite(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("Test_TC_OO_2_4", credsIssuerConfig), mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_OO_2_4Suite() {} - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_4\n"); - } - - if (mTestCount == mTestIndex) - { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_4\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++) - { - } - - if (CHIP_NO_ERROR != err) - { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - 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 = 0; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - void OnDiscoveryCommandsResults(const DiscoveryCommandResult & value) override - { - bool isExpectedDnssdResult = false; - - VerifyOrReturn(isExpectedDnssdResult, Exit("An unexpected dnssd result has been received")); - NextTest(); - } - - // - // Tests methods - // -}; - class Test_TC_PRS_2_2Suite : public TestCommand { public: @@ -119646,6 +120244,7 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), @@ -119871,7 +120470,6 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig),