From 578714756837da78d755bd8bdc321f5e98c0065c Mon Sep 17 00:00:00 2001 From: marktrayer Date: Tue, 18 Jul 2023 21:07:23 -0500 Subject: [PATCH] Add OperationalState Global Attributes test to the CI (#27950) * Add OperationalState Global Attributes test to the CI Steps: - regen all yaml tests - re-build chip-tool, re-build all-clusters - manually run OPSTATE_1_1 via chip-tool - verify resulting logs * Restyled by whitespace * Restyled by prettier-json * Restyled by prettier-yaml * Revert change to manualtests.json * Restyled by whitespace * Restyled by prettier-json * Exclude test from Darwin * Restyled by whitespace * Update with results of regen * Restyled by whitespace --------- Co-authored-by: Restyled.io --- .../templates/tests/ciTests.json | 2 + src/app/tests/suites/certification/PICS.yaml | 24 ++ .../certification/Test_TC_OPSTATE_1_1.yaml | 20 +- .../tests/suites/certification/ci-pics-values | 13 + src/app/tests/suites/ciTests.json | 2 + .../chip-tool/zap-generated/test/Commands.h | 245 ++++++++++++++++++ 6 files changed, 293 insertions(+), 13 deletions(-) diff --git a/examples/darwin-framework-tool/templates/tests/ciTests.json b/examples/darwin-framework-tool/templates/tests/ciTests.json index f20fb1683d75ea..6bbdca3711641f 100644 --- a/examples/darwin-framework-tool/templates/tests/ciTests.json +++ b/examples/darwin-framework-tool/templates/tests/ciTests.json @@ -115,6 +115,8 @@ "Disabled due to HEPAFilterMonitoring not being enabled in Matter.framework for now:", "Test_TC_HEPAFREMON_1_1", "Test_TC_HEPAFREMON_2_1", + "Disabled due to OperationalState not being enabled in Matter.framework for now:", + "Test_TC_OPSTATE_1_1", "Disabled due to Events verification not supported", "Test_TC_BINFO_2_2" ] diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index 1b58859dcabdd8..514909a2a83efa 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -9539,3 +9539,27 @@ PICS: - label: "Does the device implement sending the ChangeToModeResponse command?" id: RVCCLEANMS.S.C03.Tx + + # + #Operational State + # + #Server Attributes + - label: "Does the device implement the CountdownTime attribute?" + id: OPSTATE.S.A0002 + + #Events Generated + - label: "Does the device generate the OperationCompltion event?" + id: OPSTATE.S.E01 + + #Server Commands Received + - label: "Does the device implement receiving the Pause command?" + id: OPSTATE.S.C00 + + - label: "Does the device implement receiving the Stop command?" + id: OPSTATE.S.C01 + + - label: "Does the device implement receiving the Start command?" + id: OPSTATE.S.C02 + + - label: "Does the device implement receiving the Resume command?" + id: OPSTATE.S.C03 diff --git a/src/app/tests/suites/certification/Test_TC_OPSTATE_1_1.yaml b/src/app/tests/suites/certification/Test_TC_OPSTATE_1_1.yaml index 3f5e2e062c46f8..c4e3694536081e 100644 --- a/src/app/tests/suites/certification/Test_TC_OPSTATE_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_OPSTATE_1_1.yaml @@ -32,7 +32,6 @@ tests: value: nodeId - label: "TH reads the ClusterRevision attribute from the DUT" - PICS: OPSTATE.S.Afffd command: "readAttribute" attribute: "ClusterRevision" response: @@ -41,7 +40,6 @@ tests: type: int16u - label: "TH reads the FeatureMap attribute from the DUT" - PICS: OPSTATE.S.Afffc command: "readAttribute" attribute: "FeatureMap" response: @@ -50,7 +48,6 @@ tests: type: bitmap32 - label: "TH reads the AttributeList attribute from the DUT" - PICS: OPSTATE.S.Afffb command: "readAttribute" attribute: "AttributeList" response: @@ -62,7 +59,7 @@ tests: - label: "TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT" - PICS: OPSTATE.S.A0002 && OPSTATE.S.Afffb + PICS: OPSTATE.S.A0002 command: "readAttribute" attribute: "AttributeList" response: @@ -71,7 +68,6 @@ tests: contains: [2] - label: "TH reads from the DUT the EventList attribute." - PICS: OPSTATE.S.Afffa command: "readAttribute" attribute: "EventList" response: @@ -82,7 +78,7 @@ tests: - label: "TH reads from the DUT the optional event(OperationCompletion) in EventList." - PICS: OPSTATE.S.E01 && OPSTATE.S.Afffa + PICS: OPSTATE.S.E01 command: "readAttribute" attribute: "EventList" response: @@ -91,7 +87,7 @@ tests: contains: [0x01] - label: "Read the optional command(Start) in AcceptedCommandList" - PICS: OPSTATE.S.C02 && OPSTATE.S.Afff9 + PICS: OPSTATE.S.C02 command: "readAttribute" attribute: "AcceptedCommandList" response: @@ -100,7 +96,7 @@ tests: contains: [1, 2] - label: "Read the optional command(Stop) in AcceptedCommandList" - PICS: OPSTATE.S.C01 && OPSTATE.S.Afff9 + PICS: OPSTATE.S.C01 command: "readAttribute" attribute: "AcceptedCommandList" response: @@ -109,7 +105,7 @@ tests: contains: [1] - label: "Read the optional command(Pause) in AcceptedCommandList" - PICS: OPSTATE.S.C00 && OPSTATE.S.Afff9 + PICS: OPSTATE.S.C00 command: "readAttribute" attribute: "AcceptedCommandList" response: @@ -118,7 +114,7 @@ tests: contains: [0, 3] - label: "Read the optional command(Resume) in AcceptedCommandList" - PICS: OPSTATE.S.C03 && OPSTATE.S.Afff9 + PICS: OPSTATE.S.C03 command: "readAttribute" attribute: "AcceptedCommandList" response: @@ -127,9 +123,7 @@ tests: contains: [0, 3] - label: "Read the global attribute: GeneratedCommandList" - PICS: - OPSTATE.S.Afff8 && (OPSTATE.S.C00 || OPSTATE.S.C01 || OPSTATE.S.C02 || - OPSTATE.S.C03) + PICS: (OPSTATE.S.C00 || OPSTATE.S.C01 || OPSTATE.S.C02 || OPSTATE.S.C03) command: "readAttribute" attribute: "GeneratedCommandList" response: diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index bd5ed772903675..239ca2dafc6404 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -1828,6 +1828,19 @@ OPCREDS.C.C09.Tx=1 OPCREDS.C.C0a.Tx=1 OPCREDS.C.C0b.Tx=1 +# Operational State +# Server Attributes +OPSTATE.S.A0002=1 + +# Server Events +OPSTATE.S.E01=1 + +# Server Commands +OPSTATE.S.C00=1 +OPSTATE.S.C01=1 +OPSTATE.S.C02=1 +OPSTATE.S.C03=1 + # Thermostat # Server TSTAT.S=1 diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 33909c2de33cd8..54cc604cb886c0 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -157,6 +157,7 @@ "Test_TC_OO_2_2", "Test_TC_OO_2_4" ], + "OperationalState": ["Test_TC_OPSTATE_1_1"], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], "PressureMeasurement": [ "Test_TC_PRS_1_1", @@ -367,6 +368,7 @@ "OTASoftwareUpdate", "OccupancySensing", "OnOff", + "OperationalState", "PowerSource", "PressureMeasurement", "PumpConfigurationControl", diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 1f2894bfc40260..5d4963b058df34 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -191,6 +191,7 @@ class TestList : public Command printf("Test_TC_OO_2_1\n"); printf("Test_TC_OO_2_2\n"); printf("Test_TC_OO_2_4\n"); + printf("Test_TC_OPSTATE_1_1\n"); printf("Test_TC_PS_1_1\n"); printf("Test_TC_PS_2_1\n"); printf("Test_TC_PRS_1_1\n"); @@ -53788,6 +53789,249 @@ class Test_TC_OO_2_4Suite : public TestCommand } }; +class Test_TC_OPSTATE_1_1Suite : public TestCommand +{ +public: + Test_TC_OPSTATE_1_1Suite(CredentialIssuerCommands * credsIssuerConfig) : + TestCommand("Test_TC_OPSTATE_1_1", 12, credsIssuerConfig) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + + ~Test_TC_OPSTATE_1_1Suite() {} + + chip::System::Clock::Timeout GetWaitDuration() const override + { + return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); + } + +private: + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } + + // + // Tests methods + // + + void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override + { + bool shouldContinue = false; + + switch (mTestIndex - 1) + { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + shouldContinue = true; + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + uint16_t value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("clusterRevision", value, 1U)); + VerifyOrReturn(CheckConstraintType("value", "int16u", "int16u")); + } + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + uint32_t value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("featureMap", value, 0UL)); + VerifyOrReturn(CheckConstraintType("value", "bitmap32", "bitmap32")); + } + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::DecodableList value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckConstraintType("value", "list", "list")); + VerifyOrReturn(CheckConstraintContains("value", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 65533UL)); + } + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::DecodableList value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckConstraintType("value", "list", "list")); + VerifyOrReturn(CheckConstraintContains("value", value, 2UL)); + } + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::DecodableList value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckConstraintType("value", "list", "list")); + VerifyOrReturn(CheckConstraintContains("value", value, 0UL)); + } + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::DecodableList value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckConstraintType("value", "list", "list")); + VerifyOrReturn(CheckConstraintContains("value", value, 1UL)); + } + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::DecodableList value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckConstraintType("value", "list", "list")); + VerifyOrReturn(CheckConstraintContains("value", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 2UL)); + } + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::DecodableList value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckConstraintType("value", "list", "list")); + VerifyOrReturn(CheckConstraintContains("value", value, 1UL)); + } + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::DecodableList value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckConstraintType("value", "list", "list")); + VerifyOrReturn(CheckConstraintContains("value", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 3UL)); + } + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::DecodableList value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckConstraintType("value", "list", "list")); + VerifyOrReturn(CheckConstraintContains("value", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("value", value, 3UL)); + } + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::DecodableList value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckConstraintType("value", "list", "list")); + VerifyOrReturn(CheckConstraintContains("value", value, 4UL)); + } + break; + default: + LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); + } + + if (shouldContinue) + { + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + } + + CHIP_ERROR DoTestStep(uint16_t testIndex) override + { + using namespace chip::app::Clusters; + switch (testIndex) + { + case 0: { + LogStep(0, "Wait for the commissioned device to be retrieved"); + ListFreer listFreer; + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee(kIdentityAlpha, value); + } + case 1: { + LogStep(1, "TH reads the ClusterRevision attribute from the DUT"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::ClusterRevision::Id, true, chip::NullOptional); + } + case 2: { + LogStep(2, "TH reads the FeatureMap attribute from the DUT"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, OperationalState::Attributes::FeatureMap::Id, + true, chip::NullOptional); + } + case 3: { + LogStep(3, "TH reads the AttributeList attribute from the DUT"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::AttributeList::Id, true, chip::NullOptional); + } + case 4: { + LogStep(4, "TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT"); + VerifyOrDo(!ShouldSkip("OPSTATE.S.A0002"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::AttributeList::Id, true, chip::NullOptional); + } + case 5: { + LogStep(5, "TH reads from the DUT the EventList attribute."); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, OperationalState::Attributes::EventList::Id, + true, chip::NullOptional); + } + case 6: { + LogStep(6, "TH reads from the DUT the optional event(OperationCompletion) in EventList."); + VerifyOrDo(!ShouldSkip("OPSTATE.S.E01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, OperationalState::Attributes::EventList::Id, + true, chip::NullOptional); + } + case 7: { + LogStep(7, "Read the optional command(Start) in AcceptedCommandList"); + VerifyOrDo(!ShouldSkip("OPSTATE.S.C02"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::AcceptedCommandList::Id, true, chip::NullOptional); + } + case 8: { + LogStep(8, "Read the optional command(Stop) in AcceptedCommandList"); + VerifyOrDo(!ShouldSkip("OPSTATE.S.C01"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::AcceptedCommandList::Id, true, chip::NullOptional); + } + case 9: { + LogStep(9, "Read the optional command(Pause) in AcceptedCommandList"); + VerifyOrDo(!ShouldSkip("OPSTATE.S.C00"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::AcceptedCommandList::Id, true, chip::NullOptional); + } + case 10: { + LogStep(10, "Read the optional command(Resume) in AcceptedCommandList"); + VerifyOrDo(!ShouldSkip("OPSTATE.S.C03"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::AcceptedCommandList::Id, true, chip::NullOptional); + } + case 11: { + LogStep(11, "Read the global attribute: GeneratedCommandList"); + VerifyOrDo(!ShouldSkip("(OPSTATE.S.C00 || OPSTATE.S.C01 || OPSTATE.S.C02 || OPSTATE.S.C03)"), + return ContinueOnChipMainThread(CHIP_NO_ERROR)); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::GeneratedCommandList::Id, true, chip::NullOptional); + } + } + return CHIP_NO_ERROR; + } +}; + class Test_TC_PS_1_1Suite : public TestCommand { public: @@ -137548,6 +137792,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),