From f358e9023eeff73d8cc86b8e65709b314fe948dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Josefsen?= <69624991+ReneJosefsen@users.noreply.github.com> Date: Tue, 16 Jan 2024 14:06:57 +0100 Subject: [PATCH] Update and add additional BOOLCFG test scripts (#31105) * Rename and update 2.1 * Added 3.1 test script * Fix restyle * Added BOOLCFG_1_1 YAML test * Fix restyle * Fix restyle2 * Fix restyle3 * Fixed BOOLCFG YAML * Fix restyle * Fix restyle2 * Restyle * Added BOOLCFG 4.1 test script * Additional test scripts and minor fixes * Added missing step descriptions in 4.3 * Minor read function rename * Minor adjustment to 4.2 step 3d * Added 4.4 test script * Remove print from test script * Adjusted test step id * Adding 5.1 test script * Fix wrong test step description for 5.1 * Adding 5.2 test script * Remove unused import * Adjusted variable name and test step * Added test event trigger for 4.2 * Adding test event triggers for 4.3 * Adding test event triggers for 4.4 * Adding test event triggers for 5.1 * Adding test event triggers for 5.2 and fixed step description * Apply suggestions from code review Co-authored-by: C Freeman * Remove debug code * Converted test skipping to for loop * Updated 2.1 based on review comments * Remove unused variable declaration in 3.1 * Remove unused variable declaration in 4.1 * Restyle * Adjustment to 1.1 test based on latest spec * Added BOOLCFG PICS to ci-pics-values * Added BOOLCFG to PICS.yaml * Fixed invalid PICS --------- Co-authored-by: C Freeman --- src/app/tests/suites/certification/PICS.yaml | 66 ++++ .../certification/Test_TC_BOOLCFG_1_1.yaml | 292 ++++++++++++++++++ .../tests/suites/certification/ci-pics-values | 18 ++ .../python/chip/clusters/__init__.py | 2 +- src/python_testing/TC_BOOLCFG_2_1.py | 134 ++++++++ src/python_testing/TC_BOOLCFG_3_1.py | 135 ++++++++ src/python_testing/TC_BOOLCFG_4_1.py | 101 ++++++ src/python_testing/TC_BOOLCFG_4_2.py | 176 +++++++++++ src/python_testing/TC_BOOLCFG_4_3.py | 285 +++++++++++++++++ src/python_testing/TC_BOOLCFG_4_4.py | 207 +++++++++++++ src/python_testing/TC_BOOLCFG_5_1.py | 177 +++++++++++ src/python_testing/TC_BOOLCFG_5_2.py | 170 ++++++++++ src/python_testing/TC_BSENCFG_2_1.py | 72 ----- 13 files changed, 1762 insertions(+), 73 deletions(-) create mode 100644 src/app/tests/suites/certification/Test_TC_BOOLCFG_1_1.yaml create mode 100644 src/python_testing/TC_BOOLCFG_2_1.py create mode 100644 src/python_testing/TC_BOOLCFG_3_1.py create mode 100644 src/python_testing/TC_BOOLCFG_4_1.py create mode 100644 src/python_testing/TC_BOOLCFG_4_2.py create mode 100644 src/python_testing/TC_BOOLCFG_4_3.py create mode 100644 src/python_testing/TC_BOOLCFG_4_4.py create mode 100644 src/python_testing/TC_BOOLCFG_5_1.py create mode 100644 src/python_testing/TC_BOOLCFG_5_2.py delete mode 100644 src/python_testing/TC_BSENCFG_2_1.py diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index dd68224dc4cb68..7e67a7027b7443 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -9355,3 +9355,69 @@ PICS: - label: "Does the device implement sending the Resume command?" id: RVCOPSTATE.C.C04.Tx + + # + #Boolean State Configuration + # + - label: + "Does the device implement the Boolean State Configuration cluster as + a server?" + id: BOOLCFG.S + + #Features + - label: "Does the device support visual alarms?" + id: BOOLCFG.S.F00 + + - label: "Does the device support audible alarms??" + id: BOOLCFG.S.F01 + + - label: + "Does the device support the ability to suppress or acknowledge + alarms?" + id: BOOLCFG.S.F02 + + - label: + "Does the device support the ability to set level of threshold + detection sensitivity?" + id: BOOLCFG.S.F03 + + #Attributes + - label: "Does the device implement the CurrentSensitivityLevel attribute?" + id: BOOLCFG.S.A0000 + + - label: + "Does the device implement the SupportedSensitivityLevels attribute?" + id: BOOLCFG.S.A0001 + + - label: "Does the device implement the DefaultSensitivityLevel attribute?" + id: BOOLCFG.S.A0002 + + - label: "Does the device implement the AlarmsActive attribute?" + id: BOOLCFG.S.A0003 + + - label: "Does the device implement the AlarmsSuppressed attribute?" + id: BOOLCFG.S.A0004 + + - label: "Does the device implement the AlarmsEnabled attribute?" + id: BOOLCFG.S.A0005 + + - label: "Does the device implement the AlarmsSupported attribute?" + id: BOOLCFG.S.A0006 + + - label: "Does the device implement the SensorFault attribute?" + id: BOOLCFG.S.A0007 + + #Commands received + - label: "Does the device implement receiving the SuppressAlarm command?" + id: BOOLCFG.S.C00.Rsp + + - label: + "Does the device implement receiving the EnableDisableAlarm command?" + id: BOOLCFG.S.C01.Rsp + + #Events + - label: "Does the device implement the AlarmsStateChanged event?" + id: BOOLCFG.S.E00 + + - label: "Does the device implement the SensorFault event?" + id: BOOLCFG.S.E01 diff --git a/src/app/tests/suites/certification/Test_TC_BOOLCFG_1_1.yaml b/src/app/tests/suites/certification/Test_TC_BOOLCFG_1_1.yaml new file mode 100644 index 00000000000000..d8294f379d108a --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_BOOLCFG_1_1.yaml @@ -0,0 +1,292 @@ +# Copyright (c) 2024 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: 69.1.1. [TC-BOOLCFG-1.1] Global attributes with server as DUT + +PICS: + - BOOLCFG.S + +config: + nodeId: 0x12344321 + cluster: "Boolean State Configuration" + endpoint: 1 + +tests: + - label: "Step 1: Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: "Step 2: Read the global attribute: ClusterRevision" + command: "readAttribute" + attribute: "ClusterRevision" + response: + value: 1 + constraints: + type: int16u + + - label: "Step 3a: Read the global attribute: FeatureMap" + command: "readAttribute" + attribute: "FeatureMap" + PICS: + ( !BOOLCFG.S.F00 && !BOOLCFG.S.F01 && !BOOLCFG.S.F02 && !BOOLCFG.S.F03 + ) + response: + value: 0 + constraints: + type: bitmap32 + + - label: + "Step 3b: Given BOOLCFG.S.F00(VIS) ensure featuremap has the correct + bit set" + command: "readAttribute" + attribute: "FeatureMap" + PICS: BOOLCFG.S.F00 + response: + constraints: + type: bitmap32 + hasMasksSet: [0x1] + + - label: + "Step 3c: Given BOOLCFG.S.F01(AUD) ensure featuremap has the correct + bit set" + command: "readAttribute" + attribute: "FeatureMap" + PICS: BOOLCFG.S.F01 + response: + constraints: + type: bitmap32 + hasMasksSet: [0x2] + + - label: + "Step 3d: Given BOOLCFG.S.F02(SPRS) ensure featuremap has the correct + bit set" + command: "readAttribute" + attribute: "FeatureMap" + PICS: BOOLCFG.S.F02 + response: + constraints: + type: bitmap32 + hasMasksSet: [0x4] + + - label: + "Step 3d: Given BOOLCFG.S.F03(SENSLVL) ensure featuremap has the + correct bit set" + command: "readAttribute" + attribute: "FeatureMap" + PICS: BOOLCFG.S.F03 + response: + constraints: + type: bitmap32 + hasMasksSet: [0x8] + + - label: "Step 4a: Read the global attribute: AttributeList" + PICS: PICS_EVENT_LIST_ENABLED + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [65528, 65529, 65530, 65531, 65532, 65533] + + - label: "Step 4a: Read the global attribute: AttributeList" + PICS: "!PICS_EVENT_LIST_ENABLED" + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [65528, 65529, 65531, 65532, 65533] + + - label: + "Step 4b: Read the feature dependent(BOOLCFG.S.F00) attribute in + AttributeList" + PICS: BOOLCFG.S.F00 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [3, 6] + + - label: + "Step 4c: Read the feature dependent(BOOLCFG.S.F00) optional attribute + in AttributeList" + PICS: BOOLCFG.S.F00 && BOOLCFG.S.A0005 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [5] + + - label: + "Step 4d: Read the feature dependent(BOOLCFG.S.F01) attribute in + AttributeList" + PICS: BOOLCFG.S.F01 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [3, 6] + + - label: + "Step 4e: Read the feature dependent(BOOLCFG.S.F01) optional attribute + in AttributeList" + PICS: BOOLCFG.S.F01 && BOOLCFG.S.A0005 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [5] + + - label: + "Step 4f: Read the feature dependent(BOOLCFG.S.F02) attribute in + AttributeList" + PICS: BOOLCFG.S.F02 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [4] + + - label: + "Step 4g: Read the feature dependent(BOOLCFG.S.F03) attribute in + AttributeList" + PICS: BOOLCFG.S.F03 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [0, 1] + + - label: + "Step 4h: Read the feature dependent(BOOLCFG.S.F03) optional attribute + in AttributeList" + PICS: BOOLCFG.S.F03 && BOOLCFG.S.A0002 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [2] + + - label: + "Step 4i: TH reads optional (SensorFault) attribute in AttributeList" + PICS: BOOLCFG.S.A0007 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [7] + + - label: "Step 5a: Read the global attribute: EventList" + PICS: + PICS_EVENT_LIST_ENABLED && !BOOLCFG.S.F00 && !BOOLCFG.S.F01 && + !BOOLCFG.S.E01 + command: "readAttribute" + attribute: "EventList" + response: + value: [] + constraints: + type: list + + - label: + "Step 5b: Read the feature dependent(BOOLCFG.S.F00) + (AlarmsStateChanged) event in EventList" + PICS: PICS_EVENT_LIST_ENABLED && BOOLCFG.S.F00 + command: "readAttribute" + attribute: "EventList" + response: + constraints: + type: list + contains: [0] + + - label: + "Step 5c: Read the feature dependent(BOOLCFG.S.F01) + (AlarmsStateChanged) event in EventList" + PICS: PICS_EVENT_LIST_ENABLED && BOOLCFG.S.F01 + command: "readAttribute" + attribute: "EventList" + response: + constraints: + type: list + contains: [0] + + - label: "Step 5d: Read the optional (SensorFault) event in EventList" + PICS: PICS_EVENT_LIST_ENABLED && BOOLCFG.S.E01 + command: "readAttribute" + attribute: "EventList" + response: + constraints: + type: list + contains: [1] + + - label: "Step 6a: Read the global attribute: AcceptedCommandList" + PICS: ( !BOOLCFG.S.F00 && !BOOLCFG.S.F01 && !BOOLCFG.S.F02 ) + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + value: [] + constraints: + type: list + + - label: + "Step 6b: Read the feature dependent(BOOLCFG.S.F02) (SuppressAlarm) + command in AcceptedCommandList" + PICS: BOOLCFG.S.F02 + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [0] + + - label: + "Step 6c: Read the feature dependent(BOOLCFG.S.F00) + (EnableDisableAlarm) command in AcceptedCommandList" + PICS: BOOLCFG.S.F00 + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [1] + + - label: + "Step 6d: Read the feature dependent(BOOLCFG.S.F01) + (EnableDisableAlarm) command in AcceptedCommandList" + PICS: BOOLCFG.S.F01 + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [1] + + - label: "Step 7: Read the global attribute: GeneratedCommandList" + command: "readAttribute" + attribute: "GeneratedCommandList" + response: + value: [] + constraints: + type: list diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 86fb9fb792b2fa..079781a0c2d59e 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -2655,3 +2655,21 @@ REFALM.S.A0003=1 REFALM.S.E00=1 REFALM.S.C00.Rsp=1 REFALM.S.C01.Rsp=1 + +BOOLCFG.S=1 +BOOLCFG.S.F00=1 +BOOLCFG.S.F01=1 +BOOLCFG.S.F02=1 +BOOLCFG.S.F03=1 +BOOLCFG.S.A0000=1 +BOOLCFG.S.A0001=1 +BOOLCFG.S.A0002=1 +BOOLCFG.S.A0003=1 +BOOLCFG.S.A0004=1 +BOOLCFG.S.A0005=1 +BOOLCFG.S.A0006=1 +BOOLCFG.S.A0007=1 +BOOLCFG.S.E00=1 +BOOLCFG.S.E01=1 +BOOLCFG.S.C00.Rsp=1 +BOOLCFG.S.C01.Rsp=1 diff --git a/src/controller/python/chip/clusters/__init__.py b/src/controller/python/chip/clusters/__init__.py index 89e9107d7398f6..7f17d80b9391e6 100644 --- a/src/controller/python/chip/clusters/__init__.py +++ b/src/controller/python/chip/clusters/__init__.py @@ -48,7 +48,7 @@ __all__ = [Attribute, CHIPClusters, Command, AccessControl, AccountLogin, Actions, ActivatedCarbonFilterMonitoring, AdministratorCommissioning, AirQuality, ApplicationBasic, ApplicationLauncher, AudioOutput, BallastConfiguration, BarrierControl, BasicInformation, - BinaryInputBasic, Binding, BooleanStateConfiguration, BooleanState, BridgedDeviceBasicInformation, CarbonDioxideConcentrationMeasurement, + BinaryInputBasic, Binding, BooleanState, BooleanStateConfiguration, BridgedDeviceBasicInformation, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, Channel, ColorControl, ContentLauncher, Descriptor, DeviceEnergyManagement, DiagnosticLogs, DishwasherAlarm, DishwasherMode, DoorLock, ElectricalMeasurement, EnergyEvse, EthernetNetworkDiagnostics, FanControl, FaultInjection, FixedLabel, FlowMeasurement, diff --git a/src/python_testing/TC_BOOLCFG_2_1.py b/src/python_testing/TC_BOOLCFG_2_1.py new file mode 100644 index 00000000000000..d6ed97540056db --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_2_1.py @@ -0,0 +1,134 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# 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. +# + +import functools +import logging +from operator import ior + +import chip.clusters as Clusters +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_BOOLCFG_2_1(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_2_1(self) -> str: + return "[TC-BOOLCFG-2.1] Attributes with DUT as Server" + + def steps_TC_BOOLCFG_2_1(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Read attribute list to determine supported attributes"), + TestStep(3, "Read SupportedSensitivityLevels attribute, if supported"), + TestStep(4, "Read CurrentSensitivityLevel attribute, if supported"), + TestStep(5, "Read DefaultSensitivityLevel attribute, if supported"), + TestStep(6, "Read AlarmsActive attribute, if supported"), + TestStep(7, "Read AlarmsSuppressed attribute, if supported"), + TestStep(8, "Read AlarmsEnabled attribute, if supported"), + TestStep(9, "Read AlarmsSupported attribute, if supported"), + TestStep(10, "Read SensorFault attribute, if supported"), + ] + return steps + + def pics_TC_BOOLCFG_2_1(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_2_1(self): + + endpoint = self.user_params.get("endpoint", 1) + all_alarm_mode_bitmap_bits = functools.reduce( + ior, [b.value for b in Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap]) + all_sensor_fault_bitmap_bits = functools.reduce( + ior, [b.value for b in Clusters.BooleanStateConfiguration.Bitmaps.SensorFaultBitmap]) + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step(2) + attribute_list = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + number_of_supported_levels = 0 + + self.step(3) + if attributes.SupportedSensitivityLevels.attribute_id in attribute_list: + number_of_supported_levels = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.SupportedSensitivityLevels) + asserts.assert_less_equal(number_of_supported_levels, 10, "SupportedSensitivityLevels attribute is out of range") + asserts.assert_greater_equal(number_of_supported_levels, 2, "SupportedSensitivityLevels attribute is out of range") + else: + logging.info("Test step skipped") + + self.step(4) + if attributes.CurrentSensitivityLevel.attribute_id in attribute_list: + current_sensitivity_level_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentSensitivityLevel) + asserts.assert_less_equal(current_sensitivity_level_dut, number_of_supported_levels, + "CurrentSensitivityLevel is not in valid range") + else: + logging.info("Test step skipped") + + self.step(5) + if attributes.DefaultSensitivityLevel.attribute_id in attribute_list: + default_sensitivity_level_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.DefaultSensitivityLevel) + asserts.assert_less_equal(default_sensitivity_level_dut, number_of_supported_levels, + "DefaultSensitivityLevel is not in valid range") + else: + logging.info("Test step skipped") + + self.step(6) + if attributes.AlarmsActive.attribute_id in attribute_list: + alarms_active_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(alarms_active_dut & ~all_alarm_mode_bitmap_bits, 0, "AlarmsActive is not in valid range") + else: + logging.info("Test step skipped") + + self.step(7) + if attributes.AlarmsSuppressed.attribute_id in attribute_list: + alarms_suppressed_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSuppressed) + asserts.assert_equal(alarms_suppressed_dut & ~all_alarm_mode_bitmap_bits, 0, "AlarmsSuppressed is not in valid range") + else: + logging.info("Test step skipped") + + self.step(8) + if attributes.AlarmsEnabled.attribute_id in attribute_list: + alarms_enabled_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsEnabled) + asserts.assert_equal(alarms_enabled_dut & ~all_alarm_mode_bitmap_bits, 0, "AlarmsEnabled is not in valid range") + else: + logging.info("Test step skipped") + + self.step(9) + if attributes.AlarmsSupported.attribute_id in attribute_list: + alarms_supported_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSupported) + asserts.assert_equal(alarms_supported_dut & ~all_alarm_mode_bitmap_bits, 0, "AlarmsSupported is not in valid range") + else: + logging.info("Test step skipped") + + self.step(10) + if attributes.SensorFault.attribute_id in attribute_list: + sensor_fault_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.SensorFault) + asserts.assert_equal(sensor_fault_dut & ~all_sensor_fault_bitmap_bits, 0, "SensorFault is not in valid range") + else: + logging.info("Test step skipped") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_3_1.py b/src/python_testing/TC_BOOLCFG_3_1.py new file mode 100644 index 00000000000000..ceeeba33c6ee2d --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_3_1.py @@ -0,0 +1,135 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# 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. +# + +import logging +from random import choice + +import chip.clusters as Clusters +from chip.interaction_model import Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_BOOLCFG_3_1(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_3_1(self) -> str: + return "[TC-BOOLCFG-3.1] SensitivityLevel with DUT as Server" + + def steps_TC_BOOLCFG_3_1(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep("2a", "Read FeatureMap attribute"), + TestStep("2b", "Read AttributeList attribute"), + TestStep(3, "Read SupportedSensitivityLevels attribute"), + TestStep(4, "Read DefaultSensitivityLevel attribute, if supported"), + TestStep(5, "Read CurrentSensitivityLevel attribute"), + TestStep(6, "TH loops through the number of supported sensitivity levels"), + TestStep(7, "Write CurrentSensitivityLevel attribute to non-default value"), + TestStep(8, "Write CurrentSensitivityLevel attribute to default value"), + TestStep(9, "Write CurrentSensitivityLevel attribute to 10"), + TestStep(10, "Write CurrentSensitivityLevel attribute to 255"), + TestStep(11, "Write CurrentSensitivityLevel attribute to the initial current value"), + ] + return steps + + def pics_TC_BOOLCFG_3_1(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_3_1(self): + + endpoint = self.user_params.get("endpoint", 1) + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step("2a") + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + self.step("2b") + attribute_list = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + is_sens_level_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kSensitivityLevel + + self.step(3) + if is_sens_level_feature_supported: + numberOfSupportedLevels = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.SupportedSensitivityLevels) + else: + logging.info("Test step skipped") + + default_level = 0 + + self.step(4) + if attributes.DefaultSensitivityLevel.attribute_id in attribute_list: + default_level = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.DefaultSensitivityLevel) + else: + logging.info("Test step skipped") + + current_level = 0 + + self.step(5) + if is_sens_level_feature_supported: + current_level = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentSensitivityLevel) + else: + logging.info("Test step skipped") + + self.step(6) + if is_sens_level_feature_supported: + for sens_level in range(numberOfSupportedLevels): + logging.info(f"Write sensitivity level ({sens_level}) to CurrentSensitivityLevel)") + result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.CurrentSensitivityLevel(sens_level))]) + asserts.assert_equal(result[0].Status, Status.Success, "CurrentSensitivityLevel write failed") + + self.step(7) + if attributes.DefaultSensitivityLevel.attribute_id in attribute_list: + selected_non_default_level = choice([i for i in range(numberOfSupportedLevels) if i not in [default_level]]) + logging.info(f"Write non-default sensitivity level ({selected_non_default_level}) to CurrentSensitivityLevel)") + result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.CurrentSensitivityLevel(selected_non_default_level))]) + asserts.assert_equal(result[0].Status, Status.Success, "CurrentSensitivityLevel write failed") + + self.step(8) + if attributes.DefaultSensitivityLevel.attribute_id in attribute_list: + logging.info(f"Write default sensitivity level ({default_level}) to CurrentSensitivityLevel)") + result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.CurrentSensitivityLevel(default_level))]) + asserts.assert_equal(result[0].Status, Status.Success, "CurrentSensitivityLevel write failed") + + self.step(9) + if is_sens_level_feature_supported: + result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.CurrentSensitivityLevel(numberOfSupportedLevels))]) + asserts.assert_equal(result[0].Status, Status.ConstraintError, + "CurrentSensitivityLevel did not return CONSTRAINT_ERROR") + + self.step(10) + if is_sens_level_feature_supported: + result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.CurrentSensitivityLevel(255))]) + asserts.assert_equal(result[0].Status, Status.ConstraintError, + "CurrentSensitivityLevel did not return CONSTRAINT_ERROR") + + self.step(11) + if is_sens_level_feature_supported: + result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.CurrentSensitivityLevel(current_level))]) + asserts.assert_equal(result[0].Status, Status.Success, "CurrentSensitivityLevel write failed") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_4_1.py b/src/python_testing/TC_BOOLCFG_4_1.py new file mode 100644 index 00000000000000..74f81b7bfd79bd --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_4_1.py @@ -0,0 +1,101 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# 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. +# + +import logging + +import chip.clusters as Clusters +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_BOOLCFG_4_1(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_4_1(self) -> str: + return "[TC-BOOLCFG-4.1] AlarmsSupported attribute with DUT as Server" + + def steps_TC_BOOLCFG_4_1(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Read FeatureMap attribute"), + TestStep(3, "Read AlarmsSupported attribute"), + TestStep("4a", "Verify AlarmsSupported attribute bit 0"), + TestStep("4b", "Verify AlarmsSupported attribute bit 0"), + TestStep("5a", "Verify AlarmsSupported attribute bit 1"), + TestStep("5b", "Verify AlarmsSupported attribute bit 1"), + ] + return steps + + def pics_TC_BOOLCFG_4_1(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_4_1(self): + + endpoint = self.user_params.get("endpoint", 1) + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step(2) + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + is_vis_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kVisual + is_aud_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAudible + + self.step(3) + if is_vis_feature_supported or is_aud_feature_supported: + supportedAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSupported) + else: + logging.info("Test step skipped") + + self.step("4a") + if is_vis_feature_supported: + asserts.assert_not_equal((supportedAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), 0, + "Bit 0 in AlarmsSupported does not match feature map value") + else: + logging.info("Test step skipped") + + self.step("4b") + if not is_vis_feature_supported: + asserts.assert_equal((supportedAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), 0, + "Bit 0 in AlarmsSupported does not match feature map value") + else: + logging.info("Test step skipped") + + self.step("5a") + if is_aud_feature_supported: + asserts.assert_not_equal((supportedAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible), 0, + "Bit 1 in AlarmsSupported does not match feature map value") + else: + logging.info("Test step skipped") + + self.step("5b") + if not is_aud_feature_supported: + asserts.assert_equal((supportedAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible), 0, + "Bit 1 in AlarmsSupported does not match feature map value") + else: + logging.info("Test step skipped") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_4_2.py b/src/python_testing/TC_BOOLCFG_4_2.py new file mode 100644 index 00000000000000..06f5ecad6adbad --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_4_2.py @@ -0,0 +1,176 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# 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. +# + +import logging + +import chip.clusters as Clusters +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +sensorTrigger = 0x0080_0000_0000_0000 +sensorUntrigger = 0x0080_0000_0000_0001 + + +class TC_BOOLCFG_4_2(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_4_2(self) -> str: + return "[TC-BOOLCFG-4.2] AlarmsActive attribute with DUT as Server" + + def steps_TC_BOOLCFG_4_2(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep("2a", "Read FeatureMap attribute"), + TestStep("2b", "Read AttributeList attribute"), + TestStep("3a", "Create variable named enabledAlarms"), + TestStep("3b", "If VIS is supported, set bit 0 to 1"), + TestStep("3c", "If AUD is supported, set bit 1 to 1"), + TestStep("3d", "Set AlarmsEnabled attribute to value of enabledAlarms using EnableDisableAlarm command"), + TestStep(4, "Send TestEventTrigger with SensorTrigger event"), + TestStep(5, "Read AlarmsActive attribute"), + TestStep("6a", "Verify VIS alarm is active, if supported"), + TestStep("6b", "Verify VIS alarm is not active, if not supported"), + TestStep("7a", "Verify AUD alarm is active, if supported"), + TestStep("7b", "Verify AUD alarm is not active, if not supported"), + TestStep(8, "Send TestEventTrigger with SensorUntrigger event"), + TestStep(9, "Read AlarmsActive attribute"), + ] + return steps + + def pics_TC_BOOLCFG_4_2(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_4_2(self): + + asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, + "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " + "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + + endpoint = self.user_params.get("endpoint", 1) + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step("2a") + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + is_vis_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kVisual + is_aud_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAudible + + self.step("2b") + attribute_list = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + self.step("3a") + enabledAlarms = 0 + + self.step("3b") + if attributes.AlarmsEnabled.attribute_id in attribute_list and is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual + else: + logging.info("Test step skipped") + + self.step("3c") + if attributes.AlarmsEnabled.attribute_id in attribute_list and is_aud_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible + else: + logging.info("Test step skipped") + + self.step("3d") + if attributes.AlarmsEnabled.attribute_id in attribute_list: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(4) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(5) + activeAlarms = 0 + + if is_vis_feature_supported or is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_not_equal(activeAlarms, 0, "AlarmsActive is 0") + else: + logging.info("Test step skipped") + + self.step("6a") + if is_vis_feature_supported: + asserts.assert_not_equal( + (activeAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), 0, "Bit 0 in AlarmsActive is not 1") + else: + logging.info("Test step skipped") + + self.step("6b") + if not is_vis_feature_supported: + asserts.assert_equal((activeAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), + 0, "Bit 0 in AlarmsActive is not 0") + else: + logging.info("Test step skipped") + + self.step("7a") + if is_aud_feature_supported: + asserts.assert_not_equal( + (activeAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible), 0, "Bit 1 in AlarmsActive is not 1") + else: + logging.info("Test step skipped") + + self.step("7b") + if not is_aud_feature_supported: + asserts.assert_equal((activeAlarms & Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible), + 0, "Bit 1 in AlarmsActive is not 0") + else: + logging.info("Test step skipped") + + self.step(8) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(9) + if is_vis_feature_supported or is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, 0, "AlarmsActive is not 0") + else: + logging.info("Test step skipped") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_4_3.py b/src/python_testing/TC_BOOLCFG_4_3.py new file mode 100644 index 00000000000000..40a44a004a67e5 --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_4_3.py @@ -0,0 +1,285 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# 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. +# + +import logging + +import chip.clusters as Clusters +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +sensorTrigger = 0x0080_0000_0000_0000 +sensorUntrigger = 0x0080_0000_0000_0001 + + +class TC_BOOLCFG_4_3(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_4_3(self) -> str: + return "[TC-BOOLCFG-4.3] AlarmsEnabled functionality for inactive alarms with DUT as Server" + + def steps_TC_BOOLCFG_4_3(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep("2a", "Read FeatureMap attribute"), + TestStep("2b", "Read AttributeList attribute"), + TestStep(3, "Verify AlarmsEnabled is supported"), + TestStep(4, "Create enabledAlarms and set to 0"), + TestStep("5a", "Enable VIS alarm in enabledAlarms"), + TestStep("5b", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(6, "Send TestEventTrigger with SensorTrigger event"), + TestStep(7, "Read AlarmsActive attribute"), + TestStep(8, "Send TestEventTrigger with SensorUntrigger event"), + TestStep(9, "Read AlarmsActive attribute"), + TestStep(10, "Set enabledAlarms to 0"), + TestStep(11, "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(12, "Send TestEventTrigger with SensorTrigger event"), + TestStep(13, "Read AlarmsActive attribute"), + TestStep(14, "Send TestEventTrigger with SensorUntrigger event"), + TestStep("15a", "Enable AUD alarm in enabledAlarms"), + TestStep("15b", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(16, "Send TestEventTrigger with SensorTrigger event"), + TestStep(17, "Read AlarmsActive attribute"), + TestStep(18, "Send TestEventTrigger with SensorUntrigger event"), + TestStep(19, "Read AlarmsActive attribute"), + TestStep(20, "Set enabledAlarms to 0"), + TestStep(21, "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(22, "Send TestEventTrigger with SensorTrigger event"), + TestStep(23, "Read AlarmsActive attribute"), + TestStep(24, "Send TestEventTrigger with SensorUntrigger event"), + ] + return steps + + def pics_TC_BOOLCFG_4_3(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_4_3(self): + + asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, + "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " + "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + + endpoint = self.user_params.get("endpoint", 1) + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step("2a") + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + is_vis_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kVisual + is_aud_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAudible + + self.step("2b") + attribute_list = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + self.step(3) + if attributes.AlarmsEnabled.attribute_id not in attribute_list: + logging.info("AlarmsEnabled not supported skipping test case") + + # Skipping all remainig steps + for step in self.get_test_steps(self.current_test_info.name)[self.current_step_index:]: + self.step(step.test_plan_number) + logging.info("Test step skipped") + + return + else: + logging.info("Test step skipped") + + self.step(4) + enabledAlarms = 0 + + self.step("5a") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual + else: + logging.info("Test step skipped") + + self.step("5b") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(6) + if is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(7) + if is_vis_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual, + "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(8) + if is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(9) + if is_vis_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, 0, "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(10) + enabledAlarms = 0 + + self.step(11) + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(12) + if is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(13) + if is_vis_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, 0, "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(14) + if is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step("15a") + if is_aud_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible + else: + logging.info("Test step skipped") + + self.step("15b") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(16) + if is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(17) + if is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible, + "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(18) + if is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(19) + if is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, 0, "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(20) + enabledAlarms = 0 + + self.step(21) + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(22) + if is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(23) + if is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal(activeAlarms, 0, "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(24) + if is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_4_4.py b/src/python_testing/TC_BOOLCFG_4_4.py new file mode 100644 index 00000000000000..cd76848d59e801 --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_4_4.py @@ -0,0 +1,207 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# 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. +# + +import logging + +import chip.clusters as Clusters +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +sensorTrigger = 0x0080_0000_0000_0000 +sensorUntrigger = 0x0080_0000_0000_0001 + + +class TC_BOOLCFG_4_4(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_4_4(self) -> str: + return "[TC-BOOLCFG-4.4] AlarmsEnabled functionality for active alarms with DUT as Server" + + def steps_TC_BOOLCFG_4_4(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep("2a", "Read FeatureMap attribute"), + TestStep("2b", "Read AttributeList attribute"), + TestStep(3, "Verify AlarmsEnabled is supported"), + TestStep(4, "Create enabledAlarms and set to 0"), + TestStep("5a", "Enable VIS alarm in enabledAlarms"), + TestStep("5b", "Enable AUD alarm in enabledAlarms"), + TestStep("5c", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(6, "Send TestEventTrigger with SensorTrigger event"), + TestStep(7, "Read AlarmsActive attribute"), + TestStep(8, "Verify VIS alarm is active"), + TestStep("9a", "Disable VIS alarm in enabledAlarms"), + TestStep("9b", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(10, "Read AlarmsActive attribute"), + TestStep(11, "Verify AUD alarm is active"), + TestStep("12a", "Disable VIS alarm in enabledAlarms"), + TestStep("12b", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(13, "Read AlarmsActive attribute"), + TestStep(14, "Send TestEventTrigger with SensorUntrigger event"), + ] + return steps + + def pics_TC_BOOLCFG_4_4(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_4_4(self): + + asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, + "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " + "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + + endpoint = self.user_params.get("endpoint", 1) + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step("2a") + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + is_vis_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kVisual + is_aud_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAudible + + self.step("2b") + attribute_list = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + self.step(3) + if attributes.AlarmsEnabled.attribute_id not in attribute_list: + logging.info("AlarmsEnabled not supported skipping test case") + + # Skipping all remainig steps + for step in self.get_test_steps(self.current_test_info.name)[self.current_step_index:]: + self.step(step.test_plan_number) + logging.info("Test step skipped") + + return + else: + logging.info("Test step skipped") + + self.step(4) + enabledAlarms = 0 + + self.step("5a") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual + else: + logging.info("Test step skipped") + + self.step("5b") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible + else: + logging.info("Test step skipped") + + self.step("5c") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(6) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(7) + activeAlarms = 0 + + if is_vis_feature_supported or is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_not_equal(activeAlarms, 0, "AlarmsActive does not match expected value") + else: + logging.info("Test step skipped") + + self.step(8) + if is_vis_feature_supported: + asserts.assert_not_equal((activeAlarms & 0b01), 0, "Bit 0 in AlarmsActive is not 1") + else: + logging.info("Test step skipped") + + self.step("9a") + if is_vis_feature_supported: + enabledAlarms &= ~(Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual) + else: + logging.info("Test step skipped") + + self.step("9b") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(10) + if is_vis_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal((activeAlarms & 0b01), 0, "Bit 0 in AlarmsActive is not 0") + else: + logging.info("Test step skipped") + + self.step(11) + if is_aud_feature_supported: + asserts.assert_not_equal((activeAlarms & 0b10), 0, "Bit 1 in AlarmsActive is not 1") + else: + logging.info("Test step skipped") + + self.step("12a") + if is_aud_feature_supported: + enabledAlarms &= ~(Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible) + else: + logging.info("Test step skipped") + + self.step("12b") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(13) + if is_aud_feature_supported: + activeAlarms = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) + asserts.assert_equal((activeAlarms & 0b10), 0, "Bit 1 in AlarmsActive is not 0") + else: + logging.info("Test step skipped") + + self.step(14) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_5_1.py b/src/python_testing/TC_BOOLCFG_5_1.py new file mode 100644 index 00000000000000..7e7dac0e1e8adf --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_5_1.py @@ -0,0 +1,177 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# 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. +# + +import logging + +import chip.clusters as Clusters +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +sensorTrigger = 0x0080_0000_0000_0000 +sensorUntrigger = 0x0080_0000_0000_0001 + + +class TC_BOOLCFG_5_1(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_5_1(self) -> str: + return "[TC-BOOLCFG-5.1] SuppressAlarm functionality for inactive alarms with DUT as Server" + + def steps_TC_BOOLCFG_5_1(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Read FeatureMap attribute"), + TestStep(3, "Verify SPRS feature is supported"), + TestStep(4, "Create enabledAlarms and set to 0"), + TestStep("5a", "Enable VIS alarm in enabledAlarms"), + TestStep("5b", "Enable AUD alarm in enabledAlarms"), + TestStep("5c", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(6, "Send TestEventTrigger with SensorUntrigger event"), + TestStep("7a", "Suppress VIS alarm using SuppressAlarm command"), + TestStep("7b", "Suppress VIS alarm using SuppressAlarm command"), + TestStep(8, "Read AlarmsSuppressed attribute"), + TestStep("9a", "Suppress AUD alarm using SuppressAlarm command"), + TestStep("9b", "Suppress AUD alarm using SuppressAlarm command"), + TestStep(10, "Read AlarmsSuppressed attribute"), + ] + return steps + + def pics_TC_BOOLCFG_5_1(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_5_1(self): + + asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, + "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " + "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + + endpoint = self.user_params.get("endpoint", 1) + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step(2) + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + is_sprs_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAlarmSuppress + is_vis_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kVisual + is_aud_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAudible + + self.step(3) + if not is_sprs_feature_supported: + logging.info("AlarmSuppress feature not supported skipping test case") + + # Skipping all remainig steps + for step in self.get_test_steps(self.current_test_info.name)[self.current_step_index:]: + self.step(step.test_plan_number) + logging.info("Test step skipped") + + return + else: + logging.info("Test step skipped") + + self.step(4) + enabledAlarms = 0 + + self.step("5a") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual + else: + logging.info("Test step skipped") + + self.step("5b") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible + else: + logging.info("Test step skipped") + + self.step("5c") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(6) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step("7a") + if is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.SuppressAlarm(alarmsToSuppress=Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), endpoint=endpoint) + asserts.fail("Received Success response when an INVALID_IN_STATE was expected") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidInState, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step("7b") + if not is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.SuppressAlarm(alarmsToSuppress=Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), endpoint=endpoint) + asserts.fail("Received Success response when an CONSTRAINT_ERROR was expected") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.ConstraintError, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(8) + alarms_suppressed_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSuppressed) + asserts.assert_equal(alarms_suppressed_dut, 0, "AlarmsSuppressed is not the expected value") + + self.step("9a") + if is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.SuppressAlarm(alarmsToSuppress=Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible), endpoint=endpoint) + asserts.fail("Received Success response when an INVALID_IN_STATE was expected") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.InvalidInState, "Unexpected error returned") + pass + + self.step("9b") + if not is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.SuppressAlarm(alarmsToSuppress=Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), endpoint=endpoint) + asserts.fail("Received Success response when an CONSTRAINT_ERROR was expected") + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.ConstraintError, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(10) + alarms_suppressed_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSuppressed) + asserts.assert_equal(alarms_suppressed_dut, 0, "AlarmsSuppressed is not the expected value") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BOOLCFG_5_2.py b/src/python_testing/TC_BOOLCFG_5_2.py new file mode 100644 index 00000000000000..3a4dd41b46bbf0 --- /dev/null +++ b/src/python_testing/TC_BOOLCFG_5_2.py @@ -0,0 +1,170 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# 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. +# + +import logging + +import chip.clusters as Clusters +from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + +sensorTrigger = 0x0080_0000_0000_0000 +sensorUntrigger = 0x0080_0000_0000_0001 + + +class TC_BOOLCFG_5_2(MatterBaseTest): + async def read_boolcfg_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.BooleanStateConfiguration + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_BOOLCFG_5_2(self) -> str: + return "[TC-BOOLCFG-5.2] SuppressAlarm functionality for active alarms with DUT as Server" + + def steps_TC_BOOLCFG_5_2(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Read FeatureMap attribute"), + TestStep(3, "Verify SPRS feature is supported"), + TestStep(4, "Create enabledAlarms and set to 0"), + TestStep("5a", "Enable VIS alarm in enabledAlarms"), + TestStep("5b", "Enable AUD alarm in enabledAlarms"), + TestStep("5c", "Set AlarmsEnabled attribute to value of enabledAlarms using AlarmsToEnableDisable command"), + TestStep(6, "Send TestEventTrigger with SensorTrigger event"), + TestStep(7, "Suppress VIS alarm using SuppressAlarm command"), + TestStep(8, "Read AlarmsSuppressed attribute"), + TestStep(9, "Suppress AUD alarm using SuppressAlarm command"), + TestStep(10, "Read AlarmsActive attribute"), + TestStep(11, "Send TestEventTrigger with SensorUntrigger event") + ] + return steps + + def pics_TC_BOOLCFG_5_2(self) -> list[str]: + pics = [ + "BOOLCFG.S", + ] + return pics + + @async_test_body + async def test_TC_BOOLCFG_5_2(self): + + asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params, + "PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in " + "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:") + + endpoint = self.user_params.get("endpoint", 1) + enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big') + + self.step(1) + attributes = Clusters.BooleanStateConfiguration.Attributes + + self.step(2) + feature_map = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + + is_sprs_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAlarmSuppress + is_vis_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kVisual + is_aud_feature_supported = feature_map & Clusters.BooleanStateConfiguration.Bitmaps.Feature.kAudible + + self.step(3) + if not is_sprs_feature_supported: + logging.info("AlarmSuppress feature not supported skipping test case") + + # Skipping all remainig steps + for step in self.get_test_steps(self.current_test_info.name)[self.current_step_index:]: + self.step(step.test_plan_number) + logging.info("Test step skipped") + + return + else: + logging.info("Test step skipped") + + self.step(4) + enabledAlarms = 0 + + self.step("5a") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual + else: + logging.info("Test step skipped") + + self.step("5b") + if is_vis_feature_supported: + enabledAlarms |= Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible + else: + logging.info("Test step skipped") + + self.step("5c") + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.EnableDisableAlarm(alarmsToEnableDisable=enabledAlarms), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + self.step(6) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorTrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(7) + if is_vis_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.SuppressAlarm(alarmsToSuppress=Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kVisual), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(8) + if is_vis_feature_supported: + alarms_suppressed_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSuppressed) + asserts.assert_not_equal((alarms_suppressed_dut & 0b01), 0, "Bit 0 in AlarmsSuppressed is not 1") + else: + logging.info("Test step skipped") + + self.step(9) + if is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.BooleanStateConfiguration.Commands.SuppressAlarm(alarmsToSuppress=Clusters.BooleanStateConfiguration.Bitmaps.AlarmModeBitmap.kAudible), endpoint=endpoint) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + else: + logging.info("Test step skipped") + + self.step(10) + if is_aud_feature_supported: + alarms_suppressed_dut = await self.read_boolcfg_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSuppressed) + asserts.assert_not_equal((alarms_suppressed_dut & 0b10), 0, "Bit 1 in AlarmsSuppressed is not 1") + else: + logging.info("Test step skipped") + + self.step(11) + if is_vis_feature_supported or is_aud_feature_supported: + try: + await self.send_single_cmd(cmd=Clusters.Objects.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=enableKey, eventTrigger=sensorUntrigger), endpoint=0) + except InteractionModelError as e: + asserts.assert_equal(e.status, Status.Success, "Unexpected error returned") + pass + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_BSENCFG_2_1.py b/src/python_testing/TC_BSENCFG_2_1.py deleted file mode 100644 index 0312b131a77590..00000000000000 --- a/src/python_testing/TC_BSENCFG_2_1.py +++ /dev/null @@ -1,72 +0,0 @@ -# -# Copyright (c) 2023 Project CHIP Authors -# All rights reserved. -# -# 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. -# - -import logging - -import chip.clusters as Clusters -from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main -from mobly import asserts - - -class TC_BSENCFG_2_1(MatterBaseTest): - async def read_ts_attribute_expect_success(self, endpoint, attribute): - cluster = Clusters.Objects.BooleanStateConfiguration - return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) - - @async_test_body - async def test_TC_BSENCFG_2_1(self): - - endpoint = self.user_params.get("endpoint", 1) - - self.print_step(1, "Commissioning, already done") - attributes = Clusters.BooleanStateConfiguration.Attributes - - self.print_step(2, "Read attribute list to determine supported attributes") - attribute_list = await self.read_ts_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) - - self.print_step(3, "Read SensitivityLevel attribute, if supported") - if attributes.SensitivityLevel.attribute_id in attribute_list: - sensitivity_level_dut = await self.read_ts_attribute_expect_success(endpoint=endpoint, attribute=attributes.SensitivityLevel) - asserts.assert_less(sensitivity_level_dut, Clusters.Objects.BooleanStateConfiguration.Enums.SensitivityEnum.kUnknownEnumValue, - "SensitivityLevel is not in valid range") - else: - logging.info("Test step skipped") - - self.print_step(4, "Read AlarmsActive attribute, if supported") - if attributes.AlarmsActive.attribute_id in attribute_list: - alarms_active_dut = await self.read_ts_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsActive) - asserts.assert_less_equal(alarms_active_dut, 0b00000011, "AlarmsActive is not in valid range") - else: - logging.info("Test step skipped") - - self.print_step(5, "Read AlarmsSuppressed attribute, if supported") - if attributes.AlarmsSuppressed.attribute_id in attribute_list: - alarms_suppressed_dut = await self.read_ts_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsSuppressed) - asserts.assert_less_equal(alarms_suppressed_dut, 0b00000011, "AlarmsSuppressed is not in valid range") - else: - logging.info("Test step skipped") - - self.print_step(5, "Read AlarmsEnabled attribute, if supported") - if attributes.AlarmsEnabled.attribute_id in attribute_list: - alarms_enabled_dut = await self.read_ts_attribute_expect_success(endpoint=endpoint, attribute=attributes.AlarmsEnabled) - asserts.assert_less_equal(alarms_enabled_dut, 0b00000011, "AlarmsEnabled is not in valid range") - else: - logging.info("Test step skipped") - - -if __name__ == "__main__": - default_matter_test_main()