From 14785966dba8f8ecdb6a74dff0df192e313fa24e Mon Sep 17 00:00:00 2001 From: "Josh V [Apple]" Date: Mon, 8 Nov 2021 19:39:37 -0800 Subject: [PATCH] Add simulated device YAML and pics to YAML (#11561) * Add new YAML tests. * Generated files. --- examples/chip-tool/templates/tests.js | 1 + examples/placeholder/linux/apps/app1/tests.js | 4 +- src/app/tests/suites/certification/PICS.yaml | 12 ++ .../suites/certification/Test_TC_DM_1_1.yaml | 2 + .../suites/certification/Test_TC_DM_1_3.yaml | 100 +++++++++ .../suites/certification/Test_TC_DM_2_2.yaml | 85 ++++++++ .../chip-tool/zap-generated/test/Commands.h | 190 ++++++++++++++++++ 7 files changed, 393 insertions(+), 1 deletion(-) create mode 100644 src/app/tests/suites/certification/Test_TC_DM_1_3.yaml create mode 100644 src/app/tests/suites/certification/Test_TC_DM_2_2.yaml diff --git a/examples/chip-tool/templates/tests.js b/examples/chip-tool/templates/tests.js index 5003ad980ca36a..4790e4372e25f5 100644 --- a/examples/chip-tool/templates/tests.js +++ b/examples/chip-tool/templates/tests.js @@ -55,6 +55,7 @@ function getTests() const DeviceManagement = [ 'Test_TC_DM_1_1', 'Test_TC_DM_3_1', + 'Test_TC_DM_2_2', ]; const ElectricalMeasurement = [ diff --git a/examples/placeholder/linux/apps/app1/tests.js b/examples/placeholder/linux/apps/app1/tests.js index b48f9853011538..028c2346dc8f22 100644 --- a/examples/placeholder/linux/apps/app1/tests.js +++ b/examples/placeholder/linux/apps/app1/tests.js @@ -17,7 +17,9 @@ function getTests() { - const tests = []; + const tests = [ + "Test_TC_DM_1_3", + ]; return tests.join(', '); } diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index 38947caee43fb7..94d70422ee3ca5 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -22,3 +22,15 @@ PICS: - label: "Does the device support discovery over WiFi?" id: WIFI value: true + + - label: "Does the device support manufacturing date" + id: MANF_DATE + value: true + + - label: "Does the device support part number" + id: PART_NUM + value: true + + - label: "Does the device support Intermediate CA Certificate" + id: DM_ICACERT + value: true diff --git a/src/app/tests/suites/certification/Test_TC_DM_1_1.yaml b/src/app/tests/suites/certification/Test_TC_DM_1_1.yaml index 5557b3f11ade64..f057fa32dac99e 100644 --- a/src/app/tests/suites/certification/Test_TC_DM_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_DM_1_1.yaml @@ -109,6 +109,7 @@ tests: - label: "Query ManufacturingDate" command: "readAttribute" attribute: "ManufacturingDate" + PICS: MANF_DATE optional: true response: constraints: @@ -120,6 +121,7 @@ tests: - label: "Query PartNumber" command: "readAttribute" attribute: "PartNumber" + PICS: PART_NUM optional: true response: constraints: diff --git a/src/app/tests/suites/certification/Test_TC_DM_1_3.yaml b/src/app/tests/suites/certification/Test_TC_DM_1_3.yaml new file mode 100644 index 00000000000000..393462dcb59588 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_DM_1_3.yaml @@ -0,0 +1,100 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: 10.1.3. [TC-DM-1.3] Basic Cluster Server Attributes [DUT - Controller] + +config: + cluster: "Basic" + endpoint: 0 + +tests: + - label: "Log OnOff Test Startup" + cluster: "LogCommands" + command: "Log" + arguments: + values: + - name: "message" + value: "*** Basic Cluster Tests Ready" + + - label: "Query Interaction Model Version" + wait: "readAttribute" + attribute: "InteractionModelVersion" + + - label: "Query Vendor Name" + wait: "readAttribute" + attribute: "VendorName" + + - label: "Query VendorID" + wait: "readAttribute" + attribute: "VendorID" + + - label: "Query Product Name" + wait: "readAttribute" + attribute: "ProductName" + + - label: "Query ProductID" + wait: "readAttribute" + attribute: "ProductID" + + - label: "Query User Label" + wait: "readAttribute" + attribute: "UserLabel" + + - label: "Query User Location" + wait: "readAttribute" + attribute: "Location" + + - label: "Query HardwareVersion" + wait: "readAttribute" + attribute: "HardwareVersion" + + - label: "Query HardwareVersionString" + wait: "readAttribute" + attribute: "HardwareVersionString" + + - label: "Query SoftwareVersion" + wait: "readAttribute" + attribute: "SoftwareVersion" + + - label: "Query SoftwareVersionString" + wait: "readAttribute" + attribute: "SoftwareVersionString" + + - label: "Query ManufacturingDate" + wait: "readAttribute" + attribute: "ManufacturingDate" + + - label: "Query PartNumber" + wait: "readAttribute" + attribute: "PartNumber" + + - label: "Query ProductURL" + wait: "readAttribute" + attribute: "ProductURL" + + - label: "Query ProductLabel" + wait: "readAttribute" + attribute: "ProductLabel" + + - label: "Query SerialNumber" + wait: "readAttribute" + attribute: "SerialNumber" + + - label: "Query LocalConfigDisabled" + wait: "readAttribute" + attribute: "LocalConfigDisabled" + + - label: "Query Reachable" + wait: "readAttribute" + attribute: "Reachable" diff --git a/src/app/tests/suites/certification/Test_TC_DM_2_2.yaml b/src/app/tests/suites/certification/Test_TC_DM_2_2.yaml new file mode 100644 index 00000000000000..93febad7e71237 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_DM_2_2.yaml @@ -0,0 +1,85 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: 3.2.2. [TC-DM-2.2] Operational Credential Attributes + +config: + cluster: "Operational Credentials" + endpoint: 0 + +tests: + - label: "Query NOCs" + command: "readAttribute" + # TODO: Enabled and update value when SDK supports this. + disabled: true + attribute: "NOCs" + PICS: DM_ICACERT + response: + value: [{ NOC: 0 }] + constraints: + type: list + + - label: "Query NOCs" + command: + "readAttribute" + # TODO: Enabled and update value when SDK supports this. + disabled: true + attribute: "NOCs" + PICS: DM_ICACERT + response: + value: [{ NOC: 0, ICAC: 0 }] + constraints: + type: list + + - label: "Query fabrics list" + command: "readAttribute" + attribute: "fabrics list" + response: + value: + [ + { + FabricIndex: 0, + RootPublicKey: 65, + VendorID: 65521, + FabricID: 0, + NodeID: 305414945, + Label: "", + }, + ] + constraints: + type: list + + - label: "Query Supported Fabrics" + command: "readAttribute" + attribute: "SupportedFabrics" + response: + value: 16 + constraints: + type: uint8 + + - label: "Query Commissioned Fabrics" + command: "readAttribute" + attribute: "CommissionedFabrics" + response: + value: 1 + constraints: + type: uint8 + + - label: "Query User Trusted Root Certificates" + command: "readAttribute" + attribute: "TrustedRootCertificates" + response: + value: [237] + constraints: + type: list diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 1d624d64a8849d..c216cdf192b978 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -11856,6 +11856,195 @@ class Test_TC_DM_3_1 : public TestCommand // }; +class Test_TC_DM_2_2 : public TestCommand +{ +public: + Test_TC_DM_2_2() : TestCommand("Test_TC_DM_2_2"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DM_2_2\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DM_2_2\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 : Query fabrics list\n"); + err = TestQueryFabricsList_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Query Supported Fabrics\n"); + err = TestQuerySupportedFabrics_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Query Commissioned Fabrics\n"); + err = TestQueryCommissionedFabrics_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Query User Trusted Root Certificates\n"); + err = TestQueryUserTrustedRootCertificates_3(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Callback::Callback mOnFailureCallback_0{ OnFailureCallback_0, this }; + chip::Callback::Callback & fabricsList)> + mOnSuccessCallback_0{ OnSuccessCallback_0, this }; + chip::Callback::Callback mOnFailureCallback_1{ OnFailureCallback_1, this }; + chip::Callback::Callback mOnSuccessCallback_1{ OnSuccessCallback_1, this }; + chip::Callback::Callback mOnFailureCallback_2{ OnFailureCallback_2, this }; + chip::Callback::Callback mOnSuccessCallback_2{ OnSuccessCallback_2, + this }; + chip::Callback::Callback mOnFailureCallback_3{ OnFailureCallback_3, this }; + chip::Callback::Callback & trustedRootCertificates)> + mOnSuccessCallback_3{ OnSuccessCallback_3, this }; + + static void OnFailureCallback_0(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_0(status); + } + + static void + OnSuccessCallback_0(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptor::DecodableType> & fabricsList) + { + (static_cast(context))->OnSuccessResponse_0(fabricsList); + } + + static void OnFailureCallback_1(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_1(status); + } + + static void OnSuccessCallback_1(void * context, uint8_t supportedFabrics) + { + (static_cast(context))->OnSuccessResponse_1(supportedFabrics); + } + + static void OnFailureCallback_2(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_2(status); + } + + static void OnSuccessCallback_2(void * context, uint8_t commissionedFabrics) + { + (static_cast(context))->OnSuccessResponse_2(commissionedFabrics); + } + + static void OnFailureCallback_3(void * context, uint8_t status) + { + (static_cast(context))->OnFailureResponse_3(status); + } + + static void OnSuccessCallback_3(void * context, + const chip::app::DataModel::DecodableList & trustedRootCertificates) + { + (static_cast(context))->OnSuccessResponse_3(trustedRootCertificates); + } + + // + // Tests methods + // + + CHIP_ERROR TestQueryFabricsList_0() + { + chip::Controller::OperationalCredentialsClusterTest cluster; + cluster.Associate(mDevice, 0); + + return cluster.ReadAttributeFabricsList(mOnSuccessCallback_0.Cancel(), mOnFailureCallback_0.Cancel()); + } + + void OnFailureResponse_0(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_0(const chip::app::DataModel::DecodableList< + chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptor::DecodableType> & fabricsList) + { + VerifyOrReturn(CheckValueAsListLength("fabricsList", fabricsList, 1)); + NextTest(); + } + + CHIP_ERROR TestQuerySupportedFabrics_1() + { + chip::Controller::OperationalCredentialsClusterTest cluster; + cluster.Associate(mDevice, 0); + + return cluster.ReadAttributeSupportedFabrics(mOnSuccessCallback_1.Cancel(), mOnFailureCallback_1.Cancel()); + } + + void OnFailureResponse_1(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_1(uint8_t supportedFabrics) + { + VerifyOrReturn(CheckValue("supportedFabrics", supportedFabrics, 16)); + NextTest(); + } + + CHIP_ERROR TestQueryCommissionedFabrics_2() + { + chip::Controller::OperationalCredentialsClusterTest cluster; + cluster.Associate(mDevice, 0); + + return cluster.ReadAttributeCommissionedFabrics(mOnSuccessCallback_2.Cancel(), mOnFailureCallback_2.Cancel()); + } + + void OnFailureResponse_2(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_2(uint8_t commissionedFabrics) + { + VerifyOrReturn(CheckValue("commissionedFabrics", commissionedFabrics, 1)); + NextTest(); + } + + CHIP_ERROR TestQueryUserTrustedRootCertificates_3() + { + chip::Controller::OperationalCredentialsClusterTest cluster; + cluster.Associate(mDevice, 0); + + return cluster.ReadAttributeTrustedRootCertificates(mOnSuccessCallback_3.Cancel(), mOnFailureCallback_3.Cancel()); + } + + void OnFailureResponse_3(uint8_t status) { ThrowFailureResponse(); } + + void OnSuccessResponse_3(const chip::app::DataModel::DecodableList & trustedRootCertificates) + { + VerifyOrReturn(CheckValueAsListLength("trustedRootCertificates", trustedRootCertificates, 1)); + NextTest(); + } +}; + class Test_TC_EMR_1_1 : public TestCommand { public: @@ -28067,6 +28256,7 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(),