From c7f753bb9f798de3eeb05ece41e2f17f9ba896a8 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:32:28 -0500 Subject: [PATCH 01/86] Occupancy Sensing cluster Python test scripts Consolidate previous TC-OCC-xx test script PRs (PR 34490, PR 34491, PR 34492, PR 34523) into this one upload. --- src/python_testing/TC_OCC_2_1.py | 216 ++++++++++++++++++++++++++++++ src/python_testing/TC_OCC_2_2.py | 78 +++++++++++ src/python_testing/TC_OCC_2_3.py | 106 +++++++++++++++ src/python_testing/TC_OCC_3_1.py | 115 ++++++++++++++++ src/python_testing/TC_OCC_3_2.py | 221 +++++++++++++++++++++++++++++++ 5 files changed, 736 insertions(+) create mode 100644 src/python_testing/TC_OCC_2_1.py create mode 100644 src/python_testing/TC_OCC_2_2.py create mode 100644 src/python_testing/TC_OCC_2_3.py create mode 100644 src/python_testing/TC_OCC_3_1.py create mode 100644 src/python_testing/TC_OCC_3_2.py diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py new file mode 100644 index 00000000000000..121c3bee45cf63 --- /dev/null +++ b/src/python_testing/TC_OCC_2_1.py @@ -0,0 +1,216 @@ +# +# Copyright (c) 2024 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.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_OCC_2_1(MatterBaseTest): + async def read_occ_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.OccupancySensing + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_OCC_2_1(self) -> str: + return "[TC-OCC-2.1] Attributes with DUT as Server" + + def steps_TC_OCC_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 Occupancy attribute."), + TestStep(4, "Read OccupancySensorType attribute."), + TestStep(5, "Read OccupancySensorTypeBitmap attribute."), + TestStep(6, "Read HoldTime attribute, if supported"), + TestStep(7, "Read HoldTimeLimits attribute, if supported"), + TestStep(8, "Read PIROccupiedToUnoccupiedDelay attribute, if supported"), + TestStep(9, "Read PIRUnoccupiedToOccupiedDelay attribute, if supported"), + TestStep(10, "Read PIRUnoccupiedToOccupiedThreshold attribute, if supported"), + TestStep(11, "Read UltrasonicOccupiedToUnoccupiedDelay attribute, if supported"), + TestStep(12, "Read UltrasonicUnoccupiedToOccupiedDelay attribute, if supported"), + TestStep(13, "Read UltrasonicUnoccupiedToOccupiedThreshold attribute, if supported"), + TestStep(14, "Read PhysicalContactOccupiedToUnoccupiedDelay attribute, if supported"), + TestStep(15, "Read PhysicalContactUnoccupiedToOccupiedDelay attribute, if supported"), + TestStep(16, "Read PhysicalContactUnoccupiedToOccupiedThreshold attribute, if supported") + ] + return steps + + def pics_TC_OCC_2_1(self) -> list[str]: + pics = [ + "OCC.S", + ] + return pics + + @async_test_body + async def test_TC_OCC_2_1(self): + + endpoint = self.user_params.get("endpoint", 1) + + self.step(1) + attributes = Clusters.OccupancySensing.Attributes + + self.step(2) + attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + self.step(3) + if attributes.Occupancy.attribute_id in attribute_list: + occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) + + if occupancy_dut != NullValue: + asserts.assert_less_equal(occupancy_dut, 0b00000001, "Occupancy attribute is not in valid range") + else: + logging.info("Test step skipped") + + self.step(4) + if attributes.OccupancySensorType.attribute_id in attribute_list: + occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) + + if occupancy_sensor_type_dut != NullValue: + asserts.assert_less(occupancy_sensor_type_dut, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUnknownEnumValue, + "OccupancySensorType is not in valid range") + else: + logging.info("Test step skipped") + + self.step(5) + if attributes.OccupancySensorTypeBitmap.attribute_id in attribute_list: + occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) + + if occupancy_sensor_type_bitmap_dut != NullValue: + asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") + else: + logging.info("Test step skipped") + + self.step(6) + if attributes.HoldTime.attribute_id in attribute_list: + hold_time_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) + + if hold_time_dut != NullValue: + asserts.assert_less_equal(hold_time_dut_dut, 0xFFFE, "HoldTime attribute is out of range") + asserts.assert_greater_equal(hold_time_dut_dut, 0, "HoldTime attribute is out of range") + else: + logging.info("Test step skipped") + + self.step(7) + if attributes.HoldTimeLimits.attribute_id in attribute_list: + hold_time_limits_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTimeLimits) + + if hold_time_limits_dut != NullValue: + asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMin, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") + asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMin, 0, "HoldTimeMin is not in valid range") + asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMax, 0xFFFE, "HoldTimeMin is not in valid range") + asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMax, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") + asserts.assert_less_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") + asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") + else: + logging.info("Test step skipped") + + self.step(8) + if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: + pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) + + if pir_otou_delay_dut != NullValue: + asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") + else: + logging.info("Test step skipped") + + self.step(9) + if attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + pir_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedDelay) + + if pir_utoo_delay_dut != NullValue: + asserts.assert_less_equal(pir_utoo_delay_dut, 0xFFFE, "PIRUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(pir_utoo_delay_dut, 0, "PIRUnoccupiedToOccupiedDelay is not in valid range") + else: + logging.info("Test step skipped") + + self.step(10) + if attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: + pir_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedThreshold) + + if pir_utoo_threshold_dut != NullValue: + asserts.assert_less_equal(pir_utoo_threshold_dut, 0xFE, "PIRUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_greater_equal(pir_utoo_threshold_dut, 0, "PIRUnoccupiedToOccupiedThreshold is not in valid range") + else: + logging.info("Test step skipped") + + self.step(11) + if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: + ultrasonic_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) + + if ultrasonic_otou_delay_dut != NullValue: + asserts.assert_less_equal(ultrasonic_otou_delay_dut, 0xFFFE, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_greater_equal(ultrasonic_otou_delay_dut, 0, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") + else: + logging.info("Test step skipped") + + self.step(12) + if attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + ultrasonic_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedDelay) + + if ultrasonic_utoo_delay_dut != NullValue: + asserts.assert_less_equal(ultrasonic_utoo_delay_dut, 0xFFFE, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(ultrasonic_utoo_delay_dut, 0, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") + else: + logging.info("Test step skipped") + + self.step(13) + if attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: + ultrasonic_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedThreshold) + + if ultrasonic_utoo_threshold_dut != NullValue: + asserts.assert_less_equal(ultrasonic_utoo_threshold_dut, 0xFE, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_greater_equal(ultrasonic_utoo_threshold_dut, 0, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") + else: + logging.info("Test step skipped") + + self.step(14) + if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list: + phycontact_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) + + if phycontact_otou_delay_dut != NullValue: + asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_greater_equal(phycontact_otou_delay_dut, 0, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") + else: + logging.info("Test step skipped") + + self.step(15) + if attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + phycontact_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedDelay) + + if phycontact_utoo_delay_dut != NullValue: + asserts.assert_less_equal(phycontact_utoo_delay_dut, 0xFFFE, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(phycontact_utoo_delay_dut, 0, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") + else: + logging.info("Test step skipped") + + self.step(16) + if attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: + phycontact_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedThreshold) + + if phycontact_utoo_threshold_dut != NullValue: + asserts.assert_less_equal(phycontact_utoo_threshold_dut, 0xFE, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_greater_equal(phycontact_utoo_threshold_dut, 0, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") + else: + logging.info("Test step skipped") + + +if __name__ == "__main__": + default_matter_test_main() \ No newline at end of file diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py new file mode 100644 index 00000000000000..3ec605347526c5 --- /dev/null +++ b/src/python_testing/TC_OCC_2_2.py @@ -0,0 +1,78 @@ +# +# Copyright (c) 2024 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.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_OCC_2_2(MatterBaseTest): + async def read_occ_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.OccupancySensing + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_OCC_2_2(self) -> str: + return "[TC-OCC-2.2] OccupancySensorTypeBitmap and OccupancySensorType interdependency with server as DUT" + + def steps_TC_OCC_2_2(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Read attribute list to determine supported attributes"), + TestStep(3, "Read OccupancySensorType attribute."), + TestStep(4, "Read OccupancySensorTypeBitmap attribute.") + ] + return steps + + def pics_TC_OCC_2_2(self) -> list[str]: + pics = [ + "OCC.S", + ] + return pics + + @async_test_body + async def test_TC_OCC_2_2(self): + + endpoint = self.user_params.get("endpoint", 1) + + self.step(1) + attributes = Clusters.OccupancySensing.Attributes + + self.step(2) + attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + self.step(3) + if attributes.OccupancySensorType.attribute_id in attribute_list: + occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) + + if occupancy_sensor_type_dut != NullValue: + asserts.assert_less_equal(occupancy_sensor_type_dut, 3, "OccupancySensorType is not in valid range") + asserts.assert_greater_equal(occupancy_sensor_type_dut, 0, "OccupancySensorType is not in valid range") + else: + logging.info("Test step skipped") + + self.step(4) + if attributes.OccupancySensorTypeBitmap.attribute_id in attribute_list: + occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) + + if occupancy_sensor_type_bitmap_dut != NullValue: + if occupancy_sensor_type_bitmap_dut == 1: + asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") + else: + logging.info("Test step skipped") diff --git a/src/python_testing/TC_OCC_2_3.py b/src/python_testing/TC_OCC_2_3.py new file mode 100644 index 00000000000000..1d06af1ffaa066 --- /dev/null +++ b/src/python_testing/TC_OCC_2_3.py @@ -0,0 +1,106 @@ +# +# Copyright (c) 2024 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 chip import ChipDeviceCtrl +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_OCC_2_3(MatterBaseTest): + async def read_occ_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.OccupancySensing + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_OCC_2_3(self) -> str: + return "[TC-OCC-2.3] HoldTime Backward Compatibility Test with server as DUT" + + def steps_TC_OCC_2_3(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commission DUT to TH", is_commissioning=True), + TestStep(2, "DUT supports HoldTime attribute. If DUT doesn’t support it, then stop and exit this test case."), + TestStep(3, "Based on the feature flag value table, read OccupancySensorType attribute from DUT"), + TestStep(4, "If TH reads 0 - PIR, TH reads PIROccupiedToUnoccupiedDelay attribute and its value should be same as HoldTime") + TestStep(5, "If TH reads 1 - Ultrasonic, TH reads UltrasonicOccupiedToUnoccupiedDelay attribute and its value should be same as HoldTime") + TestStep(6, "If TH reads 2 - PHY, TH reads PhysicalContactOccupiedToUnoccupiedDelay attribute and its value should be same as HoldTime") + ] + return steps + + def pics_TC_OCC_2_3(self) -> list[str]: + pics = [ + "OCC.S", + ] + return pics + + @async_test_body + async def test_TC_OCC_2_3(self): + + endpoint = self.user_params.get("endpoint", 1) + + self.step(1) + attributes = Clusters.OccupancySensing.Attributes + attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + self.step(2) + if attributes.HoldTime.attribute_id in attribute_list: + occupancy_hold_time_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) + + else: + logging.info("No HoldTime attribute supports. Terminate this test case") + return pics + + self.step(3) + if attributes.OccupancySensorType.attribute_id in attribute_list: + occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) + + if occupancy_sensor_type_dut != NullValue: + asserts.assert_less_equal(occupancy_sensor_type_dut, 3, "OccupancySensorType attribute is out of range") + asserts.assert_greater_equal(occupancy_sensor_type_dut, 0, "OccupancySensorType attribute is out of range") + + + else: + logging.info("OccupancySensorType attribute doesn't exist. Test step skipped") + + self.step(4) + if occupancy_sensor_type_dut == 0: + occupancy_pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) + + if occupancy_pir_otou_delay_dut != NullValue: + asserts.assert_equal(occupancy_pir_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") + + elif occupancy_sensor_type_dut == 1: + occupancy_us_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) + + if occupancy_us_otou_delay_dut != NullValue: + asserts.assert_equal(occupancy_us_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to UltrasonicOccupiedToUnoccupiedDelay") + + elif occupancy_sensor_type_dut == 2: + occupancy_pirus_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) + + if occupancy_pirus_otou_delay_dut != NullValue: + asserts.assert_equal(occupancy_pirus_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") + + elif occupancy_sensor_type_dut == 3: + occupancy_phy_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) + + if occupancy_phy_otou_delay_dut != NullValue: + asserts.assert_equal(occupancy_phy_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PhysicalContactOccupiedToUnoccupiedDelay") + else: + logging.info("OccupancySensorType attribute value is out of range") \ No newline at end of file diff --git a/src/python_testing/TC_OCC_3_1.py b/src/python_testing/TC_OCC_3_1.py new file mode 100644 index 00000000000000..a1214e275f2ae0 --- /dev/null +++ b/src/python_testing/TC_OCC_3_1.py @@ -0,0 +1,115 @@ +# +# Copyright (c) 2024 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 time + +from chip import ChipDeviceCtrl +from chip.interaction_model import Status +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_OCC_3_1(MatterBaseTest): + async def read_occ_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.OccupancySensing + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def desc_TC_OCC_3_1(self) -> str: + return "[TC-OCC-3.1] Primary functionality with server as DUT" + + def steps_TC_OCC_3_1(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commission DUT to TH and obtain DUT attribute list.", is_commissioning=True), + TestStep(2, "Change DUT HoldTime attribute value to 10 seconds."), + TestStep(3, "Do not trigger DUT occupancy sensing for the period of HoldTime. TH reads Occupancy attribute from DUT."), + TestStep(4, "Trigger DUT occupancy sensing to change the occupancy state and start a timer.") + TestStep(5, "After 10 seconds, TH reads Occupancy attribute from DUT.") + ] + return steps + + def pics_TC_OCC_3_1(self) -> list[str]: + pics = [ + "OCC.S", + ] + return pics + + @async_test_body + async def test_TC_OCC_3_1(self): + + endpoint = self.user_params.get("endpoint", 1) + + node_id = self.matter_test_config.dut_node_ids[0] + + hold_time = 10 # 10 seconds + + self.step(1) # commissioning and getting cluster attribute list + attributes = Clusters.OccupancySensing.Attributes + attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + self.step(2) + if attributes.HoldTime.attribute_id in attribute_list: + # write 10 as a HoldTime attibute + write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.HoldTime(hold_time))]) + asserts.assert_equal(write_res[0].status, Status.Success, "Write HoldTime failed") + + else: + logging.info("No HoldTime attribute supports. Just test occupancy attribute triggering") + + self.step(3) + # check if Occupancy attribute is 0 + occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) + + if occupancy_dut == 1: + # Don't trigger occupancy sensor to render occupancy attribute to 0 + if attributes.HoldTime.attribute_id in attribute_list: + time.sleep(hold_time) # wait 10 seconds + + else: # a user wait until a sensor specific time to change occupancy attribute to 0 + self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after the sensor occupancy is detection ready state (occupancy attribute = 0)") + + occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) + asserts.assert_equal(occupancy_dut, 0, "Occupancy attribute is 1.") + + self.step(4) + # Trigger occupancy sensor to change Occupancy attribute value to 1 => TEST ACTION on DUT + self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after a user triggers sensor occupancy.") + + # And then check if Occupancy attribute has changed. + occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) + asserts.assert_equal(occupancy_dut, 1, "Occupancy state is not 1") + + # step 5 + # check if Occupancy attribute is back to 0 after HoldTime attribute period + if attributes.HoldTime.attribute_id in attribute_list: + self.step(5) + + # Trigger occupancy sensor to change Occupancy attribute value to 1 => TEST ACTION on DUT + self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after a user triggers sensor occupancy.") + + # Start a timer based on HoldTime + time.sleep(hold_time) # wait 10 seconds + + occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) + asserts.assert_equal(occupancy_dut, 0, "Occupancy state is not 0 after HoldTime period") + + else: + + logging.info("No HoldTime attribute supports. Skip this test procedure.") + self.skip_step(5) \ No newline at end of file diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py new file mode 100644 index 00000000000000..80c7ec3f167ca3 --- /dev/null +++ b/src/python_testing/TC_OCC_3_2.py @@ -0,0 +1,221 @@ +# +# Copyright (c) 2024 Project CHIP (Matter) 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 chip import ChipDeviceCtrl +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, ClusterAttributeChangeAccumulator, TestStep, async_test_body, default_matter_test_main +from mobly import asserts + + +class TC_OCC_3_2(MatterBaseTest): + async def read_occ_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.OccupancySensing + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + def _await_sequence_of_reports(self, report_queue: queue.Queue, endpoint_id: int, attribute: TypedAttributePath, sequence: list[Any], timeout_sec: float): + start_time = time.time() + elapsed = 0.0 + time_remaining = timeout_sec + + sequence_idx = 0 + actual_values = [] + + while time_remaining > 0: + expected_value = sequence[sequence_idx] + logging.info(f"Expecting value {expected_value} for attribute {attribute} on endpoint {endpoint_id}") + try: + item: AttributeValue = report_queue.get(block=True, timeout=time_remaining) + + # Track arrival of all values for the given attribute. + if item.endpoint_id == endpoint_id and item.attribute == attribute: + actual_values.append(item.value) + + if item.value == expected_value: + logging.info(f"Got expected attribute change {sequence_idx+1}/{len(sequence)} for attribute {attribute}") + sequence_idx += 1 + else: + asserts.assert_equal(item.value, expected_value, + msg="Did not get expected attribute value in correct sequence.") + + # We are done waiting when we have accumulated all results. + if sequence_idx == len(sequence): + logging.info("Got all attribute changes, done waiting.") + return + except queue.Empty: + # No error, we update timeouts and keep going + pass + + elapsed = time.time() - start_time + time_remaining = timeout_sec - elapsed + + asserts.fail(f"Did not get full sequence {sequence} in {timeout_sec:.1f} seconds. Got {actual_values} before time-out.") + + def desc_TC_OCC_3_2(self) -> str: + return "[TC-OCC-3.2] Subscription Report Verification with server as DUT" + + def steps_TC_OCC_3_2(self) -> list[TestStep]: + steps = [ + TestStep(1, "Commission DUT to TH if not already done", is_commissioning=True), + TestStep(2, "TH establishes a wildcard subscription to all attributes on Occupancy Sensing Cluster on the endpoint under test"), + TestStep(3a, "Don’t trigger DUT for occupancy state change."), + TestStep(3b, "TH reads DUT Occupancy attribute and saves the initial value as initial") + TestStep(3c, "Trigger DUT to change the occupancy state.") + TestStep(3d, "TH awaits a ReportDataMessage containing an attribute report for DUT Occupancy attribute.") + TestStep(4a, "Check if DUT supports HoldTime attribute, If not supported, then stop and skip the rest of test cases."), + TestStep(4b, "TH reads DUT HoldTime attribute and saves the initial value as initial") + TestStep(4c, "TH writes 10 seconds to DUT HoldTime attribute.") + TestStep(4d, "TH awaits a ReportDataMessage containing an attribute report for DUT HoldTime attribute.") + TestStep(5a, "Check if DUT supports DUT feature flag PIR or OTHER, If not supported, then stop and skip to 6a."), + TestStep(5b, "TH reads DUT PIROccupiedToUnoccupiedDelay attribute and saves the initial value as initial") + TestStep(5c, "TH writes 10 seconds to DUT PIROccupiedToUnoccupiedDelay attribute.") + TestStep(5d, "TH awaits a ReportDataMessage containing an attribute report for DUT PIROccupiedToUnoccupiedDelay attribute.") + TestStep(6a, "Check if DUT supports DUT feature flag US, If not supported, then stop and skip to 7a."), + TestStep(6b, "TH reads DUT UltrasonicOccupiedToUnoccupiedDelay attribute and saves the initial value as initial") + TestStep(6c, "TH writes 10 seconds to DUT UltrasonicOccupiedToUnoccupiedDelay attribute.") + TestStep(6d, "TH awaits a ReportDataMessage containing an attribute report for DUT UltrasonicOccupiedToUnoccupiedDelay attribute.") + TestStep(7a, "Check if DUT supports DUT feature flag PHY, If not supported, terminate this test case."), + TestStep(7b, "TH reads DUT PhysicalContactOccupiedToUnoccupiedDelay attribute and saves the initial value as initial") + TestStep(7c, "TH writes 10 seconds to DUT PhysicalContactOccupiedToUnoccupiedDelay attribute.") + TestStep(7d, "TH awaits a ReportDataMessage containing an attribute report for DUT PhysicalContactOccupiedToUnoccupiedDelay attribute.") + ] + return steps + + def pics_TC_OCC_3_2(self) -> list[str]: + pics = [ + "OCC.S", + ] + return pics + + @async_test_body + async def test_TC_OCC_3_2(self): + + endpoint = self.user_params.get("endpoint", 1) + endpoint_id = self.matter_test_config.endpoint + node_id = self.matter_test_config.dut_node_ids[0] + post_prompt_settle_delay_seconds = 10.0 + cluster = Clusters.Objects.OccupancySensing + + + self.step(1) + attributes = Clusters.OccupancySensing.Attributes + attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) + + self.step(2) + # min interval = 0, and max interval = 30 seconds + attrib_listener = ClusterAttributeChangeAccumulator(Clusters.Objects.OccupancySensing) + await attrib_listener.start(ChipDeviceCtrl, node_id, endpoint=endpoint_id) + + self.step(3a) + self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after DUT goes back to unoccupied state.") + + self.step(3b) + if attributes.Occupancy.attribute_id in attribute_list: + initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) + + if initial_dut != NullValue: + asserts.assert_equal(initial_dut, 0, "Occupancy attribute is still detected state") + + self.step(3c) + self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after the sensor occupancy is triggered and its occupancy state changed.") + + self.step(3d) + self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.Occupancy, sequence=[ + 0, 1], timeout_sec=post_prompt_settle_delay_seconds) + + self.step(4a) + if attributes.HoldTime.attribute_id not in attribute_list: + logging.info("No HoldTime attribute supports. Terminate this test case") + self.skip_all_remaining_steps("4b") + self.step(4b) + initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) + + self.step(4c) + # write 10 as a HoldTime attibute + write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.HoldTime(10))]) + + self.step(4d) + self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.HoldTime, sequence=[ + initial_dut, 10], timeout_sec=post_prompt_settle_delay_seconds) + + self.step(5a) + if (Clusters.OccupancySensing.Bitmaps.Feature.kPIR | Clusters.OccupancySensing.Bitmaps.Feature.kOTHER) != 1: + self.skip(5b) + self.skip(5c) + self.skip(5d) + + self.step(5b) + if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: + initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) + + else: + logging.info("No PIROccupiedToUnoccupiedDelay attribute supports. Terminate this test case") + self.skip_all_remaining_steps(5c) + + self.step(5c) + # write 10 for the new attribute value + write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PIROccupiedToUnoccupiedDelay(10))]) + + self.step(5d) + self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PIROccupiedToUnoccupiedDelay, sequence=[ + initial_dut, 10], timeout_sec=post_prompt_settle_delay_seconds) + + self.step(6a) + if Clusters.OccupancySensing.Bitmaps.Feature.kUS != 1: + self.skip(6b) + self.skip(6c) + self.skip(6d) + + self.step(6b) + if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: + initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) + + else: + logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Terminate this test case") + self.skip_all_remaining_steps(6c) + + self.step(6c) + # write 10 for the new attribute value + write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.UltrasonicOccupiedToUnoccupiedDelay(10))]) + + self.step(6d) + self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.UltrasonicOccupiedToUnoccupiedDelay, sequence=[ + initial_dut, 10], timeout_sec=post_prompt_settle_delay_seconds) + + self.step(7a) + if Clusters.OccupancySensing.Bitmaps.Feature.kPHY != 1: + self.skip(7b) + self.skip(7c) + self.skip(7d) + + self.step(7b) + if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list: + initial_dut = await self.t_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) + + else: + logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Terminate this test case") + self.skip_all_remaining_steps(7c) + + self.step(7c) + # write 10 for the new attribute value + write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PhysicalContactOccupiedToUnoccupiedDelay(10))]) + + self.step(7d) + self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PhysicalContactOccupiedToUnoccupiedDelay, sequence=[ + initial_dut, 10], timeout_sec=post_prompt_settle_delay_seconds) From 5e4ca221bd782d21fa7cd9ccd417f9bee76df3da Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:47:13 -0500 Subject: [PATCH 02/86] Update TC_OCC_2_1.py --- src/python_testing/TC_OCC_2_1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 121c3bee45cf63..ff0dd65e2a8297 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -181,7 +181,7 @@ async def test_TC_OCC_2_1(self): else: logging.info("Test step skipped") - self.step(14) + self.step(14) if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list: phycontact_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) @@ -213,4 +213,4 @@ async def test_TC_OCC_2_1(self): if __name__ == "__main__": - default_matter_test_main() \ No newline at end of file + default_matter_test_main() From 092e8643bd4227f0fa44e3db51118051491cbd1f Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:49:48 -0500 Subject: [PATCH 03/86] Update TC_OCC_2_2.py syntax error --- src/python_testing/TC_OCC_2_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 3ec605347526c5..e0deb5c30ccff4 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -73,6 +73,6 @@ async def test_TC_OCC_2_2(self): if occupancy_sensor_type_bitmap_dut != NullValue: if occupancy_sensor_type_bitmap_dut == 1: - asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") + asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") else: logging.info("Test step skipped") From 5eeadf7046020d35b2eb2fe068e2dc95755df038 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:51:08 -0500 Subject: [PATCH 04/86] Update TC_OCC_2_3.py --- src/python_testing/TC_OCC_2_3.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python_testing/TC_OCC_2_3.py b/src/python_testing/TC_OCC_2_3.py index 1d06af1ffaa066..e3927c08d9f2ac 100644 --- a/src/python_testing/TC_OCC_2_3.py +++ b/src/python_testing/TC_OCC_2_3.py @@ -37,8 +37,8 @@ def steps_TC_OCC_2_3(self) -> list[TestStep]: TestStep(1, "Commission DUT to TH", is_commissioning=True), TestStep(2, "DUT supports HoldTime attribute. If DUT doesn’t support it, then stop and exit this test case."), TestStep(3, "Based on the feature flag value table, read OccupancySensorType attribute from DUT"), - TestStep(4, "If TH reads 0 - PIR, TH reads PIROccupiedToUnoccupiedDelay attribute and its value should be same as HoldTime") - TestStep(5, "If TH reads 1 - Ultrasonic, TH reads UltrasonicOccupiedToUnoccupiedDelay attribute and its value should be same as HoldTime") + TestStep(4, "If TH reads 0 - PIR, TH reads PIROccupiedToUnoccupiedDelay attribute and its value should be same as HoldTime"), + TestStep(5, "If TH reads 1 - Ultrasonic, TH reads UltrasonicOccupiedToUnoccupiedDelay attribute and its value should be same as HoldTime"), TestStep(6, "If TH reads 2 - PHY, TH reads PhysicalContactOccupiedToUnoccupiedDelay attribute and its value should be same as HoldTime") ] return steps @@ -103,4 +103,4 @@ async def test_TC_OCC_2_3(self): if occupancy_phy_otou_delay_dut != NullValue: asserts.assert_equal(occupancy_phy_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PhysicalContactOccupiedToUnoccupiedDelay") else: - logging.info("OccupancySensorType attribute value is out of range") \ No newline at end of file + logging.info("OccupancySensorType attribute value is out of range") From 1d67a6317cc6a078364a6032d00bf6c0335ed8c0 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:51:45 -0500 Subject: [PATCH 05/86] Update TC_OCC_3_1.py --- src/python_testing/TC_OCC_3_1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_OCC_3_1.py b/src/python_testing/TC_OCC_3_1.py index a1214e275f2ae0..7ce08ff87f59d1 100644 --- a/src/python_testing/TC_OCC_3_1.py +++ b/src/python_testing/TC_OCC_3_1.py @@ -39,7 +39,7 @@ def steps_TC_OCC_3_1(self) -> list[TestStep]: TestStep(1, "Commission DUT to TH and obtain DUT attribute list.", is_commissioning=True), TestStep(2, "Change DUT HoldTime attribute value to 10 seconds."), TestStep(3, "Do not trigger DUT occupancy sensing for the period of HoldTime. TH reads Occupancy attribute from DUT."), - TestStep(4, "Trigger DUT occupancy sensing to change the occupancy state and start a timer.") + TestStep(4, "Trigger DUT occupancy sensing to change the occupancy state and start a timer."), TestStep(5, "After 10 seconds, TH reads Occupancy attribute from DUT.") ] return steps @@ -112,4 +112,4 @@ async def test_TC_OCC_3_1(self): else: logging.info("No HoldTime attribute supports. Skip this test procedure.") - self.skip_step(5) \ No newline at end of file + self.skip_step(5) From efacda8b1cb8472290c54e3ec66343ef9d8eb96b Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:52:38 -0500 Subject: [PATCH 06/86] Update TC_OCC_3_2.py --- src/python_testing/TC_OCC_3_2.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py index 80c7ec3f167ca3..d19ad2db0e7563 100644 --- a/src/python_testing/TC_OCC_3_2.py +++ b/src/python_testing/TC_OCC_3_2.py @@ -75,24 +75,24 @@ def steps_TC_OCC_3_2(self) -> list[TestStep]: TestStep(1, "Commission DUT to TH if not already done", is_commissioning=True), TestStep(2, "TH establishes a wildcard subscription to all attributes on Occupancy Sensing Cluster on the endpoint under test"), TestStep(3a, "Don’t trigger DUT for occupancy state change."), - TestStep(3b, "TH reads DUT Occupancy attribute and saves the initial value as initial") - TestStep(3c, "Trigger DUT to change the occupancy state.") - TestStep(3d, "TH awaits a ReportDataMessage containing an attribute report for DUT Occupancy attribute.") + TestStep(3b, "TH reads DUT Occupancy attribute and saves the initial value as initial"), + TestStep(3c, "Trigger DUT to change the occupancy state."), + TestStep(3d, "TH awaits a ReportDataMessage containing an attribute report for DUT Occupancy attribute."), TestStep(4a, "Check if DUT supports HoldTime attribute, If not supported, then stop and skip the rest of test cases."), - TestStep(4b, "TH reads DUT HoldTime attribute and saves the initial value as initial") - TestStep(4c, "TH writes 10 seconds to DUT HoldTime attribute.") - TestStep(4d, "TH awaits a ReportDataMessage containing an attribute report for DUT HoldTime attribute.") + TestStep(4b, "TH reads DUT HoldTime attribute and saves the initial value as initial"), + TestStep(4c, "TH writes 10 seconds to DUT HoldTime attribute."), + TestStep(4d, "TH awaits a ReportDataMessage containing an attribute report for DUT HoldTime attribute."), TestStep(5a, "Check if DUT supports DUT feature flag PIR or OTHER, If not supported, then stop and skip to 6a."), - TestStep(5b, "TH reads DUT PIROccupiedToUnoccupiedDelay attribute and saves the initial value as initial") - TestStep(5c, "TH writes 10 seconds to DUT PIROccupiedToUnoccupiedDelay attribute.") - TestStep(5d, "TH awaits a ReportDataMessage containing an attribute report for DUT PIROccupiedToUnoccupiedDelay attribute.") + TestStep(5b, "TH reads DUT PIROccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), + TestStep(5c, "TH writes 10 seconds to DUT PIROccupiedToUnoccupiedDelay attribute."), + TestStep(5d, "TH awaits a ReportDataMessage containing an attribute report for DUT PIROccupiedToUnoccupiedDelay attribute."), TestStep(6a, "Check if DUT supports DUT feature flag US, If not supported, then stop and skip to 7a."), - TestStep(6b, "TH reads DUT UltrasonicOccupiedToUnoccupiedDelay attribute and saves the initial value as initial") - TestStep(6c, "TH writes 10 seconds to DUT UltrasonicOccupiedToUnoccupiedDelay attribute.") - TestStep(6d, "TH awaits a ReportDataMessage containing an attribute report for DUT UltrasonicOccupiedToUnoccupiedDelay attribute.") + TestStep(6b, "TH reads DUT UltrasonicOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), + TestStep(6c, "TH writes 10 seconds to DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), + TestStep(6d, "TH awaits a ReportDataMessage containing an attribute report for DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), TestStep(7a, "Check if DUT supports DUT feature flag PHY, If not supported, terminate this test case."), - TestStep(7b, "TH reads DUT PhysicalContactOccupiedToUnoccupiedDelay attribute and saves the initial value as initial") - TestStep(7c, "TH writes 10 seconds to DUT PhysicalContactOccupiedToUnoccupiedDelay attribute.") + TestStep(7b, "TH reads DUT PhysicalContactOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), + TestStep(7c, "TH writes 10 seconds to DUT PhysicalContactOccupiedToUnoccupiedDelay attribute."), TestStep(7d, "TH awaits a ReportDataMessage containing an attribute report for DUT PhysicalContactOccupiedToUnoccupiedDelay attribute.") ] return steps From 423e9639934dab16a93397bad194483d29be7cda Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Mon, 29 Jul 2024 18:31:48 -0500 Subject: [PATCH 07/86] Update TC_OCC_2_1.py Accommodated recent test plan attribute conformance and Cecille comments --- src/python_testing/TC_OCC_2_1.py | 157 ++++++++++++++----------------- 1 file changed, 71 insertions(+), 86 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index ff0dd65e2a8297..dd91f99f9cfb7c 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -65,151 +65,136 @@ async def test_TC_OCC_2_1(self): self.step(1) attributes = Clusters.OccupancySensing.Attributes - - self.step(2) attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) - self.step(3) + self.step(2) if attributes.Occupancy.attribute_id in attribute_list: occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) - - if occupancy_dut != NullValue: - asserts.assert_less_equal(occupancy_dut, 0b00000001, "Occupancy attribute is not in valid range") + asserts.assert_less_equal(occupancy_dut, 0b00000001, "Occupancy attribute is not in valid range") else: - logging.info("Test step skipped") + logging.info("Occupancy attribute is a mandatory attribute. Test step fails.")logging.info() - self.step(4) + self.step(3) if attributes.OccupancySensorType.attribute_id in attribute_list: occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) - - if occupancy_sensor_type_dut != NullValue: - asserts.assert_less(occupancy_sensor_type_dut, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUnknownEnumValue, - "OccupancySensorType is not in valid range") + asserts.assert_less(occupancy_sensor_type_dut, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUnknownEnumValue, + "OccupancySensorType is not in valid range") else: - logging.info("Test step skipped") + logging.info("This attribute is a mandatory attribute. Test step fails") - self.step(5) + self.step(4) if attributes.OccupancySensorTypeBitmap.attribute_id in attribute_list: occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) - - if occupancy_sensor_type_bitmap_dut != NullValue: - asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") + asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") else: - logging.info("Test step skipped") + logging.info("This attribute is a mandatory attribute. Test step fails") - self.step(6) - if attributes.HoldTime.attribute_id in attribute_list: - hold_time_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) - - if hold_time_dut != NullValue: - asserts.assert_less_equal(hold_time_dut_dut, 0xFFFE, "HoldTime attribute is out of range") - asserts.assert_greater_equal(hold_time_dut_dut, 0, "HoldTime attribute is out of range") - else: - logging.info("Test step skipped") - - self.step(7) + self.step(5) if attributes.HoldTimeLimits.attribute_id in attribute_list: - hold_time_limits_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTimeLimits) + if attributes.HoldTime.attribute_id in attribute_list: # check HoldTime conformance + hold_time_limits_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTimeLimits) - if hold_time_limits_dut != NullValue: asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMin, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMin, 0, "HoldTimeMin is not in valid range") asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMax, 0xFFFE, "HoldTimeMin is not in valid range") asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMax, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") asserts.assert_less_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") + else: + loggin.info("HoldTime conformance violation. Test step skipped") else: logging.info("Test step skipped") + + self.step(6) + if attributes.HoldTime.attribute_id in attribute_list: + hold_time_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) - self.step(8) - if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: + asserts.assert_less_equal(hold_time_dut_dut, 0xFFFE, "HoldTime attribute is out of range") + asserts.assert_greater_equal(hold_time_dut_dut, 0, "HoldTime attribute is out of range") + else: + logging.info("HoldTime not supported. The rest of legacy attribute test can be skipped") + self.skip_all_remaining_steps(7) + + self.step(7) + if (attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list) & ((occupancy_sensor_type_bitmap_dut == 0b00000001) | ((occupancy_sensor_type_bitmap_dut != 0b00000001)&(occupancy_sensor_type_bitmap_dut != 0b00000010)&(occupancy_sensor_type_bitmap_dut != 0b00000100))): pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) - if pir_otou_delay_dut != NullValue: - asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") - asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") else: - logging.info("Test step skipped") + logging.info("PIROccupiedToUnoccupiedDelay not supported. Test step skipped") - self.step(9) - if attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + self.step(8) + if (attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list) & (attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list): + pir_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedDelay) - - if pir_utoo_delay_dut != NullValue: - asserts.assert_less_equal(pir_utoo_delay_dut, 0xFFFE, "PIRUnoccupiedToOccupiedDelay is not in valid range") - asserts.assert_greater_equal(pir_utoo_delay_dut, 0, "PIRUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_less_equal(pir_utoo_delay_dut, 0xFFFE, "PIRUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(pir_utoo_delay_dut, 0, "PIRUnoccupiedToOccupiedDelay is not in valid range") else: - logging.info("Test step skipped") + logging.info("PIRUnoccupiedToOccupiedDelay not supported. Test step skipped") - self.step(10) - if attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: + self.step(9) + if (attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list) & (attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list): pir_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedThreshold) - if pir_utoo_threshold_dut != NullValue: - asserts.assert_less_equal(pir_utoo_threshold_dut, 0xFE, "PIRUnoccupiedToOccupiedThreshold is not in valid range") - asserts.assert_greater_equal(pir_utoo_threshold_dut, 0, "PIRUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_less_equal(pir_utoo_threshold_dut, 0xFE, "PIRUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_greater_equal(pir_utoo_threshold_dut, 0, "PIRUnoccupiedToOccupiedThreshold is not in valid range") else: - logging.info("Test step skipped") + logging.info("PIRUnoccupiedToOccupiedThreshold not supported. Test step skipped") - self.step(11) - if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: + self.step(10) + if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list & (occupancy_sensor_type_bitmap_dut == 0b00000010): ultrasonic_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) - if ultrasonic_otou_delay_dut != NullValue: - asserts.assert_less_equal(ultrasonic_otou_delay_dut, 0xFFFE, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") - asserts.assert_greater_equal(ultrasonic_otou_delay_dut, 0, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_less_equal(ultrasonic_otou_delay_dut, 0xFFFE, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_greater_equal(ultrasonic_otou_delay_dut, 0, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") else: - logging.info("Test step skipped") + logging.info("UltrasonicOccupiedToUnoccupiedDelay not supported. Test step skipped") - self.step(12) - if attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + self.step(11) + if attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list & attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: ultrasonic_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedDelay) - - if ultrasonic_utoo_delay_dut != NullValue: - asserts.assert_less_equal(ultrasonic_utoo_delay_dut, 0xFFFE, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") - asserts.assert_greater_equal(ultrasonic_utoo_delay_dut, 0, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") + + asserts.assert_less_equal(ultrasonic_utoo_delay_dut, 0xFFFE, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(ultrasonic_utoo_delay_dut, 0, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") else: - logging.info("Test step skipped") + logging.info("UltrasonicUnoccupiedToOccupiedDelay not supported. Test step skipped") - self.step(13) - if attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: + self.step(12) + if attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list & attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list: ultrasonic_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedThreshold) if ultrasonic_utoo_threshold_dut != NullValue: asserts.assert_less_equal(ultrasonic_utoo_threshold_dut, 0xFE, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") asserts.assert_greater_equal(ultrasonic_utoo_threshold_dut, 0, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") else: - logging.info("Test step skipped") + logging.info("UltrasonicUnoccupiedToOccupiedThreshold not supported. Test step skipped") - self.step(14) - if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list: + self.step(13) + if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list & (occupancy_sensor_type_bitmap_dut == 0b00000100): phycontact_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) - - if phycontact_otou_delay_dut != NullValue: - asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") - asserts.assert_greater_equal(phycontact_otou_delay_dut, 0, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") + + asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_greater_equal(phycontact_otou_delay_dut, 0, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") else: - logging.info("Test step skipped") + logging.info("PhysicalContactOccupiedToUnoccupiedDelay not supported. Test step skipped") - self.step(15) - if attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + self.step(14) + if attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list & attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: phycontact_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedDelay) - - if phycontact_utoo_delay_dut != NullValue: - asserts.assert_less_equal(phycontact_utoo_delay_dut, 0xFFFE, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") - asserts.assert_greater_equal(phycontact_utoo_delay_dut, 0, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_less_equal(phycontact_utoo_delay_dut, 0xFFFE, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(phycontact_utoo_delay_dut, 0, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") else: - logging.info("Test step skipped") + logging.info("PhysicalContactUnoccupiedToOccupiedDelay not supported. Test step skipped") - self.step(16) - if attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: + self.step(15) + if attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list & attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list: phycontact_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedThreshold) - if phycontact_utoo_threshold_dut != NullValue: - asserts.assert_less_equal(phycontact_utoo_threshold_dut, 0xFE, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") - asserts.assert_greater_equal(phycontact_utoo_threshold_dut, 0, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_less_equal(phycontact_utoo_threshold_dut, 0xFE, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_greater_equal(phycontact_utoo_threshold_dut, 0, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") else: - logging.info("Test step skipped") + logging.info("PhysicalContactUnoccupiedToOccupiedThreshold not supported. Test step skipped") if __name__ == "__main__": From 889f2f49169bf31f2f6149127cd256daa22acd5d Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:38:15 -0500 Subject: [PATCH 08/86] Update TC_OCC_2_2.py Reflected table 2.7.6.2 --- src/python_testing/TC_OCC_2_2.py | 59 ++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index e0deb5c30ccff4..585b3f828c924c 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -34,9 +34,8 @@ def desc_TC_OCC_2_2(self) -> str: def steps_TC_OCC_2_2(self) -> list[TestStep]: steps = [ TestStep(1, "Commissioning, already done", is_commissioning=True), - TestStep(2, "Read attribute list to determine supported attributes"), - TestStep(3, "Read OccupancySensorType attribute."), - TestStep(4, "Read OccupancySensorTypeBitmap attribute.") + TestStep(2, "Read OccupancySensorType attribute with repect to featureMap."), + TestStep(3, "Read OccupancySensorTypeBitmap attribute with repect to featureMap.") ] return steps @@ -51,28 +50,58 @@ async def test_TC_OCC_2_2(self): endpoint = self.user_params.get("endpoint", 1) + feature_map_PIR = Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared + feature_map_US = Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic + feature_map_PHY = Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact + self.step(1) attributes = Clusters.OccupancySensing.Attributes - - self.step(2) attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) - self.step(3) + self.step(2) if attributes.OccupancySensorType.attribute_id in attribute_list: occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) + + if (feature_map_PIR == 0)&(feature_map_US == 0)&(feature_map_PHY == 0): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") + elif (feature_map_PIR == 1)&(feature_map_US == 0)&(feature_map_PHY == 0): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") + elif (feature_map_PIR == 0)&(feature_map_US == 1)&(feature_map_PHY == 0): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonci, "OccupancySensorType is not Ultrasonic") + elif (feature_map_PIR == 1)&(feature_map_US == 1)&(feature_map_PHY == 0): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, "OccupancySensorType is not PIRAndUltrasonic") + elif (feature_map_PIR == 0)&(feature_map_US == 0)&(feature_map_PHY == 1): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, "OccupancySensorType is not PhysicalContact") + elif (feature_map_PIR == 1)&(feature_map_US == 0)&(feature_map_PHY == 1): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") + elif (feature_map_PIR == 0)&(feature_map_US == 1)&(feature_map_PHY == 1): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") + elif (feature_map_PIR == 1)&(feature_map_US == 1)&(feature_map_PHY == 1): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, "OccupancySensorType is not PIRAndUltrasonic") - if occupancy_sensor_type_dut != NullValue: - asserts.assert_less_equal(occupancy_sensor_type_dut, 3, "OccupancySensorType is not in valid range") - asserts.assert_greater_equal(occupancy_sensor_type_dut, 0, "OccupancySensorType is not in valid range") else: - logging.info("Test step skipped") + logging.info("OccupancySensorType mandatory attribute is not supported. Test step skipped") - self.step(4) + self.step(3) if attributes.OccupancySensorTypeBitmap.attribute_id in attribute_list: occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) - if occupancy_sensor_type_bitmap_dut != NullValue: - if occupancy_sensor_type_bitmap_dut == 1: - asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") + if (feature_map_PIR == 0)&(feature_map_US == 0)&(feature_map_PHY == 0): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") + elif (feature_map_PIR == 1)&(feature_map_US == 0)&(feature_map_PHY == 0): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") + elif (feature_map_PIR == 0)&(feature_map_US == 1)&(feature_map_PHY == 0): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, "OccupancySensorType is not Ultrasonic") + elif (feature_map_PIR == 1)&(feature_map_US == 1)&(feature_map_PHY == 0): + asserts.assert_equal(occupancy_sensor_type_dut, 0b00000011, "OccupancySensorType is not PIR+Ultrasonic") + elif (feature_map_PIR == 0)&(feature_map_US == 0)&(feature_map_PHY == 1): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, "OccupancySensorType is not PhysicalContact") + elif (feature_map_PIR == 1)&(feature_map_US == 0)&(feature_map_PHY == 1): + asserts.assert_equal(occupancy_sensor_type_dut, 0b00000101, "OccupancySensorType is not PIR + PhysicalContact") + elif (feature_map_PIR == 0)&(feature_map_US == 1)&(feature_map_PHY == 1): + asserts.assert_equal(occupancy_sensor_type_dut, 0b00000110, "OccupancySensorType is not PhysicalContact + Ultrasonic") + elif (feature_map_PIR == 1)&(feature_map_US == 1)&(feature_map_PHY == 1): + asserts.assert_equal(occupancy_sensor_type_dut, 0b00000111, "OccupancySensorType is not PIR+Ultrasonic+Ultrasonic") + else: - logging.info("Test step skipped") + logging.info("OccupancySensorTypeBitmap mandatory attribute is not supported. Test step skipped") From b60b5f07b364bbcfbe09a44ed5072b68f075ef13 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:51:41 -0500 Subject: [PATCH 09/86] Update TC_OCC_2_3.py Modified according to comments --- src/python_testing/TC_OCC_2_3.py | 33 +++++++++++++------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/python_testing/TC_OCC_2_3.py b/src/python_testing/TC_OCC_2_3.py index e3927c08d9f2ac..19341226e3f826 100644 --- a/src/python_testing/TC_OCC_2_3.py +++ b/src/python_testing/TC_OCC_2_3.py @@ -70,37 +70,30 @@ async def test_TC_OCC_2_3(self): if attributes.OccupancySensorType.attribute_id in attribute_list: occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) - if occupancy_sensor_type_dut != NullValue: - asserts.assert_less_equal(occupancy_sensor_type_dut, 3, "OccupancySensorType attribute is out of range") - asserts.assert_greater_equal(occupancy_sensor_type_dut, 0, "OccupancySensorType attribute is out of range") - - + asserts.assert_less_equal(occupancy_sensor_type_dut, 3, "OccupancySensorType attribute is out of range") + asserts.assert_greater_equal(occupancy_sensor_type_dut, 0, "OccupancySensorType attribute is out of range") else: logging.info("OccupancySensorType attribute doesn't exist. Test step skipped") self.step(4) - if occupancy_sensor_type_dut == 0: + if occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir: occupancy_pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) - - if occupancy_pir_otou_delay_dut != NullValue: - asserts.assert_equal(occupancy_pir_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") + + asserts.assert_equal(occupancy_pir_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") - elif occupancy_sensor_type_dut == 1: + elif occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic: occupancy_us_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) - if occupancy_us_otou_delay_dut != NullValue: - asserts.assert_equal(occupancy_us_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to UltrasonicOccupiedToUnoccupiedDelay") + asserts.assert_equal(occupancy_us_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to UltrasonicOccupiedToUnoccupiedDelay") - elif occupancy_sensor_type_dut == 2: + elif occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic: occupancy_pirus_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) - - if occupancy_pirus_otou_delay_dut != NullValue: - asserts.assert_equal(occupancy_pirus_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") - elif occupancy_sensor_type_dut == 3: + asserts.assert_equal(occupancy_pirus_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") + + elif occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact: occupancy_phy_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) - - if occupancy_phy_otou_delay_dut != NullValue: - asserts.assert_equal(occupancy_phy_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PhysicalContactOccupiedToUnoccupiedDelay") + + asserts.assert_equal(occupancy_phy_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PhysicalContactOccupiedToUnoccupiedDelay") else: logging.info("OccupancySensorType attribute value is out of range") From 2f2129eb9a1887412d86660654e74d68a772ddf0 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:55:56 -0500 Subject: [PATCH 10/86] Update TC_OCC_3_1.py Add CLI --- src/python_testing/TC_OCC_3_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_3_1.py b/src/python_testing/TC_OCC_3_1.py index 7ce08ff87f59d1..d1e4a7273ec04f 100644 --- a/src/python_testing/TC_OCC_3_1.py +++ b/src/python_testing/TC_OCC_3_1.py @@ -79,7 +79,7 @@ async def test_TC_OCC_3_1(self): if occupancy_dut == 1: # Don't trigger occupancy sensor to render occupancy attribute to 0 if attributes.HoldTime.attribute_id in attribute_list: - time.sleep(hold_time) # wait 10 seconds + self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after not triggering the sensor for HoldTime period to ensure occupancy attribute = 0") else: # a user wait until a sensor specific time to change occupancy attribute to 0 self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after the sensor occupancy is detection ready state (occupancy attribute = 0)") From bb65bb6d237924c8d1284a5b38ea5c1ffdbe84f3 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:22:01 -0500 Subject: [PATCH 11/86] Update TC_OCC_3_2.py Fixed some errors and added some random values for subscription testing --- src/python_testing/TC_OCC_3_2.py | 51 ++++++++++++++++---------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py index d19ad2db0e7563..7a9b5dec231d0f 100644 --- a/src/python_testing/TC_OCC_3_2.py +++ b/src/python_testing/TC_OCC_3_2.py @@ -73,26 +73,26 @@ def desc_TC_OCC_3_2(self) -> str: def steps_TC_OCC_3_2(self) -> list[TestStep]: steps = [ TestStep(1, "Commission DUT to TH if not already done", is_commissioning=True), - TestStep(2, "TH establishes a wildcard subscription to all attributes on Occupancy Sensing Cluster on the endpoint under test"), + TestStep(2, "TH establishes a wildcard subscription to all attributes on Occupancy Sensing Cluster on the endpoint under test. Subscription min interval = 0 and max interval = 30 seconds."), TestStep(3a, "Don’t trigger DUT for occupancy state change."), TestStep(3b, "TH reads DUT Occupancy attribute and saves the initial value as initial"), TestStep(3c, "Trigger DUT to change the occupancy state."), TestStep(3d, "TH awaits a ReportDataMessage containing an attribute report for DUT Occupancy attribute."), TestStep(4a, "Check if DUT supports HoldTime attribute, If not supported, then stop and skip the rest of test cases."), TestStep(4b, "TH reads DUT HoldTime attribute and saves the initial value as initial"), - TestStep(4c, "TH writes 10 seconds to DUT HoldTime attribute."), + TestStep(4c, "TH writes a different value to DUT HoldTime attribute."), TestStep(4d, "TH awaits a ReportDataMessage containing an attribute report for DUT HoldTime attribute."), TestStep(5a, "Check if DUT supports DUT feature flag PIR or OTHER, If not supported, then stop and skip to 6a."), TestStep(5b, "TH reads DUT PIROccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), - TestStep(5c, "TH writes 10 seconds to DUT PIROccupiedToUnoccupiedDelay attribute."), + TestStep(5c, "TH writes a different value to DUT PIROccupiedToUnoccupiedDelay attribute."), TestStep(5d, "TH awaits a ReportDataMessage containing an attribute report for DUT PIROccupiedToUnoccupiedDelay attribute."), TestStep(6a, "Check if DUT supports DUT feature flag US, If not supported, then stop and skip to 7a."), TestStep(6b, "TH reads DUT UltrasonicOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), - TestStep(6c, "TH writes 10 seconds to DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), + TestStep(6c, "TH writes a different value to DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), TestStep(6d, "TH awaits a ReportDataMessage containing an attribute report for DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), TestStep(7a, "Check if DUT supports DUT feature flag PHY, If not supported, terminate this test case."), TestStep(7b, "TH reads DUT PhysicalContactOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), - TestStep(7c, "TH writes 10 seconds to DUT PhysicalContactOccupiedToUnoccupiedDelay attribute."), + TestStep(7c, "TH writes a different value to DUT PhysicalContactOccupiedToUnoccupiedDelay attribute."), TestStep(7d, "TH awaits a ReportDataMessage containing an attribute report for DUT PhysicalContactOccupiedToUnoccupiedDelay attribute.") ] return steps @@ -128,9 +128,7 @@ async def test_TC_OCC_3_2(self): self.step(3b) if attributes.Occupancy.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) - - if initial_dut != NullValue: - asserts.assert_equal(initial_dut, 0, "Occupancy attribute is still detected state") + asserts.assert_equal(initial_dut, 0, "Occupancy attribute is still detected state") self.step(3c) self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after the sensor occupancy is triggered and its occupancy state changed.") @@ -147,15 +145,16 @@ async def test_TC_OCC_3_2(self): initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) self.step(4c) - # write 10 as a HoldTime attibute - write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.HoldTime(10))]) + # write a different a HoldTime attibute + diff_val = 12 + write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.HoldTime(diff_val))]) self.step(4d) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.HoldTime, sequence=[ - initial_dut, 10], timeout_sec=post_prompt_settle_delay_seconds) + initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) self.step(5a) - if (Clusters.OccupancySensing.Bitmaps.Feature.kPIR | Clusters.OccupancySensing.Bitmaps.Feature.kOTHER) != 1: + if (Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared | Clusters.OccupancySensing.Bitmaps.Feature.kOther) != 1: self.skip(5b) self.skip(5c) self.skip(5d) @@ -166,18 +165,18 @@ async def test_TC_OCC_3_2(self): else: logging.info("No PIROccupiedToUnoccupiedDelay attribute supports. Terminate this test case") - self.skip_all_remaining_steps(5c) self.step(5c) - # write 10 for the new attribute value - write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PIROccupiedToUnoccupiedDelay(10))]) + # write the new attribute value + diff_val = 11 + write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PIROccupiedToUnoccupiedDelay(diff_val))]) self.step(5d) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PIROccupiedToUnoccupiedDelay, sequence=[ - initial_dut, 10], timeout_sec=post_prompt_settle_delay_seconds) + initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) self.step(6a) - if Clusters.OccupancySensing.Bitmaps.Feature.kUS != 1: + if Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic != 1: self.skip(6b) self.skip(6c) self.skip(6d) @@ -188,18 +187,18 @@ async def test_TC_OCC_3_2(self): else: logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Terminate this test case") - self.skip_all_remaining_steps(6c) self.step(6c) - # write 10 for the new attribute value - write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.UltrasonicOccupiedToUnoccupiedDelay(10))]) + # write the new attribute value + diff_val = 14 + write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.UltrasonicOccupiedToUnoccupiedDelay(diff_val))]) self.step(6d) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.UltrasonicOccupiedToUnoccupiedDelay, sequence=[ - initial_dut, 10], timeout_sec=post_prompt_settle_delay_seconds) + initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) self.step(7a) - if Clusters.OccupancySensing.Bitmaps.Feature.kPHY != 1: + if Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact != 1: self.skip(7b) self.skip(7c) self.skip(7d) @@ -210,12 +209,12 @@ async def test_TC_OCC_3_2(self): else: logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Terminate this test case") - self.skip_all_remaining_steps(7c) self.step(7c) - # write 10 for the new attribute value - write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PhysicalContactOccupiedToUnoccupiedDelay(10))]) + # write the new attribute value + diff_val = 9 + write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PhysicalContactOccupiedToUnoccupiedDelay(diff_val))]) self.step(7d) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PhysicalContactOccupiedToUnoccupiedDelay, sequence=[ - initial_dut, 10], timeout_sec=post_prompt_settle_delay_seconds) + initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) From 4de391e1c859224c89be87f964c04f8d10e7664c Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:54:01 -0500 Subject: [PATCH 12/86] Update TC_OCC_2_1.py Updated more detail test step failure description. --- src/python_testing/TC_OCC_2_1.py | 119 +++++++++++++++++++------------ 1 file changed, 72 insertions(+), 47 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index dd91f99f9cfb7c..13cb63bc106f14 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -72,7 +72,7 @@ async def test_TC_OCC_2_1(self): occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) asserts.assert_less_equal(occupancy_dut, 0b00000001, "Occupancy attribute is not in valid range") else: - logging.info("Occupancy attribute is a mandatory attribute. Test step fails.")logging.info() + logging.info("Occupancy attribute is a mandatory attribute. Test step fails.") self.step(3) if attributes.OccupancySensorType.attribute_id in attribute_list: @@ -80,14 +80,14 @@ async def test_TC_OCC_2_1(self): asserts.assert_less(occupancy_sensor_type_dut, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUnknownEnumValue, "OccupancySensorType is not in valid range") else: - logging.info("This attribute is a mandatory attribute. Test step fails") + logging.info("OccupancySensorType attribute is a mandatory attribute. Test step fails") self.step(4) if attributes.OccupancySensorTypeBitmap.attribute_id in attribute_list: occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") else: - logging.info("This attribute is a mandatory attribute. Test step fails") + logging.info("OccupancySensorTypeBitmap attribute is a mandatory attribute. Test step fails") self.step(5) if attributes.HoldTimeLimits.attribute_id in attribute_list: @@ -101,9 +101,10 @@ async def test_TC_OCC_2_1(self): asserts.assert_less_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") else: - loggin.info("HoldTime conformance violation. Test step skipped") + loggin.info("HoldTime conformance failed. Test step skipped") + else: - logging.info("Test step skipped") + logging.info("HoldTimeLimits not supported. Test step skipped") self.step(6) if attributes.HoldTime.attribute_id in attribute_list: @@ -113,89 +114,113 @@ async def test_TC_OCC_2_1(self): asserts.assert_greater_equal(hold_time_dut_dut, 0, "HoldTime attribute is out of range") else: logging.info("HoldTime not supported. The rest of legacy attribute test can be skipped") - self.skip_all_remaining_steps(7) self.step(7) - if (attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list) & ((occupancy_sensor_type_bitmap_dut == 0b00000001) | ((occupancy_sensor_type_bitmap_dut != 0b00000001)&(occupancy_sensor_type_bitmap_dut != 0b00000010)&(occupancy_sensor_type_bitmap_dut != 0b00000100))): - pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) + if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: + if ((occupancy_sensor_type_bitmap_dut == 0b00000001) | ((occupancy_sensor_type_bitmap_dut != 0b00000001)&(occupancy_sensor_type_bitmap_dut != 0b00000010)&(occupancy_sensor_type_bitmap_dut != 0b00000100))): + pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) - asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") - asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") + else: + logging.info("PIROccupiedToUnoccupiedDelay conformance failed. Test step skipped") else: logging.info("PIROccupiedToUnoccupiedDelay not supported. Test step skipped") self.step(8) - if (attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list) & (attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list): + if attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + if attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: - pir_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedDelay) - asserts.assert_less_equal(pir_utoo_delay_dut, 0xFFFE, "PIRUnoccupiedToOccupiedDelay is not in valid range") - asserts.assert_greater_equal(pir_utoo_delay_dut, 0, "PIRUnoccupiedToOccupiedDelay is not in valid range") + pir_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedDelay) + asserts.assert_less_equal(pir_utoo_delay_dut, 0xFFFE, "PIRUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(pir_utoo_delay_dut, 0, "PIRUnoccupiedToOccupiedDelay is not in valid range") + else: + logging.info("PIRUnoccupiedToOccupiedDelay conformance failed. Test step skipped") else: logging.info("PIRUnoccupiedToOccupiedDelay not supported. Test step skipped") self.step(9) - if (attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list) & (attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list): - pir_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedThreshold) - - asserts.assert_less_equal(pir_utoo_threshold_dut, 0xFE, "PIRUnoccupiedToOccupiedThreshold is not in valid range") - asserts.assert_greater_equal(pir_utoo_threshold_dut, 0, "PIRUnoccupiedToOccupiedThreshold is not in valid range") + if attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: + if attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + pir_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedThreshold) + + asserts.assert_less_equal(pir_utoo_threshold_dut, 0xFE, "PIRUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_greater_equal(pir_utoo_threshold_dut, 0, "PIRUnoccupiedToOccupiedThreshold is not in valid range") + else: + logging.info("PIRUnoccupiedToOccupiedThreshold conformance failed. Test step skipped") else: logging.info("PIRUnoccupiedToOccupiedThreshold not supported. Test step skipped") self.step(10) - if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list & (occupancy_sensor_type_bitmap_dut == 0b00000010): - ultrasonic_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) - - asserts.assert_less_equal(ultrasonic_otou_delay_dut, 0xFFFE, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") - asserts.assert_greater_equal(ultrasonic_otou_delay_dut, 0, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") + if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: + if occupancy_sensor_type_bitmap_dut == 0b00000010: + ultrasonic_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) + + asserts.assert_less_equal(ultrasonic_otou_delay_dut, 0xFFFE, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_greater_equal(ultrasonic_otou_delay_dut, 0, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") + else: + logging.info("UltrasonicOccupiedToUnoccupiedDelay conformance failed. Test step skipped") else: logging.info("UltrasonicOccupiedToUnoccupiedDelay not supported. Test step skipped") self.step(11) - if attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list & attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: - ultrasonic_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedDelay) - - asserts.assert_less_equal(ultrasonic_utoo_delay_dut, 0xFFFE, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") - asserts.assert_greater_equal(ultrasonic_utoo_delay_dut, 0, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") + if attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + if attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: + ultrasonic_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedDelay) + + asserts.assert_less_equal(ultrasonic_utoo_delay_dut, 0xFFFE, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(ultrasonic_utoo_delay_dut, 0, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") + else: + logging.info("UltrasonicUnoccupiedToOccupiedDelay conformance failed. Test step skipped") else: logging.info("UltrasonicUnoccupiedToOccupiedDelay not supported. Test step skipped") self.step(12) - if attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list & attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list: - ultrasonic_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedThreshold) + if attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: + if attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + ultrasonic_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedThreshold) - if ultrasonic_utoo_threshold_dut != NullValue: asserts.assert_less_equal(ultrasonic_utoo_threshold_dut, 0xFE, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") asserts.assert_greater_equal(ultrasonic_utoo_threshold_dut, 0, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") + else: + logging.info("UltrasonicUnoccupiedToOccupiedThreshold conformance failed. Test step skipped") else: logging.info("UltrasonicUnoccupiedToOccupiedThreshold not supported. Test step skipped") self.step(13) - if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list & (occupancy_sensor_type_bitmap_dut == 0b00000100): - phycontact_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) - - asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") - asserts.assert_greater_equal(phycontact_otou_delay_dut, 0, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") + if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list: + if occupancy_sensor_type_bitmap_dut == 0b00000100: + phycontact_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) + + asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_greater_equal(phycontact_otou_delay_dut, 0, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") + else: + logging.info("PhysicalContactOccupiedToUnoccupiedDelay conformance failed. Test step skipped") else: logging.info("PhysicalContactOccupiedToUnoccupiedDelay not supported. Test step skipped") self.step(14) - if attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list & attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: - phycontact_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedDelay) - asserts.assert_less_equal(phycontact_utoo_delay_dut, 0xFFFE, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") - asserts.assert_greater_equal(phycontact_utoo_delay_dut, 0, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") + if attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + if attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: + phycontact_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedDelay) + asserts.assert_less_equal(phycontact_utoo_delay_dut, 0xFFFE, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(phycontact_utoo_delay_dut, 0, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") + else: + logging.info("PhysicalContactUnoccupiedToOccupiedDelay conformance failed. Test step skipped") else: logging.info("PhysicalContactUnoccupiedToOccupiedDelay not supported. Test step skipped") self.step(15) - if attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list & attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list: - phycontact_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedThreshold) - - asserts.assert_less_equal(phycontact_utoo_threshold_dut, 0xFE, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") - asserts.assert_greater_equal(phycontact_utoo_threshold_dut, 0, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") + if attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: + if attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + phycontact_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedThreshold) + + asserts.assert_less_equal(phycontact_utoo_threshold_dut, 0xFE, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_greater_equal(phycontact_utoo_threshold_dut, 0, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") + else: + logging.info("PhysicalContactUnoccupiedToOccupiedThreshold conformance failed. Test step skipped") else: logging.info("PhysicalContactUnoccupiedToOccupiedThreshold not supported. Test step skipped") - if __name__ == "__main__": default_matter_test_main() From da3177295194d09e200c3f6ac9dbe4e0b4a1f372 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 14:56:00 -0500 Subject: [PATCH 13/86] Update TC_OCC_3_1.py Updating some of user input call according to comments. --- src/python_testing/TC_OCC_3_1.py | 35 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/python_testing/TC_OCC_3_1.py b/src/python_testing/TC_OCC_3_1.py index d1e4a7273ec04f..3fb1dc189afc7d 100644 --- a/src/python_testing/TC_OCC_3_1.py +++ b/src/python_testing/TC_OCC_3_1.py @@ -57,7 +57,7 @@ async def test_TC_OCC_3_1(self): node_id = self.matter_test_config.dut_node_ids[0] - hold_time = 10 # 10 seconds + hold_time = 10 # 10 seconds for occupancy state hold time self.step(1) # commissioning and getting cluster attribute list attributes = Clusters.OccupancySensing.Attributes @@ -70,46 +70,45 @@ async def test_TC_OCC_3_1(self): asserts.assert_equal(write_res[0].status, Status.Success, "Write HoldTime failed") else: - logging.info("No HoldTime attribute supports. Just test occupancy attribute triggering") + logging.info("No HoldTime attribute supports. Will test only occupancy attribute triggering functionality") self.step(3) # check if Occupancy attribute is 0 occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) - + + # if occupancy is on, then wait until the sensor occupancy state is 0. if occupancy_dut == 1: # Don't trigger occupancy sensor to render occupancy attribute to 0 if attributes.HoldTime.attribute_id in attribute_list: - self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after not triggering the sensor for HoldTime period to ensure occupancy attribute = 0") + time.sleep(hold_time + 2) # add some extra 2 seconds to ensure hold time has passed. - else: # a user wait until a sensor specific time to change occupancy attribute to 0 + else: # a user wait until a sensor specific time to change occupancy attribute to 0. This is the case where the sensor doesn't support HoldTime. self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after the sensor occupancy is detection ready state (occupancy attribute = 0)") - + + # check sensor occupancy state is 0 for the next test step occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) - asserts.assert_equal(occupancy_dut, 0, "Occupancy attribute is 1.") + asserts.assert_equal(occupancy_dut, 0, "Occupancy attribute is still 1.") self.step(4) # Trigger occupancy sensor to change Occupancy attribute value to 1 => TEST ACTION on DUT - self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after a user triggers sensor occupancy.") + self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after a sensor occupancy is triggered.") # And then check if Occupancy attribute has changed. occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) - asserts.assert_equal(occupancy_dut, 1, "Occupancy state is not 1") + asserts.assert_equal(occupancy_dut, 1, "Occupancy state is not changed to 1") - # step 5 + self.step(5) # check if Occupancy attribute is back to 0 after HoldTime attribute period if attributes.HoldTime.attribute_id in attribute_list: - self.step(5) - - # Trigger occupancy sensor to change Occupancy attribute value to 1 => TEST ACTION on DUT - self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after a user triggers sensor occupancy.") + # message to the tester + self.wait_for_user_input(prompt_msg="Do not trigger sensor during HoldTime.") # Start a timer based on HoldTime - time.sleep(hold_time) # wait 10 seconds + time.sleep(hold_time+2) # add some extra 2 seconds to ensure hold time has passed. occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) asserts.assert_equal(occupancy_dut, 0, "Occupancy state is not 0 after HoldTime period") - else: - - logging.info("No HoldTime attribute supports. Skip this test procedure.") + else: + logging.info("HoldTime attribute not supported. Skip this test procedure.") self.skip_step(5) From a1ce53b26d1194846a44049b0eab1567bf2a8c55 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:34:30 -0500 Subject: [PATCH 14/86] Update TC_OCC_2_1.py python code bug fixing --- src/python_testing/TC_OCC_2_1.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 13cb63bc106f14..42db36b69b6ccd 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -101,7 +101,7 @@ async def test_TC_OCC_2_1(self): asserts.assert_less_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") else: - loggin.info("HoldTime conformance failed. Test step skipped") + logging.info("HoldTime conformance failed. Test step skipped") else: logging.info("HoldTimeLimits not supported. Test step skipped") @@ -110,8 +110,8 @@ async def test_TC_OCC_2_1(self): if attributes.HoldTime.attribute_id in attribute_list: hold_time_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) - asserts.assert_less_equal(hold_time_dut_dut, 0xFFFE, "HoldTime attribute is out of range") - asserts.assert_greater_equal(hold_time_dut_dut, 0, "HoldTime attribute is out of range") + asserts.assert_less_equal(hold_time_dut, 0xFFFE, "HoldTime attribute is out of range") + asserts.assert_greater_equal(hold_time_dut, 0, "HoldTime attribute is out of range") else: logging.info("HoldTime not supported. The rest of legacy attribute test can be skipped") From f8df6a67633ff3ec82dece07dc57aafc81b38ac1 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:37:51 -0500 Subject: [PATCH 15/86] Update TC_OCC_2_2.py python bug fixing --- src/python_testing/TC_OCC_2_2.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 585b3f828c924c..24acae4217400b 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -87,21 +87,21 @@ async def test_TC_OCC_2_2(self): occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) if (feature_map_PIR == 0)&(feature_map_US == 0)&(feature_map_PHY == 0): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") elif (feature_map_PIR == 1)&(feature_map_US == 0)&(feature_map_PHY == 0): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") elif (feature_map_PIR == 0)&(feature_map_US == 1)&(feature_map_PHY == 0): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, "OccupancySensorType is not Ultrasonic") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, "OccupancySensorType is not Ultrasonic") elif (feature_map_PIR == 1)&(feature_map_US == 1)&(feature_map_PHY == 0): - asserts.assert_equal(occupancy_sensor_type_dut, 0b00000011, "OccupancySensorType is not PIR+Ultrasonic") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000011, "OccupancySensorType is not PIR+Ultrasonic") elif (feature_map_PIR == 0)&(feature_map_US == 0)&(feature_map_PHY == 1): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, "OccupancySensorType is not PhysicalContact") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, "OccupancySensorType is not PhysicalContact") elif (feature_map_PIR == 1)&(feature_map_US == 0)&(feature_map_PHY == 1): - asserts.assert_equal(occupancy_sensor_type_dut, 0b00000101, "OccupancySensorType is not PIR + PhysicalContact") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000101, "OccupancySensorType is not PIR + PhysicalContact") elif (feature_map_PIR == 0)&(feature_map_US == 1)&(feature_map_PHY == 1): - asserts.assert_equal(occupancy_sensor_type_dut, 0b00000110, "OccupancySensorType is not PhysicalContact + Ultrasonic") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000110, "OccupancySensorType is not PhysicalContact + Ultrasonic") elif (feature_map_PIR == 1)&(feature_map_US == 1)&(feature_map_PHY == 1): - asserts.assert_equal(occupancy_sensor_type_dut, 0b00000111, "OccupancySensorType is not PIR+Ultrasonic+Ultrasonic") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorType is not PIR+Ultrasonic+Ultrasonic") else: logging.info("OccupancySensorTypeBitmap mandatory attribute is not supported. Test step skipped") From 8267b3a8e904fbd111a9e6022dba6ceb76b8bcf6 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:38:55 -0500 Subject: [PATCH 16/86] Update TC_OCC_2_3.py python bug fix --- src/python_testing/TC_OCC_2_3.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/python_testing/TC_OCC_2_3.py b/src/python_testing/TC_OCC_2_3.py index 19341226e3f826..322bc230973905 100644 --- a/src/python_testing/TC_OCC_2_3.py +++ b/src/python_testing/TC_OCC_2_3.py @@ -64,7 +64,6 @@ async def test_TC_OCC_2_3(self): else: logging.info("No HoldTime attribute supports. Terminate this test case") - return pics self.step(3) if attributes.OccupancySensorType.attribute_id in attribute_list: From 997aa86672225fa753194d85721942c7d08f614c Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:43:43 -0500 Subject: [PATCH 17/86] Update TC_OCC_3_2.py --- src/python_testing/TC_OCC_3_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py index 7a9b5dec231d0f..78127aa5bceb28 100644 --- a/src/python_testing/TC_OCC_3_2.py +++ b/src/python_testing/TC_OCC_3_2.py @@ -74,7 +74,7 @@ def steps_TC_OCC_3_2(self) -> list[TestStep]: steps = [ TestStep(1, "Commission DUT to TH if not already done", is_commissioning=True), TestStep(2, "TH establishes a wildcard subscription to all attributes on Occupancy Sensing Cluster on the endpoint under test. Subscription min interval = 0 and max interval = 30 seconds."), - TestStep(3a, "Don’t trigger DUT for occupancy state change."), + TestStep(3a, "Do not trigger DUT for occupancy state change."), TestStep(3b, "TH reads DUT Occupancy attribute and saves the initial value as initial"), TestStep(3c, "Trigger DUT to change the occupancy state."), TestStep(3d, "TH awaits a ReportDataMessage containing an attribute report for DUT Occupancy attribute."), From 37be84151a30cd181ac16a00c8acb38d96a826c4 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:05:06 -0500 Subject: [PATCH 18/86] Update TC_OCC_3_2.py step numbering fix --- src/python_testing/TC_OCC_3_2.py | 96 ++++++++++++++++---------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py index 78127aa5bceb28..0245a622f606d1 100644 --- a/src/python_testing/TC_OCC_3_2.py +++ b/src/python_testing/TC_OCC_3_2.py @@ -74,26 +74,26 @@ def steps_TC_OCC_3_2(self) -> list[TestStep]: steps = [ TestStep(1, "Commission DUT to TH if not already done", is_commissioning=True), TestStep(2, "TH establishes a wildcard subscription to all attributes on Occupancy Sensing Cluster on the endpoint under test. Subscription min interval = 0 and max interval = 30 seconds."), - TestStep(3a, "Do not trigger DUT for occupancy state change."), - TestStep(3b, "TH reads DUT Occupancy attribute and saves the initial value as initial"), - TestStep(3c, "Trigger DUT to change the occupancy state."), - TestStep(3d, "TH awaits a ReportDataMessage containing an attribute report for DUT Occupancy attribute."), - TestStep(4a, "Check if DUT supports HoldTime attribute, If not supported, then stop and skip the rest of test cases."), - TestStep(4b, "TH reads DUT HoldTime attribute and saves the initial value as initial"), - TestStep(4c, "TH writes a different value to DUT HoldTime attribute."), - TestStep(4d, "TH awaits a ReportDataMessage containing an attribute report for DUT HoldTime attribute."), - TestStep(5a, "Check if DUT supports DUT feature flag PIR or OTHER, If not supported, then stop and skip to 6a."), - TestStep(5b, "TH reads DUT PIROccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), - TestStep(5c, "TH writes a different value to DUT PIROccupiedToUnoccupiedDelay attribute."), - TestStep(5d, "TH awaits a ReportDataMessage containing an attribute report for DUT PIROccupiedToUnoccupiedDelay attribute."), - TestStep(6a, "Check if DUT supports DUT feature flag US, If not supported, then stop and skip to 7a."), - TestStep(6b, "TH reads DUT UltrasonicOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), - TestStep(6c, "TH writes a different value to DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), - TestStep(6d, "TH awaits a ReportDataMessage containing an attribute report for DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), - TestStep(7a, "Check if DUT supports DUT feature flag PHY, If not supported, terminate this test case."), - TestStep(7b, "TH reads DUT PhysicalContactOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), - TestStep(7c, "TH writes a different value to DUT PhysicalContactOccupiedToUnoccupiedDelay attribute."), - TestStep(7d, "TH awaits a ReportDataMessage containing an attribute report for DUT PhysicalContactOccupiedToUnoccupiedDelay attribute.") + TestStep(3, "Do not trigger DUT for occupancy state change."), + TestStep(4, "TH reads DUT Occupancy attribute and saves the initial value as initial"), + TestStep(5, "Trigger DUT to change the occupancy state."), + TestStep(6, "TH awaits a ReportDataMessage containing an attribute report for DUT Occupancy attribute."), + TestStep(7, "Check if DUT supports HoldTime attribute, If not supported, then stop and skip the rest of test cases."), + TestStep(8, "TH reads DUT HoldTime attribute and saves the initial value as initial"), + TestStep(9, "TH writes a different value to DUT HoldTime attribute."), + TestStep(10, "TH awaits a ReportDataMessage containing an attribute report for DUT HoldTime attribute."), + TestStep(11, "Check if DUT supports DUT feature flag PIR or OTHER, If not supported, then stop and skip to 6a."), + TestStep(12, "TH reads DUT PIROccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), + TestStep(13, "TH writes a different value to DUT PIROccupiedToUnoccupiedDelay attribute."), + TestStep(14, "TH awaits a ReportDataMessage containing an attribute report for DUT PIROccupiedToUnoccupiedDelay attribute."), + TestStep(15, "Check if DUT supports DUT feature flag US, If not supported, then stop and skip to 7a."), + TestStep(16, "TH reads DUT UltrasonicOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), + TestStep(17, "TH writes a different value to DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), + TestStep(18, "TH awaits a ReportDataMessage containing an attribute report for DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), + TestStep(19, "Check if DUT supports DUT feature flag PHY, If not supported, terminate this test case."), + TestStep(20, "TH reads DUT PhysicalContactOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), + TestStep(21, "TH writes a different value to DUT PhysicalContactOccupiedToUnoccupiedDelay attribute."), + TestStep(22, "TH awaits a ReportDataMessage containing an attribute report for DUT PhysicalContactOccupiedToUnoccupiedDelay attribute.") ] return steps @@ -122,99 +122,97 @@ async def test_TC_OCC_3_2(self): attrib_listener = ClusterAttributeChangeAccumulator(Clusters.Objects.OccupancySensing) await attrib_listener.start(ChipDeviceCtrl, node_id, endpoint=endpoint_id) - self.step(3a) + self.step(3) self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after DUT goes back to unoccupied state.") - self.step(3b) + self.step(4) if attributes.Occupancy.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) asserts.assert_equal(initial_dut, 0, "Occupancy attribute is still detected state") - self.step(3c) + self.step(5) self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after the sensor occupancy is triggered and its occupancy state changed.") - self.step(3d) + self.step(6) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.Occupancy, sequence=[ 0, 1], timeout_sec=post_prompt_settle_delay_seconds) - self.step(4a) + self.step(7) if attributes.HoldTime.attribute_id not in attribute_list: logging.info("No HoldTime attribute supports. Terminate this test case") self.skip_all_remaining_steps("4b") - self.step(4b) + self.step(8) initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) - self.step(4c) + self.step(9) # write a different a HoldTime attibute diff_val = 12 write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.HoldTime(diff_val))]) - self.step(4d) + self.step(10) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.HoldTime, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - self.step(5a) + self.step(11) if (Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared | Clusters.OccupancySensing.Bitmaps.Feature.kOther) != 1: - self.skip(5b) - self.skip(5c) - self.skip(5d) + self.skip(12) + self.skip(13) + self.skip(14) - self.step(5b) + self.step(12) if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) else: logging.info("No PIROccupiedToUnoccupiedDelay attribute supports. Terminate this test case") - self.step(5c) + self.step(13) # write the new attribute value diff_val = 11 write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PIROccupiedToUnoccupiedDelay(diff_val))]) - self.step(5d) + self.step(14) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PIROccupiedToUnoccupiedDelay, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - self.step(6a) + self.step(15) if Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic != 1: - self.skip(6b) - self.skip(6c) - self.skip(6d) + self.skip(16) + self.skip(17) + self.skip(18) - self.step(6b) + self.step(16) if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) else: logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Terminate this test case") - self.step(6c) + self.step(17) # write the new attribute value diff_val = 14 write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.UltrasonicOccupiedToUnoccupiedDelay(diff_val))]) - self.step(6d) + self.step(18) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.UltrasonicOccupiedToUnoccupiedDelay, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - self.step(7a) + self.step(19) if Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact != 1: - self.skip(7b) - self.skip(7c) - self.skip(7d) + self.skip_all_remaining_steps(20) - self.step(7b) + self.step(20) if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list: initial_dut = await self.t_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) else: logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Terminate this test case") - self.step(7c) + self.step(21) # write the new attribute value diff_val = 9 write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PhysicalContactOccupiedToUnoccupiedDelay(diff_val))]) - self.step(7d) + self.step(22) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PhysicalContactOccupiedToUnoccupiedDelay, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) From 293b97e48fa98ea0536ac862f960965f2c0a5b03 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 17:29:50 -0500 Subject: [PATCH 19/86] Update TC_OCC_3_2.py --- src/python_testing/TC_OCC_3_2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py index 0245a622f606d1..f792558cbbcab1 100644 --- a/src/python_testing/TC_OCC_3_2.py +++ b/src/python_testing/TC_OCC_3_2.py @@ -16,10 +16,13 @@ # import logging - +import time +import queue +from typing import Any, List, Optional, Tuple from chip import ChipDeviceCtrl import chip.clusters as Clusters from chip.clusters.Types import NullValue +from chip.clusters.Attribute import EventReadResult, SubscriptionTransaction, TypedAttributePath from matter_testing_support import MatterBaseTest, ClusterAttributeChangeAccumulator, TestStep, async_test_body, default_matter_test_main from mobly import asserts From 2cf4c4c43f8522975abc5924a69310a0dc3f4df3 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:16:14 -0500 Subject: [PATCH 20/86] Update TC_OCC_3_2.py --- src/python_testing/TC_OCC_3_2.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py index f792558cbbcab1..989514235a519d 100644 --- a/src/python_testing/TC_OCC_3_2.py +++ b/src/python_testing/TC_OCC_3_2.py @@ -18,12 +18,11 @@ import logging import time import queue -from typing import Any, List, Optional, Tuple +from typing import Any from chip import ChipDeviceCtrl import chip.clusters as Clusters -from chip.clusters.Types import NullValue -from chip.clusters.Attribute import EventReadResult, SubscriptionTransaction, TypedAttributePath -from matter_testing_support import MatterBaseTest, ClusterAttributeChangeAccumulator, TestStep, async_test_body, default_matter_test_main +from chip.clusters.Attribute import TypedAttributePath +from matter_testing_support import MatterBaseTest, ClusterAttributeChangeAccumulator, AttributeValue, TestStep, async_test_body, default_matter_test_main from mobly import asserts @@ -150,7 +149,7 @@ async def test_TC_OCC_3_2(self): self.step(9) # write a different a HoldTime attibute diff_val = 12 - write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.HoldTime(diff_val))]) + await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.HoldTime(diff_val))]) self.step(10) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.HoldTime, sequence=[ @@ -172,7 +171,7 @@ async def test_TC_OCC_3_2(self): self.step(13) # write the new attribute value diff_val = 11 - write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PIROccupiedToUnoccupiedDelay(diff_val))]) + await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PIROccupiedToUnoccupiedDelay(diff_val))]) self.step(14) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PIROccupiedToUnoccupiedDelay, sequence=[ @@ -194,7 +193,7 @@ async def test_TC_OCC_3_2(self): self.step(17) # write the new attribute value diff_val = 14 - write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.UltrasonicOccupiedToUnoccupiedDelay(diff_val))]) + await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.UltrasonicOccupiedToUnoccupiedDelay(diff_val))]) self.step(18) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.UltrasonicOccupiedToUnoccupiedDelay, sequence=[ @@ -214,8 +213,11 @@ async def test_TC_OCC_3_2(self): self.step(21) # write the new attribute value diff_val = 9 - write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PhysicalContactOccupiedToUnoccupiedDelay(diff_val))]) + await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PhysicalContactOccupiedToUnoccupiedDelay(diff_val))]) self.step(22) self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PhysicalContactOccupiedToUnoccupiedDelay, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) + +if __name__ == "__main__": + default_matter_test_main() From 346aaaf3980eedb8cfc67c2d1688f8215fcf226e Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:17:07 -0500 Subject: [PATCH 21/86] Update TC_OCC_3_1.py --- src/python_testing/TC_OCC_3_1.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_3_1.py b/src/python_testing/TC_OCC_3_1.py index 3fb1dc189afc7d..eb9c553d045b34 100644 --- a/src/python_testing/TC_OCC_3_1.py +++ b/src/python_testing/TC_OCC_3_1.py @@ -21,7 +21,6 @@ from chip import ChipDeviceCtrl from chip.interaction_model import Status import chip.clusters as Clusters -from chip.clusters.Types import NullValue from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts @@ -112,3 +111,6 @@ async def test_TC_OCC_3_1(self): else: logging.info("HoldTime attribute not supported. Skip this test procedure.") self.skip_step(5) + +if __name__ == "__main__": + default_matter_test_main() From b848995d8f5d635e6a92b42f214f73c5ad307b66 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:21:53 -0500 Subject: [PATCH 22/86] Update TC_OCC_2_3.py --- src/python_testing/TC_OCC_2_3.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_OCC_2_3.py b/src/python_testing/TC_OCC_2_3.py index 322bc230973905..5b3fb85c55d454 100644 --- a/src/python_testing/TC_OCC_2_3.py +++ b/src/python_testing/TC_OCC_2_3.py @@ -17,9 +17,7 @@ import logging -from chip import ChipDeviceCtrl import chip.clusters as Clusters -from chip.clusters.Types import NullValue from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts @@ -96,3 +94,6 @@ async def test_TC_OCC_2_3(self): asserts.assert_equal(occupancy_phy_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PhysicalContactOccupiedToUnoccupiedDelay") else: logging.info("OccupancySensorType attribute value is out of range") + +if __name__ == "__main__": + default_matter_test_main() From 9761d9aa117200998abe172d585b7ac97f04658c Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:22:39 -0500 Subject: [PATCH 23/86] Update TC_OCC_2_2.py --- src/python_testing/TC_OCC_2_2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 24acae4217400b..db85106022ad84 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -18,7 +18,6 @@ import logging import chip.clusters as Clusters -from chip.clusters.Types import NullValue from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts @@ -105,3 +104,6 @@ async def test_TC_OCC_2_2(self): else: logging.info("OccupancySensorTypeBitmap mandatory attribute is not supported. Test step skipped") + +if __name__ == "__main__": + default_matter_test_main() From 86beae48ab0831116bb9506903b06c0fe72366a4 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:23:07 -0500 Subject: [PATCH 24/86] Update TC_OCC_2_1.py --- src/python_testing/TC_OCC_2_1.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 42db36b69b6ccd..6dd20cb6940f84 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -18,7 +18,6 @@ import logging import chip.clusters as Clusters -from chip.clusters.Types import NullValue from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts From e134ba8223deb0d041311963e594a49bf443ad1a Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:15:38 -0500 Subject: [PATCH 25/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 6dd20cb6940f84..6e116d5ba13376 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -72,6 +72,7 @@ async def test_TC_OCC_2_1(self): asserts.assert_less_equal(occupancy_dut, 0b00000001, "Occupancy attribute is not in valid range") else: logging.info("Occupancy attribute is a mandatory attribute. Test step fails.") + asserts.fail("Missing mandatory attribute Occupancy") self.step(3) if attributes.OccupancySensorType.attribute_id in attribute_list: From 748c52879d4664b14bd5b50e629362b8896f04f0 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:28:07 -0500 Subject: [PATCH 26/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 6e116d5ba13376..38ffd385c13cf4 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -81,6 +81,7 @@ async def test_TC_OCC_2_1(self): "OccupancySensorType is not in valid range") else: logging.info("OccupancySensorType attribute is a mandatory attribute. Test step fails") + asserts.fail("Missing mandatory attribute OccupancySensorType") self.step(4) if attributes.OccupancySensorTypeBitmap.attribute_id in attribute_list: From d8ebf5ed0700bf8e5371def5bffc85c63d8f9ba9 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:28:24 -0500 Subject: [PATCH 27/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 38ffd385c13cf4..89ae62ed83b8b9 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -89,6 +89,7 @@ async def test_TC_OCC_2_1(self): asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") else: logging.info("OccupancySensorTypeBitmap attribute is a mandatory attribute. Test step fails") + asserts.fail("Missing mandatory attribute OccupancySensorTypeBitmap") self.step(5) if attributes.HoldTimeLimits.attribute_id in attribute_list: From 1d170a31869f21e67601187a77acf83a5be525fa Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:28:46 -0500 Subject: [PATCH 28/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 89ae62ed83b8b9..e182c62c5678a2 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -104,6 +104,7 @@ async def test_TC_OCC_2_1(self): asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") else: logging.info("HoldTime conformance failed. Test step skipped") + asserts.fail("HoldTime conformance is incorrect") else: logging.info("HoldTimeLimits not supported. Test step skipped") From 680408407ad5206fe7909a58c50ae650486fdc0b Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:29:02 -0500 Subject: [PATCH 29/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index e182c62c5678a2..8b0a56137c6d32 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -108,6 +108,7 @@ async def test_TC_OCC_2_1(self): else: logging.info("HoldTimeLimits not supported. Test step skipped") + self.mark_current_step_skipped() self.step(6) if attributes.HoldTime.attribute_id in attribute_list: From 872111e14c2747bb258e173437e3fc28f18d395f Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:30:27 -0500 Subject: [PATCH 30/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 8b0a56137c6d32..ba6e744875a95f 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -118,6 +118,9 @@ async def test_TC_OCC_2_1(self): asserts.assert_greater_equal(hold_time_dut, 0, "HoldTime attribute is out of range") else: logging.info("HoldTime not supported. The rest of legacy attribute test can be skipped") + self.skip_all_remaining_steps(7) + return + self.step(7) if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: From ffedcbd1095b6c77e56fea2993ef226787e21f66 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:31:05 -0500 Subject: [PATCH 31/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index ba6e744875a95f..287412264a4578 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -130,7 +130,8 @@ async def test_TC_OCC_2_1(self): asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") else: - logging.info("PIROccupiedToUnoccupiedDelay conformance failed. Test step skipped") + logging.info("PIROccupiedToUnoccupiedDelay conformance failed".) + asserts.fail("PIROccupiedToUnoccupiedDelay conformance is incorrect") else: logging.info("PIROccupiedToUnoccupiedDelay not supported. Test step skipped") From 8df35a531e491c5e36daa830dec77252541fcd92 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:31:32 -0500 Subject: [PATCH 32/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 287412264a4578..f061136e068599 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -134,6 +134,7 @@ async def test_TC_OCC_2_1(self): asserts.fail("PIROccupiedToUnoccupiedDelay conformance is incorrect") else: logging.info("PIROccupiedToUnoccupiedDelay not supported. Test step skipped") + self.mark_current_step_skipped() self.step(8) if attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list: From 84cc83f000b13937d7dcda95d4442cfc477b856b Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:31:47 -0500 Subject: [PATCH 33/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index f061136e068599..d113290514a4d4 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -147,6 +147,7 @@ async def test_TC_OCC_2_1(self): logging.info("PIRUnoccupiedToOccupiedDelay conformance failed. Test step skipped") else: logging.info("PIRUnoccupiedToOccupiedDelay not supported. Test step skipped") + self.mark_current_step_skipped() self.step(9) if attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: From 1466f183d5a1827c08f3fc4c329b30c6534b0755 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:32:01 -0500 Subject: [PATCH 34/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index d113290514a4d4..411347df149bac 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -160,6 +160,8 @@ async def test_TC_OCC_2_1(self): logging.info("PIRUnoccupiedToOccupiedThreshold conformance failed. Test step skipped") else: logging.info("PIRUnoccupiedToOccupiedThreshold not supported. Test step skipped") + self.mark_current_step_skipped() + self.step(10) if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: From 4b201255c9b43532b7edc61de503dfaa5c84effe Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:32:27 -0500 Subject: [PATCH 35/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 411347df149bac..64da4fd3f32388 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -165,7 +165,8 @@ async def test_TC_OCC_2_1(self): self.step(10) if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: - if occupancy_sensor_type_bitmap_dut == 0b00000010: + if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) != 0: + ultrasonic_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) asserts.assert_less_equal(ultrasonic_otou_delay_dut, 0xFFFE, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") From fea321b07a775a475afe6fa08b323b6d12d70041 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:32:40 -0500 Subject: [PATCH 36/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 64da4fd3f32388..61c747288611bc 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -175,6 +175,7 @@ async def test_TC_OCC_2_1(self): logging.info("UltrasonicOccupiedToUnoccupiedDelay conformance failed. Test step skipped") else: logging.info("UltrasonicOccupiedToUnoccupiedDelay not supported. Test step skipped") + self.mark_current_step_skipped() self.step(11) if attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list: From 5494598c6ee647ab0152fdd031a519003c2be3be Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:32:53 -0500 Subject: [PATCH 37/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 61c747288611bc..66216de95d9824 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -188,6 +188,7 @@ async def test_TC_OCC_2_1(self): logging.info("UltrasonicUnoccupiedToOccupiedDelay conformance failed. Test step skipped") else: logging.info("UltrasonicUnoccupiedToOccupiedDelay not supported. Test step skipped") + self.mark_current_step_skipped() self.step(12) if attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: From 6a21c0be0cc1c53342aa22f31967494bf7b5840b Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:33:02 -0500 Subject: [PATCH 38/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 66216de95d9824..a202c8dd445775 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -201,6 +201,7 @@ async def test_TC_OCC_2_1(self): logging.info("UltrasonicUnoccupiedToOccupiedThreshold conformance failed. Test step skipped") else: logging.info("UltrasonicUnoccupiedToOccupiedThreshold not supported. Test step skipped") + self.mark_current_step_skipped() self.step(13) if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list: From ae7dbd41f9d7b7cd3e8f78dd615fd84520f1887f Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:33:32 -0500 Subject: [PATCH 39/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index a202c8dd445775..52a8cb9202c362 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -214,6 +214,7 @@ async def test_TC_OCC_2_1(self): logging.info("PhysicalContactOccupiedToUnoccupiedDelay conformance failed. Test step skipped") else: logging.info("PhysicalContactOccupiedToUnoccupiedDelay not supported. Test step skipped") + self.mark_current_step_skipped() self.step(14) if attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list: From 5dac75d2ef8542751cbd463898c921316b44fba7 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:33:42 -0500 Subject: [PATCH 40/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 52a8cb9202c362..d2db0df062d114 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -226,6 +226,7 @@ async def test_TC_OCC_2_1(self): logging.info("PhysicalContactUnoccupiedToOccupiedDelay conformance failed. Test step skipped") else: logging.info("PhysicalContactUnoccupiedToOccupiedDelay not supported. Test step skipped") + self.mark_current_step_skipped() self.step(15) if attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: From b194b3395b082824ce55718a852123ca5d03ab08 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 07:33:52 -0500 Subject: [PATCH 41/86] Update src/python_testing/TC_OCC_2_1.py Co-authored-by: C Freeman --- src/python_testing/TC_OCC_2_1.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index d2db0df062d114..1c6d769f7cb8e3 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -239,6 +239,7 @@ async def test_TC_OCC_2_1(self): logging.info("PhysicalContactUnoccupiedToOccupiedThreshold conformance failed. Test step skipped") else: logging.info("PhysicalContactUnoccupiedToOccupiedThreshold not supported. Test step skipped") + self.mark_current_step_skipped() if __name__ == "__main__": default_matter_test_main() From 3e86880e39c63877ee0f8551efd908e89d0929d0 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 08:05:46 -0500 Subject: [PATCH 42/86] Update TC_OCC_2_2.py Fixed bitmap conditional statement --- src/python_testing/TC_OCC_2_2.py | 36 ++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index db85106022ad84..564daa7a4edb9c 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -60,50 +60,54 @@ async def test_TC_OCC_2_2(self): self.step(2) if attributes.OccupancySensorType.attribute_id in attribute_list: occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) + feature_map = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.attributes.FeatureMap) - if (feature_map_PIR == 0)&(feature_map_US == 0)&(feature_map_PHY == 0): + if (feature_map != feature_map_PIR)&(feature_map != feature_map_US)&(feature_map != feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - elif (feature_map_PIR == 1)&(feature_map_US == 0)&(feature_map_PHY == 0): + elif (feature_map == feature_map_PIR)&(feature_map != feature_map_US)&(feature_map != feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - elif (feature_map_PIR == 0)&(feature_map_US == 1)&(feature_map_PHY == 0): + elif (feature_map != feature_map_PIR)&(feature_map == feature_map_US)&(feature_map != feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonci, "OccupancySensorType is not Ultrasonic") - elif (feature_map_PIR == 1)&(feature_map_US == 1)&(feature_map_PHY == 0): + elif (feature_map == feature_map_PIR)&(feature_map == feature_map_US)&(feature_map != feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, "OccupancySensorType is not PIRAndUltrasonic") - elif (feature_map_PIR == 0)&(feature_map_US == 0)&(feature_map_PHY == 1): + elif (feature_map != feature_map_PIR)&(feature_map != feature_map_US)&(feature_map == feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, "OccupancySensorType is not PhysicalContact") - elif (feature_map_PIR == 1)&(feature_map_US == 0)&(feature_map_PHY == 1): + elif (feature_map == feature_map_PIR)&(feature_map != feature_map_US)&(feature_map == feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - elif (feature_map_PIR == 0)&(feature_map_US == 1)&(feature_map_PHY == 1): + elif (feature_map != feature_map_PIR)&(feature_map == feature_map_US)&(feature_map == feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") - elif (feature_map_PIR == 1)&(feature_map_US == 1)&(feature_map_PHY == 1): + elif (feature_map == feature_map_PIR)&(feature_map == feature_map_US)&(feature_map == feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, "OccupancySensorType is not PIRAndUltrasonic") else: logging.info("OccupancySensorType mandatory attribute is not supported. Test step skipped") + asserts.fail("Missing mandatory attribute OccupancySensorType") self.step(3) if attributes.OccupancySensorTypeBitmap.attribute_id in attribute_list: occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) + feature_map = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.attributes.FeatureMap) - if (feature_map_PIR == 0)&(feature_map_US == 0)&(feature_map_PHY == 0): + if (feature_map != feature_map_PIR)&(feature_map != feature_map_US)&(feature_map != feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") - elif (feature_map_PIR == 1)&(feature_map_US == 0)&(feature_map_PHY == 0): + elif (feature_map == feature_map_PIR)&(feature_map != feature_map_US)&(feature_map != feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") - elif (feature_map_PIR == 0)&(feature_map_US == 1)&(feature_map_PHY == 0): + elif (feature_map != feature_map_PIR)&(feature_map == feature_map_US)&(feature_map != feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, "OccupancySensorType is not Ultrasonic") - elif (feature_map_PIR == 1)&(feature_map_US == 1)&(feature_map_PHY == 0): + elif (feature_map == feature_map_PIR)&(feature_map == feature_map_US)&(feature_map != feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000011, "OccupancySensorType is not PIR+Ultrasonic") - elif (feature_map_PIR == 0)&(feature_map_US == 0)&(feature_map_PHY == 1): + elif (feature_map != feature_map_PIR)&(feature_map != feature_map_US)&(feature_map == feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, "OccupancySensorType is not PhysicalContact") - elif (feature_map_PIR == 1)&(feature_map_US == 0)&(feature_map_PHY == 1): + elif (feature_map == feature_map_PIR)&(feature_map != feature_map_US)&(feature_map == feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000101, "OccupancySensorType is not PIR + PhysicalContact") - elif (feature_map_PIR == 0)&(feature_map_US == 1)&(feature_map_PHY == 1): + elif (feature_map != feature_map_PIR)&(feature_map == feature_map_US)&(feature_map == feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000110, "OccupancySensorType is not PhysicalContact + Ultrasonic") - elif (feature_map_PIR == 1)&(feature_map_US == 1)&(feature_map_PHY == 1): + elif (feature_map == feature_map_PIR)&(feature_map == feature_map_US)&(feature_map == feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorType is not PIR+Ultrasonic+Ultrasonic") else: logging.info("OccupancySensorTypeBitmap mandatory attribute is not supported. Test step skipped") + asserts.fail("Missing mandatory attribute OccupancySensorTypeBitmap") if __name__ == "__main__": default_matter_test_main() From 65fb1d516440c3294cd94b0d6b28f2fbce8901c1 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 08:08:19 -0500 Subject: [PATCH 43/86] Update TC_OCC_3_1.py --- src/python_testing/TC_OCC_3_1.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/python_testing/TC_OCC_3_1.py b/src/python_testing/TC_OCC_3_1.py index eb9c553d045b34..63d05cb981f85e 100644 --- a/src/python_testing/TC_OCC_3_1.py +++ b/src/python_testing/TC_OCC_3_1.py @@ -14,6 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${TYPE_OF_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === import logging import time From a9c1584f3ead483297cfe27ea0925822343beda1 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 08:53:58 -0500 Subject: [PATCH 44/86] Update TC_OCC_2_1.py Add additional changes according to comments received. --- src/python_testing/TC_OCC_2_1.py | 121 +++++++++++++++++-------------- 1 file changed, 65 insertions(+), 56 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 1c6d769f7cb8e3..9ce392a1a4620a 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -14,6 +14,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# There are CI issues to be followed up for the test cases below that implements manually controlling sensor device for +# the occupancy state ON/OFF change. +# [TC-OCC-3.1] test procedure step 4 +# [TC-OCC-3.2] test precedure step 3c import logging @@ -121,7 +125,6 @@ async def test_TC_OCC_2_1(self): self.skip_all_remaining_steps(7) return - self.step(7) if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: if ((occupancy_sensor_type_bitmap_dut == 0b00000001) | ((occupancy_sensor_type_bitmap_dut != 0b00000001)&(occupancy_sensor_type_bitmap_dut != 0b00000010)&(occupancy_sensor_type_bitmap_dut != 0b00000100))): @@ -138,105 +141,111 @@ async def test_TC_OCC_2_1(self): self.step(8) if attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list: - if attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: + has_delay = attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list + has_threshold = attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list + asserts.assert_equal(has_delay, has_threshold, "PIRUnoccupiedToOccupiedDelay conformance failure") - pir_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedDelay) - asserts.assert_less_equal(pir_utoo_delay_dut, 0xFFFE, "PIRUnoccupiedToOccupiedDelay is not in valid range") - asserts.assert_greater_equal(pir_utoo_delay_dut, 0, "PIRUnoccupiedToOccupiedDelay is not in valid range") - else: - logging.info("PIRUnoccupiedToOccupiedDelay conformance failed. Test step skipped") + pir_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedDelay) + asserts.assert_less_equal(pir_utoo_delay_dut, 0xFFFE, "PIRUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(pir_utoo_delay_dut, 0, "PIRUnoccupiedToOccupiedDelay is not in valid range") + else: logging.info("PIRUnoccupiedToOccupiedDelay not supported. Test step skipped") self.mark_current_step_skipped() self.step(9) if attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: - if attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list: - pir_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedThreshold) - - asserts.assert_less_equal(pir_utoo_threshold_dut, 0xFE, "PIRUnoccupiedToOccupiedThreshold is not in valid range") - asserts.assert_greater_equal(pir_utoo_threshold_dut, 0, "PIRUnoccupiedToOccupiedThreshold is not in valid range") - else: - logging.info("PIRUnoccupiedToOccupiedThreshold conformance failed. Test step skipped") + has_delay = attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list + has_threshold = attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list + asserts.assert_equal(has_delay, has_threshold, "PIRUnoccupiedToOccupiedThreshold conformance failure") + + pir_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedThreshold) + asserts.assert_less_equal(pir_utoo_threshold_dut, 0xFE, "PIRUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_greater_equal(pir_utoo_threshold_dut, 0, "PIRUnoccupiedToOccupiedThreshold is not in valid range") + else: logging.info("PIRUnoccupiedToOccupiedThreshold not supported. Test step skipped") self.mark_current_step_skipped() - self.step(10) if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: - if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) != 0: + has_ultrasonic_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) != 0 + has_ultrasonic_delay = attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list + asserts.assert_equal(has_ultrasonic_bitmap, has_ultrasonic_delay, "Bad conformance on Ultrasonic bitmap") + + ultrasonic_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) + asserts.assert_less_equal(ultrasonic_otou_delay_dut, 0xFFFE, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_greater_equal(ultrasonic_otou_delay_dut, 0, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") - ultrasonic_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) - - asserts.assert_less_equal(ultrasonic_otou_delay_dut, 0xFFFE, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") - asserts.assert_greater_equal(ultrasonic_otou_delay_dut, 0, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") - else: - logging.info("UltrasonicOccupiedToUnoccupiedDelay conformance failed. Test step skipped") else: logging.info("UltrasonicOccupiedToUnoccupiedDelay not supported. Test step skipped") self.mark_current_step_skipped() self.step(11) - if attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list: - if attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: - ultrasonic_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedDelay) - - asserts.assert_less_equal(ultrasonic_utoo_delay_dut, 0xFFFE, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") - asserts.assert_greater_equal(ultrasonic_utoo_delay_dut, 0, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") - else: - logging.info("UltrasonicUnoccupiedToOccupiedDelay conformance failed. Test step skipped") + if attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + has_delay = attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list + has_threshold = attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list + asserts.assert_equal(has_delay, has_threshold, "UltrasonicUnoccupiedToOccupiedDelay conformance failure") + + ultrasonic_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedDelay) + asserts.assert_less_equal(ultrasonic_utoo_delay_dut, 0xFFFE, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(ultrasonic_utoo_delay_dut, 0, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") else: logging.info("UltrasonicUnoccupiedToOccupiedDelay not supported. Test step skipped") self.mark_current_step_skipped() self.step(12) if attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: - if attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list: - ultrasonic_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedThreshold) + has_delay = attributes.UltrasonicUnoccupiedToOccupiedDelay.attribute_id in attribute_list + has_threshold = attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list + asserts.assert_equal(has_delay, has_threshold, "UltrasonicUnoccupiedToOccupiedThreshold conformance failure") + + ultrasonic_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedThreshold) + asserts.assert_less_equal(ultrasonic_utoo_threshold_dut, 0xFE, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_greater_equal(ultrasonic_utoo_threshold_dut, 0, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") - asserts.assert_less_equal(ultrasonic_utoo_threshold_dut, 0xFE, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") - asserts.assert_greater_equal(ultrasonic_utoo_threshold_dut, 0, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") - else: - logging.info("UltrasonicUnoccupiedToOccupiedThreshold conformance failed. Test step skipped") else: logging.info("UltrasonicUnoccupiedToOccupiedThreshold not supported. Test step skipped") self.mark_current_step_skipped() self.step(13) if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list: - if occupancy_sensor_type_bitmap_dut == 0b00000100: - phycontact_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) - - asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") - asserts.assert_greater_equal(phycontact_otou_delay_dut, 0, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") - else: - logging.info("PhysicalContactOccupiedToUnoccupiedDelay conformance failed. Test step skipped") + has_phycon_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) != 0 + has_phycon_delay = attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list + asserts.assert_equal(has_phycon_bitmap, has_phycon_delay, "Bad conformance on PhysicalContact bitmap") + + phycontact_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) + asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_greater_equal(phycontact_otou_delay_dut, 0, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") + else: logging.info("PhysicalContactOccupiedToUnoccupiedDelay not supported. Test step skipped") self.mark_current_step_skipped() self.step(14) if attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list: - if attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: - phycontact_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedDelay) - asserts.assert_less_equal(phycontact_utoo_delay_dut, 0xFFFE, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") - asserts.assert_greater_equal(phycontact_utoo_delay_dut, 0, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") - else: - logging.info("PhysicalContactUnoccupiedToOccupiedDelay conformance failed. Test step skipped") + has_delay = attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list + has_threshold = attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list + asserts.assert_equal(has_delay, has_threshold, "PhysicalContactUnoccupiedToOccupiedDelay conformance failure") + + phycontact_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedDelay) + asserts.assert_less_equal(phycontact_utoo_delay_dut, 0xFFFE, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(phycontact_utoo_delay_dut, 0, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") + else: logging.info("PhysicalContactUnoccupiedToOccupiedDelay not supported. Test step skipped") self.mark_current_step_skipped() self.step(15) if attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list: - if attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list: - phycontact_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedThreshold) - - asserts.assert_less_equal(phycontact_utoo_threshold_dut, 0xFE, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") - asserts.assert_greater_equal(phycontact_utoo_threshold_dut, 0, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") - else: - logging.info("PhysicalContactUnoccupiedToOccupiedThreshold conformance failed. Test step skipped") + has_delay = attributes.PhysicalContactUnoccupiedToOccupiedDelay.attribute_id in attribute_list + has_threshold = attributes.PhysicalContactUnoccupiedToOccupiedThreshold.attribute_id in attribute_list + asserts.assert_equal(has_delay, has_threshold, "PhysicalContactUnoccupiedToOccupiedThreshold conformance failure") + + phycontact_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedThreshold) + asserts.assert_less_equal(phycontact_utoo_threshold_dut, 0xFE, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_greater_equal(phycontact_utoo_threshold_dut, 0, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") + else: logging.info("PhysicalContactUnoccupiedToOccupiedThreshold not supported. Test step skipped") self.mark_current_step_skipped() From 7a8a76397a320b7f6bbeaafa98d5d0de3befd5e7 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 09:03:23 -0500 Subject: [PATCH 45/86] Update TC_OCC_3_1.py --- src/python_testing/TC_OCC_3_1.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/python_testing/TC_OCC_3_1.py b/src/python_testing/TC_OCC_3_1.py index 63d05cb981f85e..5e51af7becb369 100644 --- a/src/python_testing/TC_OCC_3_1.py +++ b/src/python_testing/TC_OCC_3_1.py @@ -22,6 +22,10 @@ # test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === +# There are CI issues to be followed up for the test cases below that implements manually controlling sensor device for +# the occupancy state ON/OFF change. +# [TC-OCC-3.1] test procedure step 4 +# [TC-OCC-3.2] test precedure step 3c import logging import time From 7245727213a11b66725d1d2894466b8dfb4be6d9 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 09:34:53 -0500 Subject: [PATCH 46/86] Update TC_OCC_3_2.py test step change --- src/python_testing/TC_OCC_3_2.py | 124 +++++++++++++++++-------------- 1 file changed, 70 insertions(+), 54 deletions(-) diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py index 989514235a519d..00a5b2c37e2986 100644 --- a/src/python_testing/TC_OCC_3_2.py +++ b/src/python_testing/TC_OCC_3_2.py @@ -14,6 +14,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${TYPE_OF_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === +# There are CI issues to be followed up for the test cases below that implements manually controlling sensor device for +# the occupancy state ON/OFF change. +# [TC-OCC-3.1] test procedure step 4 +# [TC-OCC-3.2] test precedure step 3a, 3c import logging import time @@ -76,26 +88,26 @@ def steps_TC_OCC_3_2(self) -> list[TestStep]: steps = [ TestStep(1, "Commission DUT to TH if not already done", is_commissioning=True), TestStep(2, "TH establishes a wildcard subscription to all attributes on Occupancy Sensing Cluster on the endpoint under test. Subscription min interval = 0 and max interval = 30 seconds."), - TestStep(3, "Do not trigger DUT for occupancy state change."), - TestStep(4, "TH reads DUT Occupancy attribute and saves the initial value as initial"), - TestStep(5, "Trigger DUT to change the occupancy state."), - TestStep(6, "TH awaits a ReportDataMessage containing an attribute report for DUT Occupancy attribute."), - TestStep(7, "Check if DUT supports HoldTime attribute, If not supported, then stop and skip the rest of test cases."), - TestStep(8, "TH reads DUT HoldTime attribute and saves the initial value as initial"), - TestStep(9, "TH writes a different value to DUT HoldTime attribute."), - TestStep(10, "TH awaits a ReportDataMessage containing an attribute report for DUT HoldTime attribute."), - TestStep(11, "Check if DUT supports DUT feature flag PIR or OTHER, If not supported, then stop and skip to 6a."), - TestStep(12, "TH reads DUT PIROccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), - TestStep(13, "TH writes a different value to DUT PIROccupiedToUnoccupiedDelay attribute."), - TestStep(14, "TH awaits a ReportDataMessage containing an attribute report for DUT PIROccupiedToUnoccupiedDelay attribute."), - TestStep(15, "Check if DUT supports DUT feature flag US, If not supported, then stop and skip to 7a."), - TestStep(16, "TH reads DUT UltrasonicOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), - TestStep(17, "TH writes a different value to DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), - TestStep(18, "TH awaits a ReportDataMessage containing an attribute report for DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), - TestStep(19, "Check if DUT supports DUT feature flag PHY, If not supported, terminate this test case."), - TestStep(20, "TH reads DUT PhysicalContactOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), - TestStep(21, "TH writes a different value to DUT PhysicalContactOccupiedToUnoccupiedDelay attribute."), - TestStep(22, "TH awaits a ReportDataMessage containing an attribute report for DUT PhysicalContactOccupiedToUnoccupiedDelay attribute.") + TestStep("3a", "Do not trigger DUT for occupancy state change."), + TestStep("3b", "TH reads DUT Occupancy attribute and saves the initial value as initial"), + TestStep("3c", "Trigger DUT to change the occupancy state."), + TestStep("3d", "TH awaits a ReportDataMessage containing an attribute report for DUT Occupancy attribute."), + TestStep("4a", "Check if DUT supports HoldTime attribute, If not supported, then stop and skip the rest of test cases."), + TestStep("4b", "TH reads DUT HoldTime attribute and saves the initial value as initial"), + TestStep("4c", "TH writes a different value to DUT HoldTime attribute."), + TestStep("4d", "TH awaits a ReportDataMessage containing an attribute report for DUT HoldTime attribute."), + TestStep("5a", "Check if DUT supports DUT feature flag PIR or OTHER, If not supported, then stop and skip to 6a."), + TestStep("5b", "TH reads DUT PIROccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), + TestStep("5c", "TH writes a different value to DUT PIROccupiedToUnoccupiedDelay attribute."), + TestStep("5d", "TH awaits a ReportDataMessage containing an attribute report for DUT PIROccupiedToUnoccupiedDelay attribute."), + TestStep("6a", "Check if DUT supports DUT feature flag US, If not supported, then stop and skip to 7a."), + TestStep("6b", "TH reads DUT UltrasonicOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), + TestStep("6c", "TH writes a different value to DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), + TestStep("6d", "TH awaits a ReportDataMessage containing an attribute report for DUT UltrasonicOccupiedToUnoccupiedDelay attribute."), + TestStep("7a", "Check if DUT supports DUT feature flag PHY, If not supported, terminate this test case."), + TestStep("7b", "TH reads DUT PhysicalContactOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), + TestStep("7c", "TH writes a different value to DUT PhysicalContactOccupiedToUnoccupiedDelay attribute."), + TestStep("7d", "TH awaits a ReportDataMessage containing an attribute report for DUT PhysicalContactOccupiedToUnoccupiedDelay attribute.") ] return steps @@ -113,10 +125,10 @@ async def test_TC_OCC_3_2(self): node_id = self.matter_test_config.dut_node_ids[0] post_prompt_settle_delay_seconds = 10.0 cluster = Clusters.Objects.OccupancySensing - + attributes = Clusters.OccupancySensing.Attributes + occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) self.step(1) - attributes = Clusters.OccupancySensing.Attributes attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) self.step(2) @@ -124,98 +136,102 @@ async def test_TC_OCC_3_2(self): attrib_listener = ClusterAttributeChangeAccumulator(Clusters.Objects.OccupancySensing) await attrib_listener.start(ChipDeviceCtrl, node_id, endpoint=endpoint_id) - self.step(3) + self.step("3a") self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after DUT goes back to unoccupied state.") - self.step(4) + self.step("3b") if attributes.Occupancy.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) asserts.assert_equal(initial_dut, 0, "Occupancy attribute is still detected state") - self.step(5) + self.step("3c") self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after the sensor occupancy is triggered and its occupancy state changed.") - self.step(6) + self.step("3d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.Occupancy, sequence=[ 0, 1], timeout_sec=post_prompt_settle_delay_seconds) - self.step(7) + self.step("4a") if attributes.HoldTime.attribute_id not in attribute_list: logging.info("No HoldTime attribute supports. Terminate this test case") self.skip_all_remaining_steps("4b") - self.step(8) + + self.step("4b") initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) - self.step(9) + self.step("4c") # write a different a HoldTime attibute diff_val = 12 await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.HoldTime(diff_val))]) - self.step(10) + self.step("4d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.HoldTime, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - self.step(11) - if (Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared | Clusters.OccupancySensing.Bitmaps.Feature.kOther) != 1: - self.skip(12) - self.skip(13) - self.skip(14) + self.step("5a") + if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir) == 0: + logging.info("No PIR timing attribute supports. Skip this test case") + self.skip("5b") + self.skip("5c") + self.skip("5d") - self.step(12) + self.step("5b") if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) else: logging.info("No PIROccupiedToUnoccupiedDelay attribute supports. Terminate this test case") - self.step(13) + self.step("5c") # write the new attribute value diff_val = 11 await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PIROccupiedToUnoccupiedDelay(diff_val))]) - self.step(14) + self.step("5d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PIROccupiedToUnoccupiedDelay, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - self.step(15) - if Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic != 1: - self.skip(16) - self.skip(17) - self.skip(18) + self.step("6a") + if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) == 0: + logging.info("No Ultrasonic timing attribute supports. Skip this test case") + self.skip("6b") + self.skip("6c") + self.skip("6d") - self.step(16) + self.step("6b") if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) else: - logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Terminate this test case") + logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Skip this test case") - self.step(17) + self.step("6c") # write the new attribute value diff_val = 14 await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.UltrasonicOccupiedToUnoccupiedDelay(diff_val))]) - self.step(18) + self.step("6d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.UltrasonicOccupiedToUnoccupiedDelay, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - self.step(19) - if Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact != 1: - self.skip_all_remaining_steps(20) + self.step("7a") + if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) == 0: + logging.info("No Physical contact timing attribute supports. Skip this test case") + self.skip_all_remaining_steps("7b") - self.step(20) + self.step("7b") if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list: initial_dut = await self.t_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) else: - logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Terminate this test case") + logging.info("No PhysicalContactOccupiedToUnoccupiedDelay attribute supports. Skip this test case") - self.step(21) + self.step("7c") # write the new attribute value diff_val = 9 await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PhysicalContactOccupiedToUnoccupiedDelay(diff_val))]) - self.step(22) + self.step("7d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PhysicalContactOccupiedToUnoccupiedDelay, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) From e64eed17064c4b390e1159009940fece2930922a Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 10:03:53 -0500 Subject: [PATCH 47/86] Update TC_OCC_2_1.py --- src/python_testing/TC_OCC_2_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 9ce392a1a4620a..d7ed2a63423e82 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -133,7 +133,7 @@ async def test_TC_OCC_2_1(self): asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") else: - logging.info("PIROccupiedToUnoccupiedDelay conformance failed".) + logging.info("PIROccupiedToUnoccupiedDelay conformance failed") asserts.fail("PIROccupiedToUnoccupiedDelay conformance is incorrect") else: logging.info("PIROccupiedToUnoccupiedDelay not supported. Test step skipped") From 38fa992994987553324a59c7615afe605f0a5dec Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 10:45:57 -0500 Subject: [PATCH 48/86] Update TC_OCC_2_1.py --- src/python_testing/TC_OCC_2_1.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index d7ed2a63423e82..cb32055f31a914 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -37,21 +37,20 @@ def desc_TC_OCC_2_1(self) -> str: def steps_TC_OCC_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 Occupancy attribute."), - TestStep(4, "Read OccupancySensorType attribute."), - TestStep(5, "Read OccupancySensorTypeBitmap attribute."), + TestStep(2, "Read Occupancy attribute."), + TestStep(3, "Read OccupancySensorType attribute."), + TestStep(4, "Read OccupancySensorTypeBitmap attribute."), + TestStep(5, "Read HoldTimeLimits attribute, if supported"), TestStep(6, "Read HoldTime attribute, if supported"), - TestStep(7, "Read HoldTimeLimits attribute, if supported"), - TestStep(8, "Read PIROccupiedToUnoccupiedDelay attribute, if supported"), - TestStep(9, "Read PIRUnoccupiedToOccupiedDelay attribute, if supported"), - TestStep(10, "Read PIRUnoccupiedToOccupiedThreshold attribute, if supported"), - TestStep(11, "Read UltrasonicOccupiedToUnoccupiedDelay attribute, if supported"), - TestStep(12, "Read UltrasonicUnoccupiedToOccupiedDelay attribute, if supported"), - TestStep(13, "Read UltrasonicUnoccupiedToOccupiedThreshold attribute, if supported"), - TestStep(14, "Read PhysicalContactOccupiedToUnoccupiedDelay attribute, if supported"), - TestStep(15, "Read PhysicalContactUnoccupiedToOccupiedDelay attribute, if supported"), - TestStep(16, "Read PhysicalContactUnoccupiedToOccupiedThreshold attribute, if supported") + TestStep(7, "Read PIROccupiedToUnoccupiedDelay attribute, if supported"), + TestStep(8, "Read PIRUnoccupiedToOccupiedDelay attribute, if supported"), + TestStep(9, "Read PIRUnoccupiedToOccupiedThreshold attribute, if supported"), + TestStep(10, "Read UltrasonicOccupiedToUnoccupiedDelay attribute, if supported"), + TestStep(11, "Read UltrasonicUnoccupiedToOccupiedDelay attribute, if supported"), + TestStep(12, "Read UltrasonicUnoccupiedToOccupiedThreshold attribute, if supported"), + TestStep(13, "Read PhysicalContactOccupiedToUnoccupiedDelay attribute, if supported"), + TestStep(14, "Read PhysicalContactUnoccupiedToOccupiedDelay attribute, if supported"), + TestStep(15, "Read PhysicalContactUnoccupiedToOccupiedThreshold attribute, if supported") ] return steps From 05110cb28307217c0546aba43530f592bb581248 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:24:44 -0500 Subject: [PATCH 49/86] Update TC_OCC_2_1.py --- src/python_testing/TC_OCC_2_1.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index cb32055f31a914..9f8ae3123c4212 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -82,6 +82,10 @@ async def test_TC_OCC_2_1(self): occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) asserts.assert_less(occupancy_sensor_type_dut, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUnknownEnumValue, "OccupancySensorType is not in valid range") + asserts.assert_in(occupancy_sensor_type_dut, {Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIR, + Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, + Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, + Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact},"OccupancySensorType is not in valid range") else: logging.info("OccupancySensorType attribute is a mandatory attribute. Test step fails") asserts.fail("Missing mandatory attribute OccupancySensorType") @@ -116,9 +120,10 @@ async def test_TC_OCC_2_1(self): self.step(6) if attributes.HoldTime.attribute_id in attribute_list: hold_time_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) + hold_time_limits_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTimeLimits) - asserts.assert_less_equal(hold_time_dut, 0xFFFE, "HoldTime attribute is out of range") - asserts.assert_greater_equal(hold_time_dut, 0, "HoldTime attribute is out of range") + asserts.assert_less_equal(hold_time_dut, hold_time_limits_dut.HoldTimeMax, "HoldTime attribute is out of range") + asserts.assert_greater_equal(hold_time_dut, hold_time_limits_dut.HoldTimeMin, "HoldTime attribute is out of range") else: logging.info("HoldTime not supported. The rest of legacy attribute test can be skipped") self.skip_all_remaining_steps(7) From e3d9184ed3f4e53238304a34933c964fbf0a0398 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:35:41 -0500 Subject: [PATCH 50/86] Update TC_OCC_2_1.py --- src/python_testing/TC_OCC_2_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 9f8ae3123c4212..83f9d26cf69498 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -17,7 +17,7 @@ # There are CI issues to be followed up for the test cases below that implements manually controlling sensor device for # the occupancy state ON/OFF change. # [TC-OCC-3.1] test procedure step 4 -# [TC-OCC-3.2] test precedure step 3c +# [TC-OCC-3.2] test precedure step 3a, 3c import logging From 264c803bc816128bf8c90d1b201380d6512cd6bf Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 12:07:35 -0500 Subject: [PATCH 51/86] Update TC_OCC_2_1.py --- src/python_testing/TC_OCC_2_1.py | 40 +++++++++++++------------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 83f9d26cf69498..c71eec3c95c427 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -70,33 +70,25 @@ async def test_TC_OCC_2_1(self): attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) self.step(2) - if attributes.Occupancy.attribute_id in attribute_list: - occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) - asserts.assert_less_equal(occupancy_dut, 0b00000001, "Occupancy attribute is not in valid range") - else: - logging.info("Occupancy attribute is a mandatory attribute. Test step fails.") - asserts.fail("Missing mandatory attribute Occupancy") + asserts.assert_in(attributes.Occupancy.attribute_id, attribute_list, "Occupancy attribute is mandatory") + occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) + asserts.assert_less_equal(occupancy_dut, 0b00000001, "Occupancy attribute is not in valid range") self.step(3) - if attributes.OccupancySensorType.attribute_id in attribute_list: - occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) - asserts.assert_less(occupancy_sensor_type_dut, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUnknownEnumValue, - "OccupancySensorType is not in valid range") - asserts.assert_in(occupancy_sensor_type_dut, {Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIR, - Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, - Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, - Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact},"OccupancySensorType is not in valid range") - else: - logging.info("OccupancySensorType attribute is a mandatory attribute. Test step fails") - asserts.fail("Missing mandatory attribute OccupancySensorType") - + asserts.assert_in(attributes.OccupancySensorType.attribute_id, attribute_list, "OccupancySensorType attribute is a mandatory attribute.") + + occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) + asserts.assert_less(occupancy_sensor_type_dut, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUnknownEnumValue, + "OccupancySensorType is not in valid range") + asserts.assert_in(occupancy_sensor_type_dut, {Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIR, + Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, + Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, + Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact},"OccupancySensorType is not in valid range") self.step(4) - if attributes.OccupancySensorTypeBitmap.attribute_id in attribute_list: - occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) - asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") - else: - logging.info("OccupancySensorTypeBitmap attribute is a mandatory attribute. Test step fails") - asserts.fail("Missing mandatory attribute OccupancySensorTypeBitmap") + asserts.assert_in(attributes.OccupancySensorTypeBitmap.attribute_id, attribute_list, "OccupancySensorTypeBitmap attribute is a mandatory attribute.") + + occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) + asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") self.step(5) if attributes.HoldTimeLimits.attribute_id in attribute_list: From a1a20fd53252e7492765ca257dea5851db9ea723 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:01:14 -0500 Subject: [PATCH 52/86] Update TC_OCC_2_1.py update on PIR --- src/python_testing/TC_OCC_2_1.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index c71eec3c95c427..cf4716faf282af 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -92,18 +92,15 @@ async def test_TC_OCC_2_1(self): self.step(5) if attributes.HoldTimeLimits.attribute_id in attribute_list: - if attributes.HoldTime.attribute_id in attribute_list: # check HoldTime conformance - hold_time_limits_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTimeLimits) - - asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMin, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") - asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMin, 0, "HoldTimeMin is not in valid range") - asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMax, 0xFFFE, "HoldTimeMin is not in valid range") - asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMax, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") - asserts.assert_less_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") - asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") - else: - logging.info("HoldTime conformance failed. Test step skipped") - asserts.fail("HoldTime conformance is incorrect") + asserts.assert_in(attributes.HoldTime.attribute_id, attribute_list, "HoldTime attribute conformance failed.") + + hold_time_limits_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTimeLimits) + asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMin, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") + asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMin, 0, "HoldTimeMin is not in valid range") + asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMax, 0xFFFE, "HoldTimeMin is not in valid range") + asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMax, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") + asserts.assert_less_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") + asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") else: logging.info("HoldTimeLimits not supported. Test step skipped") @@ -123,9 +120,12 @@ async def test_TC_OCC_2_1(self): self.step(7) if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: - if ((occupancy_sensor_type_bitmap_dut == 0b00000001) | ((occupancy_sensor_type_bitmap_dut != 0b00000001)&(occupancy_sensor_type_bitmap_dut != 0b00000010)&(occupancy_sensor_type_bitmap_dut != 0b00000100))): + has_pir_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir) == 1 + has_ultrasonic_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) == 1 + has_phy_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) == 1 + if (has_pir_bitmap == 1) or ((has_pir_bitmap == 0)&(has_ultrasonic_bitmap == 0)&(has_phy_bitmap == 0)): + pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) - asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") else: @@ -136,7 +136,7 @@ async def test_TC_OCC_2_1(self): self.mark_current_step_skipped() self.step(8) - if attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list: + if attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list: has_delay = attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list has_threshold = attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list asserts.assert_equal(has_delay, has_threshold, "PIRUnoccupiedToOccupiedDelay conformance failure") From 1319d79303b5631d45eff0c74b65fb0bea5eeebe Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:10:52 -0500 Subject: [PATCH 53/86] Update TC_OCC_2_2.py From 386a31f7c6515a2671db05118fd094d99344f096 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:20:27 -0500 Subject: [PATCH 54/86] Update TC_OCC_2_1.py restyled --- src/python_testing/TC_OCC_2_1.py | 74 ++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index cf4716faf282af..526fa36825bf01 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# There are CI issues to be followed up for the test cases below that implements manually controlling sensor device for +# There are CI issues to be followed up for the test cases below that implements manually controlling sensor device for # the occupancy state ON/OFF change. # [TC-OCC-3.1] test procedure step 4 # [TC-OCC-3.2] test precedure step 3a, 3c @@ -75,7 +75,8 @@ async def test_TC_OCC_2_1(self): asserts.assert_less_equal(occupancy_dut, 0b00000001, "Occupancy attribute is not in valid range") self.step(3) - asserts.assert_in(attributes.OccupancySensorType.attribute_id, attribute_list, "OccupancySensorType attribute is a mandatory attribute.") + asserts.assert_in(attributes.OccupancySensorType.attribute_id, attribute_list, + "OccupancySensorType attribute is a mandatory attribute.") occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) asserts.assert_less(occupancy_sensor_type_dut, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUnknownEnumValue, @@ -83,24 +84,29 @@ async def test_TC_OCC_2_1(self): asserts.assert_in(occupancy_sensor_type_dut, {Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIR, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, - Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact},"OccupancySensorType is not in valid range") + Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact}, "OccupancySensorType is not in valid range") self.step(4) - asserts.assert_in(attributes.OccupancySensorTypeBitmap.attribute_id, attribute_list, "OccupancySensorTypeBitmap attribute is a mandatory attribute.") + asserts.assert_in(attributes.OccupancySensorTypeBitmap.attribute_id, attribute_list, + "OccupancySensorTypeBitmap attribute is a mandatory attribute.") occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) - asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") + asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, + "OccupancySensorTypeBitmap attribute is not in valid range") self.step(5) if attributes.HoldTimeLimits.attribute_id in attribute_list: asserts.assert_in(attributes.HoldTime.attribute_id, attribute_list, "HoldTime attribute conformance failed.") - hold_time_limits_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTimeLimits) - asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMin, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") + asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMin, hold_time_limits_dut.HoldTimeMax, + "HoldTimeMin is not in valid range") asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMin, 0, "HoldTimeMin is not in valid range") asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMax, 0xFFFE, "HoldTimeMin is not in valid range") - asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMax, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") - asserts.assert_less_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") - asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") + asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMax, + hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") + asserts.assert_less_equal(hold_time_limits_dut.HoldTimeDefault, + hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") + asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, + hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") else: logging.info("HoldTimeLimits not supported. Test step skipped") @@ -120,11 +126,12 @@ async def test_TC_OCC_2_1(self): self.step(7) if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: - has_pir_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir) == 1 - has_ultrasonic_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) == 1 + has_pir_bitmap = (occupancy_sensor_type_bitmap_dut & + Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir) == 1 + has_ultrasonic_bitmap = (occupancy_sensor_type_bitmap_dut & + Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) == 1 has_phy_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) == 1 - if (has_pir_bitmap == 1) or ((has_pir_bitmap == 0)&(has_ultrasonic_bitmap == 0)&(has_phy_bitmap == 0)): - + if (has_pir_bitmap == 1) or ((has_pir_bitmap == 0)&(has_ultrasonic_bitmap == 0)&(has_phy_bitmap == 0)): pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") @@ -144,7 +151,6 @@ async def test_TC_OCC_2_1(self): pir_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedDelay) asserts.assert_less_equal(pir_utoo_delay_dut, 0xFFFE, "PIRUnoccupiedToOccupiedDelay is not in valid range") asserts.assert_greater_equal(pir_utoo_delay_dut, 0, "PIRUnoccupiedToOccupiedDelay is not in valid range") - else: logging.info("PIRUnoccupiedToOccupiedDelay not supported. Test step skipped") self.mark_current_step_skipped() @@ -158,19 +164,20 @@ async def test_TC_OCC_2_1(self): pir_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedThreshold) asserts.assert_less_equal(pir_utoo_threshold_dut, 0xFE, "PIRUnoccupiedToOccupiedThreshold is not in valid range") asserts.assert_greater_equal(pir_utoo_threshold_dut, 0, "PIRUnoccupiedToOccupiedThreshold is not in valid range") - else: logging.info("PIRUnoccupiedToOccupiedThreshold not supported. Test step skipped") self.mark_current_step_skipped() self.step(10) if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: - has_ultrasonic_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) != 0 + has_ultrasonic_bitmap = (occupancy_sensor_type_bitmap_dut & + Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) != 0 has_ultrasonic_delay = attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list asserts.assert_equal(has_ultrasonic_bitmap, has_ultrasonic_delay, "Bad conformance on Ultrasonic bitmap") ultrasonic_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) - asserts.assert_less_equal(ultrasonic_otou_delay_dut, 0xFFFE, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_less_equal(ultrasonic_otou_delay_dut, 0xFFFE, + "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") asserts.assert_greater_equal(ultrasonic_otou_delay_dut, 0, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") else: @@ -184,7 +191,8 @@ async def test_TC_OCC_2_1(self): asserts.assert_equal(has_delay, has_threshold, "UltrasonicUnoccupiedToOccupiedDelay conformance failure") ultrasonic_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedDelay) - asserts.assert_less_equal(ultrasonic_utoo_delay_dut, 0xFFFE, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_less_equal(ultrasonic_utoo_delay_dut, 0xFFFE, + "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") asserts.assert_greater_equal(ultrasonic_utoo_delay_dut, 0, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") else: logging.info("UltrasonicUnoccupiedToOccupiedDelay not supported. Test step skipped") @@ -197,8 +205,10 @@ async def test_TC_OCC_2_1(self): asserts.assert_equal(has_delay, has_threshold, "UltrasonicUnoccupiedToOccupiedThreshold conformance failure") ultrasonic_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedThreshold) - asserts.assert_less_equal(ultrasonic_utoo_threshold_dut, 0xFE, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") - asserts.assert_greater_equal(ultrasonic_utoo_threshold_dut, 0, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_less_equal(ultrasonic_utoo_threshold_dut, 0xFE, + "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_greater_equal(ultrasonic_utoo_threshold_dut, 0, + "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") else: logging.info("UltrasonicUnoccupiedToOccupiedThreshold not supported. Test step skipped") @@ -206,13 +216,16 @@ async def test_TC_OCC_2_1(self): self.step(13) if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list: - has_phycon_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) != 0 + has_phycon_bitmap = (occupancy_sensor_type_bitmap_dut & + Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) != 0 has_phycon_delay = attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list asserts.assert_equal(has_phycon_bitmap, has_phycon_delay, "Bad conformance on PhysicalContact bitmap") phycontact_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) - asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") - asserts.assert_greater_equal(phycontact_otou_delay_dut, 0, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, + "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") + asserts.assert_greater_equal(phycontact_otou_delay_dut, 0, + "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") else: logging.info("PhysicalContactOccupiedToUnoccupiedDelay not supported. Test step skipped") @@ -225,8 +238,10 @@ async def test_TC_OCC_2_1(self): asserts.assert_equal(has_delay, has_threshold, "PhysicalContactUnoccupiedToOccupiedDelay conformance failure") phycontact_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedDelay) - asserts.assert_less_equal(phycontact_utoo_delay_dut, 0xFFFE, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") - asserts.assert_greater_equal(phycontact_utoo_delay_dut, 0, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_less_equal(phycontact_utoo_delay_dut, 0xFFFE, + "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") + asserts.assert_greater_equal(phycontact_utoo_delay_dut, 0, + "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") else: logging.info("PhysicalContactUnoccupiedToOccupiedDelay not supported. Test step skipped") @@ -239,12 +254,15 @@ async def test_TC_OCC_2_1(self): asserts.assert_equal(has_delay, has_threshold, "PhysicalContactUnoccupiedToOccupiedThreshold conformance failure") phycontact_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedThreshold) - asserts.assert_less_equal(phycontact_utoo_threshold_dut, 0xFE, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") - asserts.assert_greater_equal(phycontact_utoo_threshold_dut, 0, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_less_equal(phycontact_utoo_threshold_dut, 0xFE, + "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") + asserts.assert_greater_equal(phycontact_utoo_threshold_dut, 0, + "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") else: logging.info("PhysicalContactUnoccupiedToOccupiedThreshold not supported. Test step skipped") self.mark_current_step_skipped() + if __name__ == "__main__": default_matter_test_main() From 73d642e6dcb5d5bd85e96f4183247868abb56041 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:26:10 -0500 Subject: [PATCH 55/86] Update TC_OCC_2_2.py restyled --- src/python_testing/TC_OCC_2_2.py | 48 +++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 564daa7a4edb9c..07e9457cd8c4c3 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -57,27 +57,35 @@ async def test_TC_OCC_2_2(self): attributes = Clusters.OccupancySensing.Attributes attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) - self.step(2) + self.step(2) if attributes.OccupancySensorType.attribute_id in attribute_list: occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) feature_map = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.attributes.FeatureMap) if (feature_map != feature_map_PIR)&(feature_map != feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") + asserts.assert_equal(occupancy_sensor_type_dut, + Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") elif (feature_map == feature_map_PIR)&(feature_map != feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") + asserts.assert_equal(occupancy_sensor_type_dut, + Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") elif (feature_map != feature_map_PIR)&(feature_map == feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonci, "OccupancySensorType is not Ultrasonic") + asserts.assert_equal( + occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonci, "OccupancySensorType is not Ultrasonic") elif (feature_map == feature_map_PIR)&(feature_map == feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, "OccupancySensorType is not PIRAndUltrasonic") + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, + "OccupancySensorType is not PIRAndUltrasonic") elif (feature_map != feature_map_PIR)&(feature_map != feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, "OccupancySensorType is not PhysicalContact") + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, + "OccupancySensorType is not PhysicalContact") elif (feature_map == feature_map_PIR)&(feature_map != feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") + asserts.assert_equal(occupancy_sensor_type_dut, + Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") elif (feature_map != feature_map_PIR)&(feature_map == feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") + asserts.assert_equal( + occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") elif (feature_map == feature_map_PIR)&(feature_map == feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, "OccupancySensorType is not PIRAndUltrasonic") + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, + "OccupancySensorType is not PIRAndUltrasonic") else: logging.info("OccupancySensorType mandatory attribute is not supported. Test step skipped") @@ -89,25 +97,33 @@ async def test_TC_OCC_2_2(self): feature_map = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.attributes.FeatureMap) if (feature_map != feature_map_PIR)&(feature_map != feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, + Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") elif (feature_map == feature_map_PIR)&(feature_map != feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, + Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") elif (feature_map != feature_map_PIR)&(feature_map == feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, "OccupancySensorType is not Ultrasonic") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, + Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, "OccupancySensorType is not Ultrasonic") elif (feature_map == feature_map_PIR)&(feature_map == feature_map_US)&(feature_map != feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000011, "OccupancySensorType is not PIR+Ultrasonic") elif (feature_map != feature_map_PIR)&(feature_map != feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, "OccupancySensorType is not PhysicalContact") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, + Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, "OccupancySensorType is not PhysicalContact") elif (feature_map == feature_map_PIR)&(feature_map != feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000101, "OccupancySensorType is not PIR + PhysicalContact") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000101, + "OccupancySensorType is not PIR + PhysicalContact") elif (feature_map != feature_map_PIR)&(feature_map == feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000110, "OccupancySensorType is not PhysicalContact + Ultrasonic") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000110, + "OccupancySensorType is not PhysicalContact + Ultrasonic") elif (feature_map == feature_map_PIR)&(feature_map == feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorType is not PIR+Ultrasonic+Ultrasonic") + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, + "OccupancySensorType is not PIR+Ultrasonic+Ultrasonic") else: logging.info("OccupancySensorTypeBitmap mandatory attribute is not supported. Test step skipped") asserts.fail("Missing mandatory attribute OccupancySensorTypeBitmap") + if __name__ == "__main__": default_matter_test_main() From 8b430efc7f2e224ad7d31b02feeed0626496beca Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:28:55 -0500 Subject: [PATCH 56/86] Update TC_OCC_2_3.py restyled --- src/python_testing/TC_OCC_2_3.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/python_testing/TC_OCC_2_3.py b/src/python_testing/TC_OCC_2_3.py index 5b3fb85c55d454..d06f8ac8aa982e 100644 --- a/src/python_testing/TC_OCC_2_3.py +++ b/src/python_testing/TC_OCC_2_3.py @@ -59,7 +59,6 @@ async def test_TC_OCC_2_3(self): self.step(2) if attributes.HoldTime.attribute_id in attribute_list: occupancy_hold_time_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) - else: logging.info("No HoldTime attribute supports. Terminate this test case") @@ -76,24 +75,29 @@ async def test_TC_OCC_2_3(self): if occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir: occupancy_pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) - asserts.assert_equal(occupancy_pir_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") + asserts.assert_equal(occupancy_pir_otou_delay_dut, occupancy_hold_time_dut, + "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") elif occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic: occupancy_us_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) - asserts.assert_equal(occupancy_us_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to UltrasonicOccupiedToUnoccupiedDelay") + asserts.assert_equal(occupancy_us_otou_delay_dut, occupancy_hold_time_dut, + "HoldTime attribute value is not equal to UltrasonicOccupiedToUnoccupiedDelay") elif occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic: occupancy_pirus_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) - asserts.assert_equal(occupancy_pirus_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") + asserts.assert_equal(occupancy_pirus_otou_delay_dut, occupancy_hold_time_dut, + "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") elif occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact: occupancy_phy_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) - asserts.assert_equal(occupancy_phy_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PhysicalContactOccupiedToUnoccupiedDelay") + asserts.assert_equal(occupancy_phy_otou_delay_dut, occupancy_hold_time_dut, + "HoldTime attribute value is not equal to PhysicalContactOccupiedToUnoccupiedDelay") else: logging.info("OccupancySensorType attribute value is out of range") + if __name__ == "__main__": default_matter_test_main() From 99775f238f8b06ae1072b8f9133dbee10f930cde Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:35:11 -0500 Subject: [PATCH 57/86] Update TC_OCC_3_1.py restyled --- src/python_testing/TC_OCC_3_1.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/python_testing/TC_OCC_3_1.py b/src/python_testing/TC_OCC_3_1.py index 5e51af7becb369..65025f17e744e5 100644 --- a/src/python_testing/TC_OCC_3_1.py +++ b/src/python_testing/TC_OCC_3_1.py @@ -65,16 +65,14 @@ def pics_TC_OCC_3_1(self) -> list[str]: async def test_TC_OCC_3_1(self): endpoint = self.user_params.get("endpoint", 1) - node_id = self.matter_test_config.dut_node_ids[0] - hold_time = 10 # 10 seconds for occupancy state hold time self.step(1) # commissioning and getting cluster attribute list attributes = Clusters.OccupancySensing.Attributes attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) - self.step(2) + self.step(2) if attributes.HoldTime.attribute_id in attribute_list: # write 10 as a HoldTime attibute write_res = await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.HoldTime(hold_time))]) @@ -92,12 +90,12 @@ async def test_TC_OCC_3_1(self): # Don't trigger occupancy sensor to render occupancy attribute to 0 if attributes.HoldTime.attribute_id in attribute_list: time.sleep(hold_time + 2) # add some extra 2 seconds to ensure hold time has passed. - else: # a user wait until a sensor specific time to change occupancy attribute to 0. This is the case where the sensor doesn't support HoldTime. - self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after the sensor occupancy is detection ready state (occupancy attribute = 0)") + self.wait_for_user_input( + prompt_msg="Type any letter and press ENTER after the sensor occupancy is detection ready state (occupancy attribute = 0)") # check sensor occupancy state is 0 for the next test step - occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) + occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) asserts.assert_equal(occupancy_dut, 0, "Occupancy attribute is still 1.") self.step(4) @@ -107,22 +105,23 @@ async def test_TC_OCC_3_1(self): # And then check if Occupancy attribute has changed. occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) asserts.assert_equal(occupancy_dut, 1, "Occupancy state is not changed to 1") - + self.step(5) # check if Occupancy attribute is back to 0 after HoldTime attribute period if attributes.HoldTime.attribute_id in attribute_list: # message to the tester self.wait_for_user_input(prompt_msg="Do not trigger sensor during HoldTime.") - + # Start a timer based on HoldTime time.sleep(hold_time+2) # add some extra 2 seconds to ensure hold time has passed. occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) asserts.assert_equal(occupancy_dut, 0, "Occupancy state is not 0 after HoldTime period") - else: + else: logging.info("HoldTime attribute not supported. Skip this test procedure.") self.skip_step(5) + if __name__ == "__main__": default_matter_test_main() From 214f3267722dd42b83bee93bef611ad7210cd778 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:44:34 -0500 Subject: [PATCH 58/86] Update TC_OCC_3_2.py restyled --- src/python_testing/TC_OCC_3_2.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py index 00a5b2c37e2986..f8bafa62fdc05d 100644 --- a/src/python_testing/TC_OCC_3_2.py +++ b/src/python_testing/TC_OCC_3_2.py @@ -22,19 +22,21 @@ # test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === -# There are CI issues to be followed up for the test cases below that implements manually controlling sensor device for +# TODO: There are CI issues to be followed up for the test cases below that implements manually controlling sensor device for # the occupancy state ON/OFF change. # [TC-OCC-3.1] test procedure step 4 # [TC-OCC-3.2] test precedure step 3a, 3c import logging -import time import queue +import time from typing import Any -from chip import ChipDeviceCtrl + import chip.clusters as Clusters +from chip import ChipDeviceCtrl from chip.clusters.Attribute import TypedAttributePath -from matter_testing_support import MatterBaseTest, ClusterAttributeChangeAccumulator, AttributeValue, TestStep, async_test_body, default_matter_test_main +from matter_testing_support import (AttributeValue, ClusterAttributeChangeAccumulator, MatterBaseTest, TestStep, async_test_body, + default_matter_test_main) from mobly import asserts @@ -80,7 +82,7 @@ def _await_sequence_of_reports(self, report_queue: queue.Queue, endpoint_id: int time_remaining = timeout_sec - elapsed asserts.fail(f"Did not get full sequence {sequence} in {timeout_sec:.1f} seconds. Got {actual_values} before time-out.") - + def desc_TC_OCC_3_2(self) -> str: return "[TC-OCC-3.2] Subscription Report Verification with server as DUT" @@ -107,7 +109,7 @@ def steps_TC_OCC_3_2(self) -> list[TestStep]: TestStep("7a", "Check if DUT supports DUT feature flag PHY, If not supported, terminate this test case."), TestStep("7b", "TH reads DUT PhysicalContactOccupiedToUnoccupiedDelay attribute and saves the initial value as initial"), TestStep("7c", "TH writes a different value to DUT PhysicalContactOccupiedToUnoccupiedDelay attribute."), - TestStep("7d", "TH awaits a ReportDataMessage containing an attribute report for DUT PhysicalContactOccupiedToUnoccupiedDelay attribute.") + TestStep("7d", "TH awaits a ReportDataMessage containing an attribute report for DUT PhysicalContactOccupiedToUnoccupiedDelay attribute.") ] return steps @@ -135,7 +137,7 @@ async def test_TC_OCC_3_2(self): # min interval = 0, and max interval = 30 seconds attrib_listener = ClusterAttributeChangeAccumulator(Clusters.Objects.OccupancySensing) await attrib_listener.start(ChipDeviceCtrl, node_id, endpoint=endpoint_id) - + self.step("3a") self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after DUT goes back to unoccupied state.") @@ -143,7 +145,7 @@ async def test_TC_OCC_3_2(self): if attributes.Occupancy.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) asserts.assert_equal(initial_dut, 0, "Occupancy attribute is still detected state") - + self.step("3c") self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after the sensor occupancy is triggered and its occupancy state changed.") @@ -155,7 +157,7 @@ async def test_TC_OCC_3_2(self): if attributes.HoldTime.attribute_id not in attribute_list: logging.info("No HoldTime attribute supports. Terminate this test case") self.skip_all_remaining_steps("4b") - + self.step("4b") initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) @@ -233,7 +235,7 @@ async def test_TC_OCC_3_2(self): self.step("7d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PhysicalContactOccupiedToUnoccupiedDelay, sequence=[ - initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - + initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) + if __name__ == "__main__": default_matter_test_main() From c299926c1343a21f5ea68b9683fac06303e11754 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:58:35 -0500 Subject: [PATCH 59/86] Update TC_OCC_2_1.py --- src/python_testing/TC_OCC_2_1.py | 47 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 526fa36825bf01..4832f8433fe2a2 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -76,7 +76,7 @@ async def test_TC_OCC_2_1(self): self.step(3) asserts.assert_in(attributes.OccupancySensorType.attribute_id, attribute_list, - "OccupancySensorType attribute is a mandatory attribute.") + "OccupancySensorType attribute is a mandatory attribute.") occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) asserts.assert_less(occupancy_sensor_type_dut, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUnknownEnumValue, @@ -90,22 +90,22 @@ async def test_TC_OCC_2_1(self): "OccupancySensorTypeBitmap attribute is a mandatory attribute.") occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) - asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, + asserts.assert_less_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorTypeBitmap attribute is not in valid range") self.step(5) if attributes.HoldTimeLimits.attribute_id in attribute_list: asserts.assert_in(attributes.HoldTime.attribute_id, attribute_list, "HoldTime attribute conformance failed.") hold_time_limits_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTimeLimits) - asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMin, hold_time_limits_dut.HoldTimeMax, + asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMin, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMin, 0, "HoldTimeMin is not in valid range") asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMax, 0xFFFE, "HoldTimeMin is not in valid range") - asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMax, + asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMax, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") - asserts.assert_less_equal(hold_time_limits_dut.HoldTimeDefault, + asserts.assert_less_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") - asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, + asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") else: @@ -126,12 +126,13 @@ async def test_TC_OCC_2_1(self): self.step(7) if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: - has_pir_bitmap = (occupancy_sensor_type_bitmap_dut & + has_pir_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir) == 1 - has_ultrasonic_bitmap = (occupancy_sensor_type_bitmap_dut & + has_ultrasonic_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) == 1 - has_phy_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) == 1 - if (has_pir_bitmap == 1) or ((has_pir_bitmap == 0)&(has_ultrasonic_bitmap == 0)&(has_phy_bitmap == 0)): + has_phy_bitmap = (occupancy_sensor_type_bitmap_dut & + Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) == 1 + if (has_pir_bitmap == 1) or ((has_pir_bitmap == 0)&(has_ultrasonic_bitmap == 0)&(has_phy_bitmap == 0)): pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") @@ -170,13 +171,13 @@ async def test_TC_OCC_2_1(self): self.step(10) if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: - has_ultrasonic_bitmap = (occupancy_sensor_type_bitmap_dut & + has_ultrasonic_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) != 0 has_ultrasonic_delay = attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list asserts.assert_equal(has_ultrasonic_bitmap, has_ultrasonic_delay, "Bad conformance on Ultrasonic bitmap") ultrasonic_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) - asserts.assert_less_equal(ultrasonic_otou_delay_dut, 0xFFFE, + asserts.assert_less_equal(ultrasonic_otou_delay_dut, 0xFFFE, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") asserts.assert_greater_equal(ultrasonic_otou_delay_dut, 0, "UltrasonicOccupiedToUnoccupiedDelay is not in valid range") @@ -190,8 +191,8 @@ async def test_TC_OCC_2_1(self): has_threshold = attributes.UltrasonicUnoccupiedToOccupiedThreshold.attribute_id in attribute_list asserts.assert_equal(has_delay, has_threshold, "UltrasonicUnoccupiedToOccupiedDelay conformance failure") - ultrasonic_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedDelay) - asserts.assert_less_equal(ultrasonic_utoo_delay_dut, 0xFFFE, + ultrasonic_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedDelay) + asserts.assert_less_equal(ultrasonic_utoo_delay_dut, 0xFFFE, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") asserts.assert_greater_equal(ultrasonic_utoo_delay_dut, 0, "UltrasonicUnoccupiedToOccupiedDelay is not in valid range") else: @@ -205,9 +206,9 @@ async def test_TC_OCC_2_1(self): asserts.assert_equal(has_delay, has_threshold, "UltrasonicUnoccupiedToOccupiedThreshold conformance failure") ultrasonic_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicUnoccupiedToOccupiedThreshold) - asserts.assert_less_equal(ultrasonic_utoo_threshold_dut, 0xFE, + asserts.assert_less_equal(ultrasonic_utoo_threshold_dut, 0xFE, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") - asserts.assert_greater_equal(ultrasonic_utoo_threshold_dut, 0, + asserts.assert_greater_equal(ultrasonic_utoo_threshold_dut, 0, "UltrasonicUnoccupiedToOccupiedThreshold is not in valid range") else: @@ -216,15 +217,15 @@ async def test_TC_OCC_2_1(self): self.step(13) if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list: - has_phycon_bitmap = (occupancy_sensor_type_bitmap_dut & + has_phycon_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) != 0 has_phycon_delay = attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list asserts.assert_equal(has_phycon_bitmap, has_phycon_delay, "Bad conformance on PhysicalContact bitmap") phycontact_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) - asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, + asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") - asserts.assert_greater_equal(phycontact_otou_delay_dut, 0, + asserts.assert_greater_equal(phycontact_otou_delay_dut, 0, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") else: @@ -238,9 +239,9 @@ async def test_TC_OCC_2_1(self): asserts.assert_equal(has_delay, has_threshold, "PhysicalContactUnoccupiedToOccupiedDelay conformance failure") phycontact_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedDelay) - asserts.assert_less_equal(phycontact_utoo_delay_dut, 0xFFFE, + asserts.assert_less_equal(phycontact_utoo_delay_dut, 0xFFFE, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") - asserts.assert_greater_equal(phycontact_utoo_delay_dut, 0, + asserts.assert_greater_equal(phycontact_utoo_delay_dut, 0, "PhysicalContactUnoccupiedToOccupiedDelay is not in valid range") else: @@ -254,9 +255,9 @@ async def test_TC_OCC_2_1(self): asserts.assert_equal(has_delay, has_threshold, "PhysicalContactUnoccupiedToOccupiedThreshold conformance failure") phycontact_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactUnoccupiedToOccupiedThreshold) - asserts.assert_less_equal(phycontact_utoo_threshold_dut, 0xFE, + asserts.assert_less_equal(phycontact_utoo_threshold_dut, 0xFE, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") - asserts.assert_greater_equal(phycontact_utoo_threshold_dut, 0, + asserts.assert_greater_equal(phycontact_utoo_threshold_dut, 0, "PhysicalContactUnoccupiedToOccupiedThreshold is not in valid range") else: From 009761bbdf1dd584ba6e09747c209f8baca77ba3 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 15:04:21 -0500 Subject: [PATCH 60/86] Update TC_OCC_2_1.py --- src/python_testing/TC_OCC_2_1.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 4832f8433fe2a2..706f4c7e760c4f 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -107,7 +107,6 @@ async def test_TC_OCC_2_1(self): hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") - else: logging.info("HoldTimeLimits not supported. Test step skipped") self.mark_current_step_skipped() @@ -132,7 +131,7 @@ async def test_TC_OCC_2_1(self): Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) == 1 has_phy_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) == 1 - if (has_pir_bitmap == 1) or ((has_pir_bitmap == 0)&(has_ultrasonic_bitmap == 0)&(has_phy_bitmap == 0)): + if (has_pir_bitmap == 1) or ((has_pir_bitmap == 0) & (has_ultrasonic_bitmap == 0) & (has_phy_bitmap == 0)): pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") @@ -148,7 +147,6 @@ async def test_TC_OCC_2_1(self): has_delay = attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list has_threshold = attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list asserts.assert_equal(has_delay, has_threshold, "PIRUnoccupiedToOccupiedDelay conformance failure") - pir_utoo_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedDelay) asserts.assert_less_equal(pir_utoo_delay_dut, 0xFFFE, "PIRUnoccupiedToOccupiedDelay is not in valid range") asserts.assert_greater_equal(pir_utoo_delay_dut, 0, "PIRUnoccupiedToOccupiedDelay is not in valid range") @@ -161,7 +159,6 @@ async def test_TC_OCC_2_1(self): has_delay = attributes.PIRUnoccupiedToOccupiedDelay.attribute_id in attribute_list has_threshold = attributes.PIRUnoccupiedToOccupiedThreshold.attribute_id in attribute_list asserts.assert_equal(has_delay, has_threshold, "PIRUnoccupiedToOccupiedThreshold conformance failure") - pir_utoo_threshold_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIRUnoccupiedToOccupiedThreshold) asserts.assert_less_equal(pir_utoo_threshold_dut, 0xFE, "PIRUnoccupiedToOccupiedThreshold is not in valid range") asserts.assert_greater_equal(pir_utoo_threshold_dut, 0, "PIRUnoccupiedToOccupiedThreshold is not in valid range") @@ -221,7 +218,6 @@ async def test_TC_OCC_2_1(self): Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) != 0 has_phycon_delay = attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list asserts.assert_equal(has_phycon_bitmap, has_phycon_delay, "Bad conformance on PhysicalContact bitmap") - phycontact_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") From d797b80757c1da96faf5d551e36a26f0d52beb2a Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 15:08:51 -0500 Subject: [PATCH 61/86] Update TC_OCC_2_1.py --- src/python_testing/TC_OCC_2_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 706f4c7e760c4f..1780664bd38b68 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -218,7 +218,7 @@ async def test_TC_OCC_2_1(self): Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) != 0 has_phycon_delay = attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list asserts.assert_equal(has_phycon_bitmap, has_phycon_delay, "Bad conformance on PhysicalContact bitmap") - phycontact_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) + phycontact_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) asserts.assert_less_equal(phycontact_otou_delay_dut, 0xFFFE, "PhysicalContactOccupiedToUnoccupiedDelay is not in valid range") asserts.assert_greater_equal(phycontact_otou_delay_dut, 0, From 25382a4ebc53e660c21b15d1d414c08c22c02e4f Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 31 Jul 2024 17:28:58 -0400 Subject: [PATCH 62/86] Restyle --- src/python_testing/TC_OCC_2_1.py | 2 +- src/python_testing/TC_OCC_2_2.py | 62 +++++++++++++-------------- src/python_testing/TC_OCC_2_3.py | 22 +++++----- src/python_testing/TC_OCC_3_1.py | 26 ++++++------ src/python_testing/TC_OCC_3_2.py | 72 ++++++++++++++++---------------- 5 files changed, 93 insertions(+), 91 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 1780664bd38b68..99331090793ed5 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -110,7 +110,7 @@ async def test_TC_OCC_2_1(self): else: logging.info("HoldTimeLimits not supported. Test step skipped") self.mark_current_step_skipped() - + self.step(6) if attributes.HoldTime.attribute_id in attribute_list: hold_time_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 07e9457cd8c4c3..5e447dcabd2342 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -56,35 +56,35 @@ async def test_TC_OCC_2_2(self): self.step(1) attributes = Clusters.OccupancySensing.Attributes attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) - + self.step(2) if attributes.OccupancySensorType.attribute_id in attribute_list: occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) feature_map = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.attributes.FeatureMap) - - if (feature_map != feature_map_PIR)&(feature_map != feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, + + if (feature_map != feature_map_PIR) & (feature_map != feature_map_US) & (feature_map != feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - elif (feature_map == feature_map_PIR)&(feature_map != feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, + elif (feature_map == feature_map_PIR) & (feature_map != feature_map_US) & (feature_map != feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - elif (feature_map != feature_map_PIR)&(feature_map == feature_map_US)&(feature_map != feature_map_PHY): + elif (feature_map != feature_map_PIR) & (feature_map == feature_map_US) & (feature_map != feature_map_PHY): asserts.assert_equal( occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonci, "OccupancySensorType is not Ultrasonic") - elif (feature_map == feature_map_PIR)&(feature_map == feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, + elif (feature_map == feature_map_PIR) & (feature_map == feature_map_US) & (feature_map != feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, "OccupancySensorType is not PIRAndUltrasonic") - elif (feature_map != feature_map_PIR)&(feature_map != feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, + elif (feature_map != feature_map_PIR) & (feature_map != feature_map_US) & (feature_map == feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, "OccupancySensorType is not PhysicalContact") - elif (feature_map == feature_map_PIR)&(feature_map != feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, + elif (feature_map == feature_map_PIR) & (feature_map != feature_map_US) & (feature_map == feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - elif (feature_map != feature_map_PIR)&(feature_map == feature_map_US)&(feature_map == feature_map_PHY): + elif (feature_map != feature_map_PIR) & (feature_map == feature_map_US) & (feature_map == feature_map_PHY): asserts.assert_equal( occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") - elif (feature_map == feature_map_PIR)&(feature_map == feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, + elif (feature_map == feature_map_PIR) & (feature_map == feature_map_US) & (feature_map == feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, "OccupancySensorType is not PIRAndUltrasonic") else: @@ -96,28 +96,28 @@ async def test_TC_OCC_2_2(self): occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) feature_map = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.attributes.FeatureMap) - if (feature_map != feature_map_PIR)&(feature_map != feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, + if (feature_map != feature_map_PIR) & (feature_map != feature_map_US) & (feature_map != feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") - elif (feature_map == feature_map_PIR)&(feature_map != feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, + elif (feature_map == feature_map_PIR) & (feature_map != feature_map_US) & (feature_map != feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") - elif (feature_map != feature_map_PIR)&(feature_map == feature_map_US)&(feature_map != feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, + elif (feature_map != feature_map_PIR) & (feature_map == feature_map_US) & (feature_map != feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, "OccupancySensorType is not Ultrasonic") - elif (feature_map == feature_map_PIR)&(feature_map == feature_map_US)&(feature_map != feature_map_PHY): + elif (feature_map == feature_map_PIR) & (feature_map == feature_map_US) & (feature_map != feature_map_PHY): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000011, "OccupancySensorType is not PIR+Ultrasonic") - elif (feature_map != feature_map_PIR)&(feature_map != feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, + elif (feature_map != feature_map_PIR) & (feature_map != feature_map_US) & (feature_map == feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, "OccupancySensorType is not PhysicalContact") - elif (feature_map == feature_map_PIR)&(feature_map != feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000101, + elif (feature_map == feature_map_PIR) & (feature_map != feature_map_US) & (feature_map == feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000101, "OccupancySensorType is not PIR + PhysicalContact") - elif (feature_map != feature_map_PIR)&(feature_map == feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000110, + elif (feature_map != feature_map_PIR) & (feature_map == feature_map_US) & (feature_map == feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000110, "OccupancySensorType is not PhysicalContact + Ultrasonic") - elif (feature_map == feature_map_PIR)&(feature_map == feature_map_US)&(feature_map == feature_map_PHY): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, + elif (feature_map == feature_map_PIR) & (feature_map == feature_map_US) & (feature_map == feature_map_PHY): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorType is not PIR+Ultrasonic+Ultrasonic") else: diff --git a/src/python_testing/TC_OCC_2_3.py b/src/python_testing/TC_OCC_2_3.py index d06f8ac8aa982e..45c947186974bf 100644 --- a/src/python_testing/TC_OCC_2_3.py +++ b/src/python_testing/TC_OCC_2_3.py @@ -55,13 +55,13 @@ async def test_TC_OCC_2_3(self): self.step(1) attributes = Clusters.OccupancySensing.Attributes attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) - + self.step(2) if attributes.HoldTime.attribute_id in attribute_list: occupancy_hold_time_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) else: logging.info("No HoldTime attribute supports. Terminate this test case") - + self.step(3) if attributes.OccupancySensorType.attribute_id in attribute_list: occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) @@ -75,26 +75,26 @@ async def test_TC_OCC_2_3(self): if occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir: occupancy_pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) - asserts.assert_equal(occupancy_pir_otou_delay_dut, occupancy_hold_time_dut, + asserts.assert_equal(occupancy_pir_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") - + elif occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic: occupancy_us_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) - - asserts.assert_equal(occupancy_us_otou_delay_dut, occupancy_hold_time_dut, + + asserts.assert_equal(occupancy_us_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to UltrasonicOccupiedToUnoccupiedDelay") elif occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic: occupancy_pirus_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) - asserts.assert_equal(occupancy_pirus_otou_delay_dut, occupancy_hold_time_dut, - "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") + asserts.assert_equal(occupancy_pirus_otou_delay_dut, occupancy_hold_time_dut, + "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") elif occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact: occupancy_phy_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) - - asserts.assert_equal(occupancy_phy_otou_delay_dut, occupancy_hold_time_dut, - "HoldTime attribute value is not equal to PhysicalContactOccupiedToUnoccupiedDelay") + + asserts.assert_equal(occupancy_phy_otou_delay_dut, occupancy_hold_time_dut, + "HoldTime attribute value is not equal to PhysicalContactOccupiedToUnoccupiedDelay") else: logging.info("OccupancySensorType attribute value is out of range") diff --git a/src/python_testing/TC_OCC_3_1.py b/src/python_testing/TC_OCC_3_1.py index 65025f17e744e5..19499b9862d6b3 100644 --- a/src/python_testing/TC_OCC_3_1.py +++ b/src/python_testing/TC_OCC_3_1.py @@ -22,7 +22,7 @@ # test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === -# There are CI issues to be followed up for the test cases below that implements manually controlling sensor device for +# There are CI issues to be followed up for the test cases below that implements manually controlling sensor device for # the occupancy state ON/OFF change. # [TC-OCC-3.1] test procedure step 4 # [TC-OCC-3.2] test precedure step 3c @@ -30,9 +30,9 @@ import logging import time +import chip.clusters as Clusters from chip import ChipDeviceCtrl from chip.interaction_model import Status -import chip.clusters as Clusters from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts @@ -66,12 +66,12 @@ async def test_TC_OCC_3_1(self): endpoint = self.user_params.get("endpoint", 1) node_id = self.matter_test_config.dut_node_ids[0] - hold_time = 10 # 10 seconds for occupancy state hold time + hold_time = 10 # 10 seconds for occupancy state hold time - self.step(1) # commissioning and getting cluster attribute list + self.step(1) # commissioning and getting cluster attribute list attributes = Clusters.OccupancySensing.Attributes attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) - + self.step(2) if attributes.HoldTime.attribute_id in attribute_list: # write 10 as a HoldTime attibute @@ -80,7 +80,7 @@ async def test_TC_OCC_3_1(self): else: logging.info("No HoldTime attribute supports. Will test only occupancy attribute triggering functionality") - + self.step(3) # check if Occupancy attribute is 0 occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) @@ -89,8 +89,8 @@ async def test_TC_OCC_3_1(self): if occupancy_dut == 1: # Don't trigger occupancy sensor to render occupancy attribute to 0 if attributes.HoldTime.attribute_id in attribute_list: - time.sleep(hold_time + 2) # add some extra 2 seconds to ensure hold time has passed. - else: # a user wait until a sensor specific time to change occupancy attribute to 0. This is the case where the sensor doesn't support HoldTime. + time.sleep(hold_time + 2) # add some extra 2 seconds to ensure hold time has passed. + else: # a user wait until a sensor specific time to change occupancy attribute to 0. This is the case where the sensor doesn't support HoldTime. self.wait_for_user_input( prompt_msg="Type any letter and press ENTER after the sensor occupancy is detection ready state (occupancy attribute = 0)") @@ -105,19 +105,19 @@ async def test_TC_OCC_3_1(self): # And then check if Occupancy attribute has changed. occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) asserts.assert_equal(occupancy_dut, 1, "Occupancy state is not changed to 1") - + self.step(5) # check if Occupancy attribute is back to 0 after HoldTime attribute period if attributes.HoldTime.attribute_id in attribute_list: # message to the tester self.wait_for_user_input(prompt_msg="Do not trigger sensor during HoldTime.") - + # Start a timer based on HoldTime - time.sleep(hold_time+2) # add some extra 2 seconds to ensure hold time has passed. - + time.sleep(hold_time+2) # add some extra 2 seconds to ensure hold time has passed. + occupancy_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) asserts.assert_equal(occupancy_dut, 0, "Occupancy state is not 0 after HoldTime period") - + else: logging.info("HoldTime attribute not supported. Skip this test procedure.") self.skip_step(5) diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py index f8bafa62fdc05d..b30e0abd1cec29 100644 --- a/src/python_testing/TC_OCC_3_2.py +++ b/src/python_testing/TC_OCC_3_2.py @@ -35,7 +35,7 @@ import chip.clusters as Clusters from chip import ChipDeviceCtrl from chip.clusters.Attribute import TypedAttributePath -from matter_testing_support import (AttributeValue, ClusterAttributeChangeAccumulator, MatterBaseTest, TestStep, async_test_body, +from matter_testing_support import (AttributeValue, ClusterAttributeChangeAccumulator, MatterBaseTest, TestStep, async_test_body, default_matter_test_main) from mobly import asserts @@ -82,7 +82,7 @@ def _await_sequence_of_reports(self, report_queue: queue.Queue, endpoint_id: int time_remaining = timeout_sec - elapsed asserts.fail(f"Did not get full sequence {sequence} in {timeout_sec:.1f} seconds. Got {actual_values} before time-out.") - + def desc_TC_OCC_3_2(self) -> str: return "[TC-OCC-3.2] Subscription Report Verification with server as DUT" @@ -132,110 +132,112 @@ async def test_TC_OCC_3_2(self): self.step(1) attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) - + self.step(2) # min interval = 0, and max interval = 30 seconds attrib_listener = ClusterAttributeChangeAccumulator(Clusters.Objects.OccupancySensing) await attrib_listener.start(ChipDeviceCtrl, node_id, endpoint=endpoint_id) - + self.step("3a") self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after DUT goes back to unoccupied state.") - + self.step("3b") if attributes.Occupancy.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) asserts.assert_equal(initial_dut, 0, "Occupancy attribute is still detected state") - + self.step("3c") - self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after the sensor occupancy is triggered and its occupancy state changed.") - + self.wait_for_user_input( + prompt_msg="Type any letter and press ENTER after the sensor occupancy is triggered and its occupancy state changed.") + self.step("3d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.Occupancy, sequence=[ 0, 1], timeout_sec=post_prompt_settle_delay_seconds) - + self.step("4a") if attributes.HoldTime.attribute_id not in attribute_list: logging.info("No HoldTime attribute supports. Terminate this test case") self.skip_all_remaining_steps("4b") - + self.step("4b") initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) - + self.step("4c") # write a different a HoldTime attibute diff_val = 12 await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.HoldTime(diff_val))]) - + self.step("4d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.HoldTime, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - + self.step("5a") if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir) == 0: logging.info("No PIR timing attribute supports. Skip this test case") self.skip("5b") self.skip("5c") self.skip("5d") - - self.step("5b") + + self.step("5b") if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) - - else: + + else: logging.info("No PIROccupiedToUnoccupiedDelay attribute supports. Terminate this test case") - + self.step("5c") # write the new attribute value diff_val = 11 await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PIROccupiedToUnoccupiedDelay(diff_val))]) - + self.step("5d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PIROccupiedToUnoccupiedDelay, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - + self.step("6a") - if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) == 0: + if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) == 0: logging.info("No Ultrasonic timing attribute supports. Skip this test case") self.skip("6b") self.skip("6c") self.skip("6d") - - self.step("6b") + + self.step("6b") if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) - - else: + + else: logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Skip this test case") - + self.step("6c") # write the new attribute value diff_val = 14 await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.UltrasonicOccupiedToUnoccupiedDelay(diff_val))]) - + self.step("6d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.UltrasonicOccupiedToUnoccupiedDelay, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - + self.step("7a") if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) == 0: logging.info("No Physical contact timing attribute supports. Skip this test case") self.skip_all_remaining_steps("7b") - - self.step("7b") + + self.step("7b") if attributes.PhysicalContactOccupiedToUnoccupiedDelay.attribute_id in attribute_list: initial_dut = await self.t_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) - - else: + + else: logging.info("No PhysicalContactOccupiedToUnoccupiedDelay attribute supports. Skip this test case") - + self.step("7c") # write the new attribute value diff_val = 9 await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PhysicalContactOccupiedToUnoccupiedDelay(diff_val))]) - + self.step("7d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PhysicalContactOccupiedToUnoccupiedDelay, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - + + if __name__ == "__main__": default_matter_test_main() From 9ec09b4c380456b79a875f850be9e972ddb6f0de Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 20:46:43 -0500 Subject: [PATCH 63/86] Update TC_OCC_2_2.py bitmap conditional statement revised --- src/python_testing/TC_OCC_2_2.py | 34 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 5e447dcabd2342..91cd1e86ca0c04 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -33,8 +33,8 @@ def desc_TC_OCC_2_2(self) -> str: def steps_TC_OCC_2_2(self) -> list[TestStep]: steps = [ TestStep(1, "Commissioning, already done", is_commissioning=True), - TestStep(2, "Read OccupancySensorType attribute with repect to featureMap."), - TestStep(3, "Read OccupancySensorTypeBitmap attribute with repect to featureMap.") + TestStep(2, "Read OccupancySensorType attribute selection based on FeatureMap Bitmap."), + TestStep(3, "Read OccupancySensorTypeBitmap attribute selection based on FeatureMap Bitmap.") ] return steps @@ -49,41 +49,53 @@ async def test_TC_OCC_2_2(self): endpoint = self.user_params.get("endpoint", 1) + feature_map = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) feature_map_PIR = Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared feature_map_US = Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic feature_map_PHY = Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact + is_pir_feature_supported = feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared + is_us_feature_supported = feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic + is_phy_feature_supported = feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact self.step(1) attributes = Clusters.OccupancySensing.Attributes attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) self.step(2) + # OccupancySensorType will be determined by FeatureMap matching table at 2.7.6.2. if attributes.OccupancySensorType.attribute_id in attribute_list: occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) - feature_map = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.attributes.FeatureMap) - if (feature_map != feature_map_PIR) & (feature_map != feature_map_US) & (feature_map != feature_map_PHY): + # No Bitmap support from PIR, US, Physical Contact, then OccupancySensorType should be PIR + if (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - elif (feature_map == feature_map_PIR) & (feature_map != feature_map_US) & (feature_map != feature_map_PHY): + # Bitmap supports PIR, then OccupancySensorType should be PIR + elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - elif (feature_map != feature_map_PIR) & (feature_map == feature_map_US) & (feature_map != feature_map_PHY): + # Bitmap supports US, then OccupancySensorType should be US + elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): asserts.assert_equal( occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonci, "OccupancySensorType is not Ultrasonic") - elif (feature_map == feature_map_PIR) & (feature_map == feature_map_US) & (feature_map != feature_map_PHY): + # Bitmap supports PIR and US, then OccupancySensorType should be PIRAndUltrasonic + elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, "OccupancySensorType is not PIRAndUltrasonic") - elif (feature_map != feature_map_PIR) & (feature_map != feature_map_US) & (feature_map == feature_map_PHY): + # Bitmap supports Physical Contact, then OccupancySensorType should be Physical Contact + elif (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, "OccupancySensorType is not PhysicalContact") - elif (feature_map == feature_map_PIR) & (feature_map != feature_map_US) & (feature_map == feature_map_PHY): + # Bitmap supports Physical Contact and PIR, then OccupancySensorType should be PIR + elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - elif (feature_map != feature_map_PIR) & (feature_map == feature_map_US) & (feature_map == feature_map_PHY): + # Bitmap supports US and Physical Contact, then OccupancySensorType should be US + elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): asserts.assert_equal( occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") - elif (feature_map == feature_map_PIR) & (feature_map == feature_map_US) & (feature_map == feature_map_PHY): + # Bitmap supports PIR, US and Physical Contact, then OccupancySensorType should be PIRAndUltrasonic + elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, "OccupancySensorType is not PIRAndUltrasonic") From 218885277af10902ee6682128938cc2cefdef78a Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 21:02:41 -0500 Subject: [PATCH 64/86] Update TC_OCC_2_2.py Bitmap matching statement update --- src/python_testing/TC_OCC_2_2.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 91cd1e86ca0c04..746879e6737600 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -49,16 +49,13 @@ async def test_TC_OCC_2_2(self): endpoint = self.user_params.get("endpoint", 1) + attributes = Clusters.OccupancySensing.Attributes feature_map = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) - feature_map_PIR = Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared - feature_map_US = Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic - feature_map_PHY = Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact is_pir_feature_supported = feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared is_us_feature_supported = feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic is_phy_feature_supported = feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact self.step(1) - attributes = Clusters.OccupancySensing.Attributes attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) self.step(2) @@ -104,31 +101,39 @@ async def test_TC_OCC_2_2(self): asserts.fail("Missing mandatory attribute OccupancySensorType") self.step(3) + # OccupancySensorTypeBitmap will be determined by FeatureMap matching table at 2.7.6.2. if attributes.OccupancySensorTypeBitmap.attribute_id in attribute_list: occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) - feature_map = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.attributes.FeatureMap) - if (feature_map != feature_map_PIR) & (feature_map != feature_map_US) & (feature_map != feature_map_PHY): + # No Bitmap support from PIR, US, Physical Contact, then OccupancySensorTypeBitmap should be PIR + if (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") - elif (feature_map == feature_map_PIR) & (feature_map != feature_map_US) & (feature_map != feature_map_PHY): + # Bitmap supports PIR, then OccupancySensorTypeBitmap should be PIR + elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") - elif (feature_map != feature_map_PIR) & (feature_map == feature_map_US) & (feature_map != feature_map_PHY): + # Bitmap supports US, then OccupancySensorTypeBitmap should be US + elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, "OccupancySensorType is not Ultrasonic") - elif (feature_map == feature_map_PIR) & (feature_map == feature_map_US) & (feature_map != feature_map_PHY): + # Bitmap supports PIR and US, then OccupancySensorTypeBitmap should be PIRAndUltrasonic + elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000011, "OccupancySensorType is not PIR+Ultrasonic") - elif (feature_map != feature_map_PIR) & (feature_map != feature_map_US) & (feature_map == feature_map_PHY): + # Bitmap supports Physical Contact, then OccupancySensorTypeBitmap should be Physical Contact + elif (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, "OccupancySensorType is not PhysicalContact") - elif (feature_map == feature_map_PIR) & (feature_map != feature_map_US) & (feature_map == feature_map_PHY): + # Bitmap supports Physical Contact and PIR, then OccupancySensorTypeBitmap should be PIR + PhysicalContact + elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000101, "OccupancySensorType is not PIR + PhysicalContact") - elif (feature_map != feature_map_PIR) & (feature_map == feature_map_US) & (feature_map == feature_map_PHY): + # Bitmap supports US and Physical Contact, then OccupancySensorTypeBitmap should be US + Physical contact + elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000110, "OccupancySensorType is not PhysicalContact + Ultrasonic") - elif (feature_map == feature_map_PIR) & (feature_map == feature_map_US) & (feature_map == feature_map_PHY): + # Bitmap supports PIR, US and Physical Contact, then OccupancySensorTypeBitmap should be PIRAndUltrasonicAndPhy + elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, "OccupancySensorType is not PIR+Ultrasonic+Ultrasonic") From 2c25e663cdc353c769dcf733bbc52b6c7f1dff52 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Wed, 31 Jul 2024 21:24:41 -0500 Subject: [PATCH 65/86] Update TC_OCC_3_1.py --- src/python_testing/TC_OCC_3_1.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/python_testing/TC_OCC_3_1.py b/src/python_testing/TC_OCC_3_1.py index 19499b9862d6b3..4380866333f339 100644 --- a/src/python_testing/TC_OCC_3_1.py +++ b/src/python_testing/TC_OCC_3_1.py @@ -99,7 +99,7 @@ async def test_TC_OCC_3_1(self): asserts.assert_equal(occupancy_dut, 0, "Occupancy attribute is still 1.") self.step(4) - # Trigger occupancy sensor to change Occupancy attribute value to 1 => TEST ACTION on DUT + # Trigger occupancy sensor to change Occupancy attribute value to 1 => TESTER ACTION on DUT self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after a sensor occupancy is triggered.") # And then check if Occupancy attribute has changed. @@ -108,9 +108,8 @@ async def test_TC_OCC_3_1(self): self.step(5) # check if Occupancy attribute is back to 0 after HoldTime attribute period + # Tester should not be triggering the sensor for this test step. if attributes.HoldTime.attribute_id in attribute_list: - # message to the tester - self.wait_for_user_input(prompt_msg="Do not trigger sensor during HoldTime.") # Start a timer based on HoldTime time.sleep(hold_time+2) # add some extra 2 seconds to ensure hold time has passed. @@ -119,7 +118,7 @@ async def test_TC_OCC_3_1(self): asserts.assert_equal(occupancy_dut, 0, "Occupancy state is not 0 after HoldTime period") else: - logging.info("HoldTime attribute not supported. Skip this test procedure.") + logging.info("HoldTime attribute not supported. Skip this return to 0 timing test procedure.") self.skip_step(5) From 79710ce5cd8dae3bc5e66d174188870b2e967d0f Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Thu, 1 Aug 2024 06:57:22 -0500 Subject: [PATCH 66/86] Update src/python_testing/TC_OCC_2_2.py typo Co-authored-by: Andrei Litvin --- src/python_testing/TC_OCC_2_2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 746879e6737600..63d4a1c563103b 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -74,7 +74,8 @@ async def test_TC_OCC_2_2(self): # Bitmap supports US, then OccupancySensorType should be US elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): asserts.assert_equal( - occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonci, "OccupancySensorType is not Ultrasonic") + occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") + # Bitmap supports PIR and US, then OccupancySensorType should be PIRAndUltrasonic elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, From 9f68ef60af0095e2ae52f08764eb91d90fdd2506 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Thu, 1 Aug 2024 07:05:10 -0500 Subject: [PATCH 67/86] Update src/python_testing/TC_OCC_2_2.py Co-authored-by: Andrei Litvin --- src/python_testing/TC_OCC_2_2.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 63d4a1c563103b..8944b68f3e7c2a 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -51,9 +51,10 @@ async def test_TC_OCC_2_2(self): attributes = Clusters.OccupancySensing.Attributes feature_map = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) - is_pir_feature_supported = feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared - is_us_feature_supported = feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic - is_phy_feature_supported = feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact + is_pir_feature_supported = (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared) != 0 + is_us_feature_supported = (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic) != 0 + is_phy_feature_supported = (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact) != 0 + self.step(1) attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) From 30f86dd0ec4a8d2ae1eea0e40db227f61b66bf89 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Thu, 1 Aug 2024 07:24:29 -0500 Subject: [PATCH 68/86] Update TC_OCC_2_2.py --- src/python_testing/TC_OCC_2_2.py | 151 +++++++++++++++---------------- 1 file changed, 73 insertions(+), 78 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 8944b68f3e7c2a..543a2b29275a43 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -61,87 +61,82 @@ async def test_TC_OCC_2_2(self): self.step(2) # OccupancySensorType will be determined by FeatureMap matching table at 2.7.6.2. - if attributes.OccupancySensorType.attribute_id in attribute_list: - occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) - - # No Bitmap support from PIR, US, Physical Contact, then OccupancySensorType should be PIR - if (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_dut, - Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - # Bitmap supports PIR, then OccupancySensorType should be PIR - elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_dut, - Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - # Bitmap supports US, then OccupancySensorType should be US - elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): - asserts.assert_equal( - occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") - - # Bitmap supports PIR and US, then OccupancySensorType should be PIRAndUltrasonic - elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, - "OccupancySensorType is not PIRAndUltrasonic") - # Bitmap supports Physical Contact, then OccupancySensorType should be Physical Contact - elif (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, - "OccupancySensorType is not PhysicalContact") - # Bitmap supports Physical Contact and PIR, then OccupancySensorType should be PIR - elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_dut, - Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - # Bitmap supports US and Physical Contact, then OccupancySensorType should be US - elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): - asserts.assert_equal( - occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") - # Bitmap supports PIR, US and Physical Contact, then OccupancySensorType should be PIRAndUltrasonic - elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, - "OccupancySensorType is not PIRAndUltrasonic") - - else: - logging.info("OccupancySensorType mandatory attribute is not supported. Test step skipped") - asserts.fail("Missing mandatory attribute OccupancySensorType") + asserts.assert_in(attributes.OccupancySensor.attribute_id, attribute_list, + "OccupancySensorType attribute is a mandatory attribute.") + occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) + + # No Bitmap support from PIR, US, Physical Contact, then OccupancySensorType should be PIR + if (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): + asserts.assert_equal(occupancy_sensor_type_dut, + Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") + # Bitmap supports PIR, then OccupancySensorType should be PIR + elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): + asserts.assert_equal(occupancy_sensor_type_dut, + Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") + # Bitmap supports US, then OccupancySensorType should be US + elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): + asserts.assert_equal( + occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") + + # Bitmap supports PIR and US, then OccupancySensorType should be PIRAndUltrasonic + elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, + "OccupancySensorType is not PIRAndUltrasonic") + # Bitmap supports Physical Contact, then OccupancySensorType should be Physical Contact + elif (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, + "OccupancySensorType is not PhysicalContact") + # Bitmap supports Physical Contact and PIR, then OccupancySensorType should be PIR + elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): + asserts.assert_equal(occupancy_sensor_type_dut, + Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") + # Bitmap supports US and Physical Contact, then OccupancySensorType should be US + elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): + asserts.assert_equal( + occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") + # Bitmap supports PIR, US and Physical Contact, then OccupancySensorType should be PIRAndUltrasonic + elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): + asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, + "OccupancySensorType is not PIRAndUltrasonic") self.step(3) # OccupancySensorTypeBitmap will be determined by FeatureMap matching table at 2.7.6.2. - if attributes.OccupancySensorTypeBitmap.attribute_id in attribute_list: - occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) - - # No Bitmap support from PIR, US, Physical Contact, then OccupancySensorTypeBitmap should be PIR - if (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, - Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") - # Bitmap supports PIR, then OccupancySensorTypeBitmap should be PIR - elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, - Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") - # Bitmap supports US, then OccupancySensorTypeBitmap should be US - elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, - Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, "OccupancySensorType is not Ultrasonic") - # Bitmap supports PIR and US, then OccupancySensorTypeBitmap should be PIRAndUltrasonic - elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000011, "OccupancySensorType is not PIR+Ultrasonic") - # Bitmap supports Physical Contact, then OccupancySensorTypeBitmap should be Physical Contact - elif (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, - Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, "OccupancySensorType is not PhysicalContact") - # Bitmap supports Physical Contact and PIR, then OccupancySensorTypeBitmap should be PIR + PhysicalContact - elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000101, - "OccupancySensorType is not PIR + PhysicalContact") - # Bitmap supports US and Physical Contact, then OccupancySensorTypeBitmap should be US + Physical contact - elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000110, - "OccupancySensorType is not PhysicalContact + Ultrasonic") - # Bitmap supports PIR, US and Physical Contact, then OccupancySensorTypeBitmap should be PIRAndUltrasonicAndPhy - elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, - "OccupancySensorType is not PIR+Ultrasonic+Ultrasonic") - - else: - logging.info("OccupancySensorTypeBitmap mandatory attribute is not supported. Test step skipped") - asserts.fail("Missing mandatory attribute OccupancySensorTypeBitmap") + asserts.assert_in(attributes.OccupancySensorTypeBitmap.attribute_id, attribute_list, + "OccupancySensorTypeBitmap attribute is a mandatory attribute.") + + occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) + + # No Bitmap support from PIR, US, Physical Contact, then OccupancySensorTypeBitmap should be PIR + if (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, + Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") + # Bitmap supports PIR, then OccupancySensorTypeBitmap should be PIR + elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, + Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") + # Bitmap supports US, then OccupancySensorTypeBitmap should be US + elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, + Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, "OccupancySensorType is not Ultrasonic") + # Bitmap supports PIR and US, then OccupancySensorTypeBitmap should be PIRAndUltrasonic + elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000011, "OccupancySensorType is not PIR+Ultrasonic") + # Bitmap supports Physical Contact, then OccupancySensorTypeBitmap should be Physical Contact + elif (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, + Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, "OccupancySensorType is not PhysicalContact") + # Bitmap supports Physical Contact and PIR, then OccupancySensorTypeBitmap should be PIR + PhysicalContact + elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000101, + "OccupancySensorType is not PIR + PhysicalContact") + # Bitmap supports US and Physical Contact, then OccupancySensorTypeBitmap should be US + Physical contact + elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000110, + "OccupancySensorType is not PhysicalContact + Ultrasonic") + # Bitmap supports PIR, US and Physical Contact, then OccupancySensorTypeBitmap should be PIRAndUltrasonicAndPhy + elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): + asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, + "OccupancySensorType is not PIR+Ultrasonic+Ultrasonic") if __name__ == "__main__": From f6f1aa81448d65261a8ed6fd0fa996e4360ed046 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Thu, 1 Aug 2024 07:33:30 -0500 Subject: [PATCH 69/86] Update TC_OCC_2_2.py --- src/python_testing/TC_OCC_2_2.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 543a2b29275a43..8ee85d117b014d 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -15,8 +15,6 @@ # 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 @@ -55,7 +53,6 @@ async def test_TC_OCC_2_2(self): is_us_feature_supported = (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic) != 0 is_phy_feature_supported = (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact) != 0 - self.step(1) attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) From ed0c1652003d1c4aa7d8f298a1f4a1466735b65d Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Thu, 1 Aug 2024 09:26:02 -0500 Subject: [PATCH 70/86] Update TC_OCC_2_2.py rewriting sensor type check --- src/python_testing/TC_OCC_2_2.py | 58 +++++++++++++------------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 8ee85d117b014d..a119c1c355c8b7 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -58,43 +58,33 @@ async def test_TC_OCC_2_2(self): self.step(2) # OccupancySensorType will be determined by FeatureMap matching table at 2.7.6.2. - asserts.assert_in(attributes.OccupancySensor.attribute_id, attribute_list, + asserts.assert_in(attributes.OccupancySensorType.attribute_id, attribute_list, "OccupancySensorType attribute is a mandatory attribute.") occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) - # No Bitmap support from PIR, US, Physical Contact, then OccupancySensorType should be PIR - if (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_dut, - Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - # Bitmap supports PIR, then OccupancySensorType should be PIR - elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_dut, - Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - # Bitmap supports US, then OccupancySensorType should be US - elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): - asserts.assert_equal( - occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") - - # Bitmap supports PIR and US, then OccupancySensorType should be PIRAndUltrasonic - elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, - "OccupancySensorType is not PIRAndUltrasonic") - # Bitmap supports Physical Contact, then OccupancySensorType should be Physical Contact - elif (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, - "OccupancySensorType is not PhysicalContact") - # Bitmap supports Physical Contact and PIR, then OccupancySensorType should be PIR - elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_dut, - Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, "OccupancySensorType is not PIR") - # Bitmap supports US and Physical Contact, then OccupancySensorType should be US - elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): - asserts.assert_equal( - occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, "OccupancySensorType is not Ultrasonic") - # Bitmap supports PIR, US and Physical Contact, then OccupancySensorType should be PIRAndUltrasonic - elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_dut, Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, - "OccupancySensorType is not PIRAndUltrasonic") + # if OccupancySensorType is PIR, check bitmaps + assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, + not is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported) + assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, + is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported) + assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, + is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported) + + # if OccupancySensorType is Ultrasonic, check bitmaps + assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, + not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported) + assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, + not is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported) + + # if OccupancySensorType is PIRAndUltrasonic, check bitmaps + assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, + is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported) + assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, + is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported) + + # if OccupancySensorType is PhysicalContact, check bitmaps + assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, + not is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported) self.step(3) # OccupancySensorTypeBitmap will be determined by FeatureMap matching table at 2.7.6.2. From f4380967d533e2e5e6e840457ce488daef595196 Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Thu, 1 Aug 2024 09:35:20 -0500 Subject: [PATCH 71/86] Update TC_OCC_2_2.py --- src/python_testing/TC_OCC_2_2.py | 60 +++++++++++++++----------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index a119c1c355c8b7..d2f0460c66f29e 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -93,37 +93,35 @@ async def test_TC_OCC_2_2(self): occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) - # No Bitmap support from PIR, US, Physical Contact, then OccupancySensorTypeBitmap should be PIR - if (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, - Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") - # Bitmap supports PIR, then OccupancySensorTypeBitmap should be PIR - elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, - Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, "OccupancySensorType is not PIR") - # Bitmap supports US, then OccupancySensorTypeBitmap should be US - elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, - Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, "OccupancySensorType is not Ultrasonic") - # Bitmap supports PIR and US, then OccupancySensorTypeBitmap should be PIRAndUltrasonic - elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported != 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000011, "OccupancySensorType is not PIR+Ultrasonic") - # Bitmap supports Physical Contact, then OccupancySensorTypeBitmap should be Physical Contact - elif (is_pir_feature_supported != 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, - Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, "OccupancySensorType is not PhysicalContact") - # Bitmap supports Physical Contact and PIR, then OccupancySensorTypeBitmap should be PIR + PhysicalContact - elif (is_pir_feature_supported == 1) & (is_us_feature_supported != 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000101, - "OccupancySensorType is not PIR + PhysicalContact") - # Bitmap supports US and Physical Contact, then OccupancySensorTypeBitmap should be US + Physical contact - elif (is_pir_feature_supported != 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000110, - "OccupancySensorType is not PhysicalContact + Ultrasonic") - # Bitmap supports PIR, US and Physical Contact, then OccupancySensorTypeBitmap should be PIRAndUltrasonicAndPhy - elif (is_pir_feature_supported == 1) & (is_us_feature_supported == 1) & (is_phy_feature_supported == 1): - asserts.assert_equal(occupancy_sensor_type_bitmap_dut, 0b00000111, - "OccupancySensorType is not PIR+Ultrasonic+Ultrasonic") + # if OccupancySensorTypeBitmap is PIR, check bitmaps + assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, + not is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported) + assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, + is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported) + + # if OccupancySensorTypeBitmap is Ultrasonic, check bitmaps + assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, + not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported) + + # if OccupancySensorTypeBitmap is PhysicalContact, check bitmaps + assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, + not is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported) + + # if OccupancySensorTypeBitmap is PIR+Ultrasonic, check bitmaps + assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000011, + not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported) + + # if OccupancySensorTypeBitmap is PIR+PhysicalContact, check bitmaps + assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000101, + is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported) + + # if OccupancySensorTypeBitmap is US+PhysicalContact, check bitmaps + assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000110, + not is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported) + + # if OccupancySensorTypeBitmap is PIR+US+PhysicalContact, check bitmaps + assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000111, + is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported) if __name__ == "__main__": From 775105bf9234ff5004f02ca0e82e5bbded62488d Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Thu, 1 Aug 2024 09:41:31 -0500 Subject: [PATCH 72/86] Update TC_OCC_2_2.py --- src/python_testing/TC_OCC_2_2.py | 44 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index d2f0460c66f29e..bdd19787579065 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -94,34 +94,34 @@ async def test_TC_OCC_2_2(self): occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) # if OccupancySensorTypeBitmap is PIR, check bitmaps - assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, - not is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported) - assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, - is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported) + assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, + not is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported) + assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, + is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported) # if OccupancySensorTypeBitmap is Ultrasonic, check bitmaps - assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, - not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported) + assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, + not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported) # if OccupancySensorTypeBitmap is PhysicalContact, check bitmaps - assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, - not is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported) + assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, + not is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported) # if OccupancySensorTypeBitmap is PIR+Ultrasonic, check bitmaps - assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000011, - not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported) - - # if OccupancySensorTypeBitmap is PIR+PhysicalContact, check bitmaps - assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000101, - is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported) - - # if OccupancySensorTypeBitmap is US+PhysicalContact, check bitmaps - assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000110, - not is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported) - - # if OccupancySensorTypeBitmap is PIR+US+PhysicalContact, check bitmaps - assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000111, - is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported) + assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000011, + not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported) + + # if OccupancySensorTypeBitmap is PIR+PhysicalContact, check bitmaps + assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000101, + is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported) + + # if OccupancySensorTypeBitmap is US+PhysicalContact, check bitmaps + assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000110, + not is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported) + + # if OccupancySensorTypeBitmap is PIR+US+PhysicalContact, check bitmaps + assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000111, + is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported) if __name__ == "__main__": From 3db7f0236f41a920d20ee0683b20f6bfc0c94a6e Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Thu, 1 Aug 2024 10:08:25 -0500 Subject: [PATCH 73/86] Update TC_OCC_2_2.py --- src/python_testing/TC_OCC_2_2.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index bdd19787579065..1483d58a2dc575 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -64,27 +64,27 @@ async def test_TC_OCC_2_2(self): # if OccupancySensorType is PIR, check bitmaps assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, - not is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported) + not is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported, "PIR sensor type is wrong") assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, - is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported) + is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported, "PIR sensor type is wrong") assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, - is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported) + is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported, "PIR sensor type is wrong") # if OccupancySensorType is Ultrasonic, check bitmaps assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, - not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported) + not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported, "Ultrasonic sensor type is wrong") assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, - not is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported) + not is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported, "Ultrasonic sensor type is wrong") # if OccupancySensorType is PIRAndUltrasonic, check bitmaps assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, - is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported) + is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported, "PIRAndUltrasonic sensor type is wrong") assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, - is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported) + is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported, "PIRAndUltrasonic sensor type is wrong") # if OccupancySensorType is PhysicalContact, check bitmaps assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, - not is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported) + not is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported, "PHY Contact sensor type is wrong") self.step(3) # OccupancySensorTypeBitmap will be determined by FeatureMap matching table at 2.7.6.2. @@ -95,33 +95,33 @@ async def test_TC_OCC_2_2(self): # if OccupancySensorTypeBitmap is PIR, check bitmaps assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, - not is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported) + not is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported, "PIR sensor type bitmap is wrong") assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, - is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported) + is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported, "PIR sensor type bitmap is wrong") # if OccupancySensorTypeBitmap is Ultrasonic, check bitmaps assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, - not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported) + not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported, "Ultrasonic sensor type bitmap is wrong") # if OccupancySensorTypeBitmap is PhysicalContact, check bitmaps assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, - not is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported) + not is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported, "Physical contact sensor type bitmap is wrong") # if OccupancySensorTypeBitmap is PIR+Ultrasonic, check bitmaps assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000011, - not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported) + not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported, "PIR+UL sensor type bitmap is wrong") # if OccupancySensorTypeBitmap is PIR+PhysicalContact, check bitmaps assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000101, - is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported) + is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported, "PIR+Phy contact sensor type bitmap is wrong") # if OccupancySensorTypeBitmap is US+PhysicalContact, check bitmaps assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000110, - not is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported) + not is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported, "US+Phy contact sensor type bitmap is wrong") # if OccupancySensorTypeBitmap is PIR+US+PhysicalContact, check bitmaps assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000111, - is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported) + is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported, "PIR+US+Phy contact sensor type bitmap is wrong") if __name__ == "__main__": From 87b3f4ddd97ea6490c7d911226c102964b825144 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 1 Aug 2024 11:29:36 -0400 Subject: [PATCH 74/86] Restyle --- src/python_testing/TC_OCC_2_2.py | 80 ++++++++++++++++---------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 1483d58a2dc575..af3c34b2ffaeb2 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -63,28 +63,28 @@ async def test_TC_OCC_2_2(self): occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) # if OccupancySensorType is PIR, check bitmaps - assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, - not is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported, "PIR sensor type is wrong") - assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, - is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported, "PIR sensor type is wrong") - assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, - is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported, "PIR sensor type is wrong") + assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, + not is_pir_feature_supported & & not is_us_feature_supported & & not is_phy_feature_supported, "PIR sensor type is wrong") + assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, + is_pir_feature_supported & & not is_us_feature_supported & & not is_phy_feature_supported, "PIR sensor type is wrong") + assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, + is_pir_feature_supported & & not is_us_feature_supported & & is_phy_feature_supported, "PIR sensor type is wrong") # if OccupancySensorType is Ultrasonic, check bitmaps - assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, - not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported, "Ultrasonic sensor type is wrong") - assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, - not is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported, "Ultrasonic sensor type is wrong") + assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, + not is_pir_feature_supported & & is_us_feature_supported & & not is_phy_feature_supported, "Ultrasonic sensor type is wrong") + assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, + not is_pir_feature_supported & & is_us_feature_supported & & is_phy_feature_supported, "Ultrasonic sensor type is wrong") # if OccupancySensorType is PIRAndUltrasonic, check bitmaps - assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, - is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported, "PIRAndUltrasonic sensor type is wrong") - assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, - is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported, "PIRAndUltrasonic sensor type is wrong") + assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, + is_pir_feature_supported & & is_us_feature_supported & & not is_phy_feature_supported, "PIRAndUltrasonic sensor type is wrong") + assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, + is_pir_feature_supported & & is_us_feature_supported & & is_phy_feature_supported, "PIRAndUltrasonic sensor type is wrong") # if OccupancySensorType is PhysicalContact, check bitmaps - assert.assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, - not is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported, "PHY Contact sensor type is wrong") + assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, + not is_pir_feature_supported & & not is_us_feature_supported & & is_phy_feature_supported, "PHY Contact sensor type is wrong") self.step(3) # OccupancySensorTypeBitmap will be determined by FeatureMap matching table at 2.7.6.2. @@ -94,34 +94,34 @@ async def test_TC_OCC_2_2(self): occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) # if OccupancySensorTypeBitmap is PIR, check bitmaps - assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, - not is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported, "PIR sensor type bitmap is wrong") - assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, - is_pir_feature_supported && not is_us_feature_supported && not is_phy_feature_supported, "PIR sensor type bitmap is wrong") - + assert .assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, + not is_pir_feature_supported & & not is_us_feature_supported & & not is_phy_feature_supported, "PIR sensor type bitmap is wrong") + assert .assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, + is_pir_feature_supported & & not is_us_feature_supported & & not is_phy_feature_supported, "PIR sensor type bitmap is wrong") + # if OccupancySensorTypeBitmap is Ultrasonic, check bitmaps - assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, - not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported, "Ultrasonic sensor type bitmap is wrong") + assert .assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, + not is_pir_feature_supported & & is_us_feature_supported & & not is_phy_feature_supported, "Ultrasonic sensor type bitmap is wrong") # if OccupancySensorTypeBitmap is PhysicalContact, check bitmaps - assert.assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, - not is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported, "Physical contact sensor type bitmap is wrong") - + assert .assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, + not is_pir_feature_supported & & not is_us_feature_supported & & is_phy_feature_supported, "Physical contact sensor type bitmap is wrong") + # if OccupancySensorTypeBitmap is PIR+Ultrasonic, check bitmaps - assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000011, - not is_pir_feature_supported && is_us_feature_supported && not is_phy_feature_supported, "PIR+UL sensor type bitmap is wrong") - - # if OccupancySensorTypeBitmap is PIR+PhysicalContact, check bitmaps - assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000101, - is_pir_feature_supported && not is_us_feature_supported && is_phy_feature_supported, "PIR+Phy contact sensor type bitmap is wrong") - - # if OccupancySensorTypeBitmap is US+PhysicalContact, check bitmaps - assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000110, - not is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported, "US+Phy contact sensor type bitmap is wrong") - - # if OccupancySensorTypeBitmap is PIR+US+PhysicalContact, check bitmaps - assert.assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000111, - is_pir_feature_supported && is_us_feature_supported && is_phy_feature_supported, "PIR+US+Phy contact sensor type bitmap is wrong") + assert .assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000011, + not is_pir_feature_supported & & is_us_feature_supported & & not is_phy_feature_supported, "PIR+UL sensor type bitmap is wrong") + + # if OccupancySensorTypeBitmap is PIR+PhysicalContact, check bitmaps + assert .assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000101, + is_pir_feature_supported & & not is_us_feature_supported & & is_phy_feature_supported, "PIR+Phy contact sensor type bitmap is wrong") + + # if OccupancySensorTypeBitmap is US+PhysicalContact, check bitmaps + assert .assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000110, + not is_pir_feature_supported & & is_us_feature_supported & & is_phy_feature_supported, "US+Phy contact sensor type bitmap is wrong") + + # if OccupancySensorTypeBitmap is PIR+US+PhysicalContact, check bitmaps + assert .assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000111, + is_pir_feature_supported & & is_us_feature_supported & & is_phy_feature_supported, "PIR+US+Phy contact sensor type bitmap is wrong") if __name__ == "__main__": From 8a888d69a132d0390c5174b1d1aea022f5ab4187 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 1 Aug 2024 12:16:57 -0400 Subject: [PATCH 75/86] Proposal for TC_OCC bitmap compares --- src/python_testing/TC_OCC_2_2.py | 107 +++++++++++++++---------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index af3c34b2ffaeb2..f7d4c60754c938 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -15,11 +15,20 @@ # limitations under the License. # +from dataclasses import dataclass + import chip.clusters as Clusters from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts +@dataclass +class FeatureMapping: + """Maps feature flags to a specific bitmap and sensor type""" + feature_map: int + sensor_type: Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum + + class TC_OCC_2_2(MatterBaseTest): async def read_occ_attribute_expect_success(self, endpoint, attribute): cluster = Clusters.Objects.OccupancySensing @@ -49,9 +58,6 @@ async def test_TC_OCC_2_2(self): attributes = Clusters.OccupancySensing.Attributes feature_map = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) - is_pir_feature_supported = (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared) != 0 - is_us_feature_supported = (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic) != 0 - is_phy_feature_supported = (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact) != 0 self.step(1) attribute_list = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.AttributeList) @@ -62,29 +68,35 @@ async def test_TC_OCC_2_2(self): "OccupancySensorType attribute is a mandatory attribute.") occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) - # if OccupancySensorType is PIR, check bitmaps - assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, - not is_pir_feature_supported & & not is_us_feature_supported & & not is_phy_feature_supported, "PIR sensor type is wrong") - assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, - is_pir_feature_supported & & not is_us_feature_supported & & not is_phy_feature_supported, "PIR sensor type is wrong") - assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, - is_pir_feature_supported & & not is_us_feature_supported & & is_phy_feature_supported, "PIR sensor type is wrong") - - # if OccupancySensorType is Ultrasonic, check bitmaps - assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, - not is_pir_feature_supported & & is_us_feature_supported & & not is_phy_feature_supported, "Ultrasonic sensor type is wrong") - assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, - not is_pir_feature_supported & & is_us_feature_supported & & is_phy_feature_supported, "Ultrasonic sensor type is wrong") - - # if OccupancySensorType is PIRAndUltrasonic, check bitmaps - assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, - is_pir_feature_supported & & is_us_feature_supported & & not is_phy_feature_supported, "PIRAndUltrasonic sensor type is wrong") - assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, - is_pir_feature_supported & & is_us_feature_supported & & is_phy_feature_supported, "PIRAndUltrasonic sensor type is wrong") - - # if OccupancySensorType is PhysicalContact, check bitmaps - assert .assert_equal(occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact, - not is_pir_feature_supported & & not is_us_feature_supported & & is_phy_feature_supported, "PHY Contact sensor type is wrong") + # For validation purposes, 2.7.6.2 table describes what feature flags map to what type of sensors + TypeEnum = Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum + + Y = True + N = False + # Map is PIR, US, PHY => expected sensor type + # odd Y/N mapping to make the table align nicely + mappings = { + (N, N, N): TypeEnum.kPir, + (Y, N, N): TypeEnum.kPir, + (N, Y, N): TypeEnum.kUltrasonic, + (Y, Y, N): TypeEnum.kUltrasonic, + (N, N, Y): TypeEnum.kPhysicalContact, + (Y, N, Y): TypeEnum.kPir, + (N, Y, Y): TypeEnum.kUltrasonic, + (Y, Y, Y): TypeEnum.kPIRAndUltrasonic, + } + expected = mappings.get( + ( + (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared) != 0, + (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic) != 0, + (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact) != 0 + )) + + asserts.assert_equal( + occupancy_sensor_type_dut, + expected, + f"Sensort Type should be f{expected}" + ) self.step(3) # OccupancySensorTypeBitmap will be determined by FeatureMap matching table at 2.7.6.2. @@ -93,35 +105,22 @@ async def test_TC_OCC_2_2(self): occupancy_sensor_type_bitmap_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorTypeBitmap) - # if OccupancySensorTypeBitmap is PIR, check bitmaps - assert .assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, - not is_pir_feature_supported & & not is_us_feature_supported & & not is_phy_feature_supported, "PIR sensor type bitmap is wrong") - assert .assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, - is_pir_feature_supported & & not is_us_feature_supported & & not is_phy_feature_supported, "PIR sensor type bitmap is wrong") - - # if OccupancySensorTypeBitmap is Ultrasonic, check bitmaps - assert .assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, - not is_pir_feature_supported & & is_us_feature_supported & & not is_phy_feature_supported, "Ultrasonic sensor type bitmap is wrong") - - # if OccupancySensorTypeBitmap is PhysicalContact, check bitmaps - assert .assert_equal(occupancy_sensor_bitmap_dut == Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, - not is_pir_feature_supported & & not is_us_feature_supported & & is_phy_feature_supported, "Physical contact sensor type bitmap is wrong") - - # if OccupancySensorTypeBitmap is PIR+Ultrasonic, check bitmaps - assert .assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000011, - not is_pir_feature_supported & & is_us_feature_supported & & not is_phy_feature_supported, "PIR+UL sensor type bitmap is wrong") - - # if OccupancySensorTypeBitmap is PIR+PhysicalContact, check bitmaps - assert .assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000101, - is_pir_feature_supported & & not is_us_feature_supported & & is_phy_feature_supported, "PIR+Phy contact sensor type bitmap is wrong") - - # if OccupancySensorTypeBitmap is US+PhysicalContact, check bitmaps - assert .assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000110, - not is_pir_feature_supported & & is_us_feature_supported & & is_phy_feature_supported, "US+Phy contact sensor type bitmap is wrong") + # Feature map must match the sensor type bitmap + must_match_bits = [ + (Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir, + Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared, "PIR"), + (Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic, + Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic, "Ultrasonic"), + (Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact, + Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact, "Physical contact"), + ] - # if OccupancySensorTypeBitmap is PIR+US+PhysicalContact, check bitmaps - assert .assert_equal(occupancy_sensor_type_bitmap_dut == 0b00000111, - is_pir_feature_supported & & is_us_feature_supported & & is_phy_feature_supported, "PIR+US+Phy contact sensor type bitmap is wrong") + for sensor_bit, feature_bit, name in must_match_bits: + asserts.assert_equal( + (occupancy_sensor_bitmap_dut & sensor_bit) != 0, + (feature_map & feature_bit) != 0, + f"Feature bit and sensor bitmap must be equal for {name}" + ) if __name__ == "__main__": From 01160c476929d08a85f639338b9ffdc50ead7777 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 1 Aug 2024 12:30:57 -0400 Subject: [PATCH 76/86] Fix typo --- src/python_testing/TC_OCC_2_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index f7d4c60754c938..caf156e6608a71 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -117,7 +117,7 @@ async def test_TC_OCC_2_2(self): for sensor_bit, feature_bit, name in must_match_bits: asserts.assert_equal( - (occupancy_sensor_bitmap_dut & sensor_bit) != 0, + (occupancy_sensor_type_bitmap_dut & sensor_bit) != 0, (feature_map & feature_bit) != 0, f"Feature bit and sensor bitmap must be equal for {name}" ) From d7906c5730f7c41be761796c5c509f2c78a2a32e Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 1 Aug 2024 12:33:13 -0400 Subject: [PATCH 77/86] Fix map --- src/python_testing/TC_OCC_2_2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index caf156e6608a71..33287b92964f6d 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -79,7 +79,7 @@ async def test_TC_OCC_2_2(self): (N, N, N): TypeEnum.kPir, (Y, N, N): TypeEnum.kPir, (N, Y, N): TypeEnum.kUltrasonic, - (Y, Y, N): TypeEnum.kUltrasonic, + (Y, Y, N): TypeEnum.kPIRAndUltrasonic, (N, N, Y): TypeEnum.kPhysicalContact, (Y, N, Y): TypeEnum.kPir, (N, Y, Y): TypeEnum.kUltrasonic, From 683e4742840a0f488d6de185296e72b3cf70c52c Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:57:34 -0500 Subject: [PATCH 78/86] Update TC_OCC_3_2.py added else on conditional statement. --- src/python_testing/TC_OCC_3_2.py | 79 ++++++++++++++++---------------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py index b30e0abd1cec29..9b9e852a15edc4 100644 --- a/src/python_testing/TC_OCC_3_2.py +++ b/src/python_testing/TC_OCC_3_2.py @@ -14,6 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# # === BEGIN CI TEST ARGUMENTS === # test-runner-runs: run1 # test-runner-run/run1/app: ${TYPE_OF_APP} @@ -138,6 +141,7 @@ async def test_TC_OCC_3_2(self): attrib_listener = ClusterAttributeChangeAccumulator(Clusters.Objects.OccupancySensing) await attrib_listener.start(ChipDeviceCtrl, node_id, endpoint=endpoint_id) + # TODO - Will add Namepiped to assimilate the manual sensor untrigger here self.step("3a") self.wait_for_user_input(prompt_msg="Type any letter and press ENTER after DUT goes back to unoccupied state.") @@ -146,6 +150,7 @@ async def test_TC_OCC_3_2(self): initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.Occupancy) asserts.assert_equal(initial_dut, 0, "Occupancy attribute is still detected state") + # TODO - Will add Namepiped to assimilate the manual sensor trigger here self.step("3c") self.wait_for_user_input( prompt_msg="Type any letter and press ENTER after the sensor occupancy is triggered and its occupancy state changed.") @@ -173,49 +178,43 @@ async def test_TC_OCC_3_2(self): self.step("5a") if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir) == 0: - logging.info("No PIR timing attribute supports. Skip this test case") - self.skip("5b") - self.skip("5c") - self.skip("5d") - - self.step("5b") - if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: - initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) - - else: - logging.info("No PIROccupiedToUnoccupiedDelay attribute supports. Terminate this test case") - - self.step("5c") - # write the new attribute value - diff_val = 11 - await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PIROccupiedToUnoccupiedDelay(diff_val))]) - - self.step("5d") - self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PIROccupiedToUnoccupiedDelay, sequence=[ - initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - + logging.info("No PIR timing attribute supports. Skip this test cases, 5b, 5c, 5d") + else: + self.step("5b") + if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: + initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) + + else: + logging.info("No PIROccupiedToUnoccupiedDelay attribute supports. Terminate this test case") + + self.step("5c") + # write the new attribute value + diff_val = 11 + await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PIROccupiedToUnoccupiedDelay(diff_val))]) + + self.step("5d") + self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PIROccupiedToUnoccupiedDelay, sequence=[ + initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) + self.step("6a") if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) == 0: - logging.info("No Ultrasonic timing attribute supports. Skip this test case") - self.skip("6b") - self.skip("6c") - self.skip("6d") - - self.step("6b") - if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: - initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) - + logging.info("No Ultrasonic timing attribute supports. Skip this test cases, 6b, 6c, 6d") else: - logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Skip this test case") - - self.step("6c") - # write the new attribute value - diff_val = 14 - await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.UltrasonicOccupiedToUnoccupiedDelay(diff_val))]) - - self.step("6d") - self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.UltrasonicOccupiedToUnoccupiedDelay, sequence=[ - initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) + self.step("6b") + if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: + initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) + + else: + logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Skip this test case") + + self.step("6c") + # write the new attribute value + diff_val = 14 + await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.UltrasonicOccupiedToUnoccupiedDelay(diff_val))]) + + self.step("6d") + self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.UltrasonicOccupiedToUnoccupiedDelay, sequence=[ + initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) self.step("7a") if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) == 0: From bc92bf539555e909a354f3a489164a4f735b870f Mon Sep 17 00:00:00 2001 From: Jae Son <12516308+jaehs6sam@users.noreply.github.com> Date: Thu, 1 Aug 2024 12:12:56 -0500 Subject: [PATCH 79/86] Update TC_OCC_3_2.py put skip back --- src/python_testing/TC_OCC_3_2.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py index 9b9e852a15edc4..25585120f449c3 100644 --- a/src/python_testing/TC_OCC_3_2.py +++ b/src/python_testing/TC_OCC_3_2.py @@ -179,6 +179,9 @@ async def test_TC_OCC_3_2(self): self.step("5a") if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir) == 0: logging.info("No PIR timing attribute supports. Skip this test cases, 5b, 5c, 5d") + self.skip_step("5b") + self.skip_test("5c") + self.skip_step("5d") else: self.step("5b") if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: @@ -199,6 +202,9 @@ async def test_TC_OCC_3_2(self): self.step("6a") if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) == 0: logging.info("No Ultrasonic timing attribute supports. Skip this test cases, 6b, 6c, 6d") + self.skip_step("6b") + self.skip_test("6c") + self.skip_step("6d") else: self.step("6b") if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: From 582bdb7392c6dfb2429b088fdab236b3c057e2aa Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 1 Aug 2024 13:14:34 -0400 Subject: [PATCH 80/86] Restyle --- src/python_testing/TC_OCC_3_2.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/python_testing/TC_OCC_3_2.py b/src/python_testing/TC_OCC_3_2.py index 25585120f449c3..3624f1044c40e8 100644 --- a/src/python_testing/TC_OCC_3_2.py +++ b/src/python_testing/TC_OCC_3_2.py @@ -181,24 +181,24 @@ async def test_TC_OCC_3_2(self): logging.info("No PIR timing attribute supports. Skip this test cases, 5b, 5c, 5d") self.skip_step("5b") self.skip_test("5c") - self.skip_step("5d") - else: + self.skip_step("5d") + else: self.step("5b") if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) - + else: logging.info("No PIROccupiedToUnoccupiedDelay attribute supports. Terminate this test case") - + self.step("5c") # write the new attribute value diff_val = 11 await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.PIROccupiedToUnoccupiedDelay(diff_val))]) - + self.step("5d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.PIROccupiedToUnoccupiedDelay, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) - + self.step("6a") if (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) == 0: logging.info("No Ultrasonic timing attribute supports. Skip this test cases, 6b, 6c, 6d") @@ -209,15 +209,15 @@ async def test_TC_OCC_3_2(self): self.step("6b") if attributes.UltrasonicOccupiedToUnoccupiedDelay.attribute_id in attribute_list: initial_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) - + else: logging.info("No UltrasonicOccupiedToUnoccupiedDelay attribute supports. Skip this test case") - + self.step("6c") # write the new attribute value diff_val = 14 await ChipDeviceCtrl.WriteAttribute(node_id, [(endpoint, attributes.UltrasonicOccupiedToUnoccupiedDelay(diff_val))]) - + self.step("6d") self._await_sequence_of_reports(report_queue=attrib_listener.attribute_queue, endpoint_id=endpoint_id, attribute=cluster.Attributes.UltrasonicOccupiedToUnoccupiedDelay, sequence=[ initial_dut, diff_val], timeout_sec=post_prompt_settle_delay_seconds) From 1215ecb85a65aa6d44c26e8c2107407085bc3b5b Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 1 Aug 2024 13:15:10 -0400 Subject: [PATCH 81/86] Typo fixes and enable some tests in CI --- .github/workflows/tests.yaml | 1 + src/python_testing/TC_OCC_2_1.py | 12 ++++++++++++ src/python_testing/TC_OCC_2_2.py | 22 ++++++++++++++++++---- src/python_testing/TC_OCC_2_3.py | 12 ++++++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5e38c6c341bea6..f87b5a96dda9c9 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -571,6 +571,7 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TestEventTrigger.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TestBatchInvoke.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TestGroupTableReports.py' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OCC_2_2.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPCREDS_3_1.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPCREDS_3_2.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPSTATE_2_1.py' diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 99331090793ed5..adb5771257959d 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -19,6 +19,18 @@ # [TC-OCC-3.1] test procedure step 4 # [TC-OCC-3.2] test precedure step 3a, 3c +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${ALL_CLUSTERS_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + import logging import chip.clusters as Clusters diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 33287b92964f6d..44989fa6faf02a 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -15,6 +15,18 @@ # limitations under the License. # +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${ALL_CLUSTERS_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + from dataclasses import dataclass import chip.clusters as Clusters @@ -85,17 +97,19 @@ async def test_TC_OCC_2_2(self): (N, Y, Y): TypeEnum.kUltrasonic, (Y, Y, Y): TypeEnum.kPIRAndUltrasonic, } + + FeatureBit = Clusters.OccupancySensing.Bitmaps.Feature expected = mappings.get( ( - (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPassiveInfrared) != 0, - (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kUltrasonic) != 0, - (feature_map & Clusters.OccupancySensing.Bitmaps.Feature.kPhysicalContact) != 0 + (feature_map & FeatureBit.kPassiveInfrared) != 0, + (feature_map & FeatureBit.kUltrasonic) != 0, + (feature_map & FeatureBit.kPhysicalContact) != 0 )) asserts.assert_equal( occupancy_sensor_type_dut, expected, - f"Sensort Type should be f{expected}" + f"Sensor Type should be f{expected}" ) self.step(3) diff --git a/src/python_testing/TC_OCC_2_3.py b/src/python_testing/TC_OCC_2_3.py index 45c947186974bf..0e1223f896ffc3 100644 --- a/src/python_testing/TC_OCC_2_3.py +++ b/src/python_testing/TC_OCC_2_3.py @@ -15,6 +15,18 @@ # limitations under the License. # +# See https://github.com/project-chip/connectedhomeip/blob/master/docs/testing/python.md#defining-the-ci-test-arguments +# for details about the block below. +# +# === BEGIN CI TEST ARGUMENTS === +# test-runner-runs: run1 +# test-runner-run/run1/app: ${ALL_CLUSTERS_APP} +# test-runner-run/run1/factoryreset: True +# test-runner-run/run1/quiet: True +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json +# test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto +# === END CI TEST ARGUMENTS === + import logging import chip.clusters as Clusters From 506d08e4fc994023040bbe31d0ba3669c03cabb9 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 1 Aug 2024 13:35:21 -0400 Subject: [PATCH 82/86] Fix OCC_2_1 to run in CI --- src/python_testing/TC_OCC_2_1.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index adb5771257959d..77e044b5e68a12 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -93,7 +93,7 @@ async def test_TC_OCC_2_1(self): occupancy_sensor_type_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.OccupancySensorType) asserts.assert_less(occupancy_sensor_type_dut, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUnknownEnumValue, "OccupancySensorType is not in valid range") - asserts.assert_in(occupancy_sensor_type_dut, {Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIR, + asserts.assert_in(occupancy_sensor_type_dut, {Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic, Clusters.Objects.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact}, "OccupancySensorType is not in valid range") @@ -109,16 +109,16 @@ async def test_TC_OCC_2_1(self): if attributes.HoldTimeLimits.attribute_id in attribute_list: asserts.assert_in(attributes.HoldTime.attribute_id, attribute_list, "HoldTime attribute conformance failed.") hold_time_limits_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTimeLimits) - asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMin, hold_time_limits_dut.HoldTimeMax, + asserts.assert_less_equal(hold_time_limits_dut.holdTimeMin, hold_time_limits_dut.holdTimeMax, "HoldTimeMin is not in valid range") - asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMin, 0, "HoldTimeMin is not in valid range") - asserts.assert_less_equal(hold_time_limits_dut.HoldTimeMax, 0xFFFE, "HoldTimeMin is not in valid range") - asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeMax, - hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") - asserts.assert_less_equal(hold_time_limits_dut.HoldTimeDefault, - hold_time_limits_dut.HoldTimeMax, "HoldTimeMin is not in valid range") - asserts.assert_greater_equal(hold_time_limits_dut.HoldTimeDefault, - hold_time_limits_dut.HoldTimeMin, "HoldTimeMin is not in valid range") + asserts.assert_greater_equal(hold_time_limits_dut.holdTimeMin, 0, "HoldTimeMin is not in valid range") + asserts.assert_less_equal(hold_time_limits_dut.holdTimeMax, 0xFFFE, "HoldTimeMin is not in valid range") + asserts.assert_greater_equal(hold_time_limits_dut.holdTimeMax, + hold_time_limits_dut.holdTimeMin, "HoldTimeMin is not in valid range") + asserts.assert_less_equal(hold_time_limits_dut.holdTimeDefault, + hold_time_limits_dut.holdTimeMax, "HoldTimeMin is not in valid range") + asserts.assert_greater_equal(hold_time_limits_dut.holdTimeDefault, + hold_time_limits_dut.holdTimeMin, "HoldTimeMin is not in valid range") else: logging.info("HoldTimeLimits not supported. Test step skipped") self.mark_current_step_skipped() @@ -128,8 +128,8 @@ async def test_TC_OCC_2_1(self): hold_time_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTime) hold_time_limits_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.HoldTimeLimits) - asserts.assert_less_equal(hold_time_dut, hold_time_limits_dut.HoldTimeMax, "HoldTime attribute is out of range") - asserts.assert_greater_equal(hold_time_dut, hold_time_limits_dut.HoldTimeMin, "HoldTime attribute is out of range") + asserts.assert_less_equal(hold_time_dut, hold_time_limits_dut.holdTimeMax, "HoldTime attribute is out of range") + asserts.assert_greater_equal(hold_time_dut, hold_time_limits_dut.holdTimeMin, "HoldTime attribute is out of range") else: logging.info("HoldTime not supported. The rest of legacy attribute test can be skipped") self.skip_all_remaining_steps(7) From 2a1f0f0f3439904fe6e85af2d4a19eddc6492915 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 1 Aug 2024 14:11:55 -0400 Subject: [PATCH 83/86] Fix all clusters for TC_OCC_2_2 and some logging --- .../src/occupancy-sensing-stub.cpp | 2 +- src/python_testing/TC_OCC_2_2.py | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp index dcbb90ff659bcb..776e108911aaef 100644 --- a/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/occupancy-sensing-stub.cpp @@ -36,7 +36,7 @@ void emberAfOccupancySensingClusterInitCallback(EndpointId endpointId) VerifyOrDie(!gAttrAccess[endpointId]); gAttrAccess[endpointId] = std::make_unique( - BitMask(OccupancySensing::Feature::kOther)); + BitMask(OccupancySensing::Feature::kPassiveInfrared)); OccupancySensing::Structs::HoldTimeLimitsStruct::Type holdTimeLimits = { .holdTimeMin = 1, diff --git a/src/python_testing/TC_OCC_2_2.py b/src/python_testing/TC_OCC_2_2.py index 44989fa6faf02a..e27bbf30ebcade 100644 --- a/src/python_testing/TC_OCC_2_2.py +++ b/src/python_testing/TC_OCC_2_2.py @@ -27,20 +27,11 @@ # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === -from dataclasses import dataclass - import chip.clusters as Clusters from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from mobly import asserts -@dataclass -class FeatureMapping: - """Maps feature flags to a specific bitmap and sensor type""" - feature_map: int - sensor_type: Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum - - class TC_OCC_2_2(MatterBaseTest): async def read_occ_attribute_expect_success(self, endpoint, attribute): cluster = Clusters.Objects.OccupancySensing @@ -133,7 +124,7 @@ async def test_TC_OCC_2_2(self): asserts.assert_equal( (occupancy_sensor_type_bitmap_dut & sensor_bit) != 0, (feature_map & feature_bit) != 0, - f"Feature bit and sensor bitmap must be equal for {name}" + f"Feature bit and sensor bitmap must be equal for {name} (BITMAP: 0x{occupancy_sensor_type_bitmap_dut:02X}, FEATUREMAP: 0x{feature_map:02X})" ) From 338d2f9853e9dc5edbd7b63902e873699c4ffaf4 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 1 Aug 2024 14:28:01 -0400 Subject: [PATCH 84/86] make all TC_OCC_2_* pass --- .../all-clusters-app.matter | 10 +++-- .../all-clusters-common/all-clusters-app.zap | 44 ++++++++++++++++--- src/python_testing/TC_OCC_2_1.py | 10 ++--- src/python_testing/TC_OCC_2_3.py | 15 ++++++- 4 files changed, 63 insertions(+), 16 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index f69ed20583379c..eb172fa54dcff9 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -9025,10 +9025,11 @@ endpoint 1 { server cluster OccupancySensing { ram attribute occupancy; ram attribute occupancySensorType; - ram attribute occupancySensorTypeBitmap; + ram attribute occupancySensorTypeBitmap default = 1; ram attribute holdTime default = 10; callback attribute holdTimeLimits; - ram attribute featureMap default = 0x01; + ram attribute PIROccupiedToUnoccupiedDelay default = 10; + ram attribute featureMap default = 0x02; ram attribute clusterRevision default = 5; } @@ -9502,10 +9503,11 @@ endpoint 2 { server cluster OccupancySensing { ram attribute occupancy; ram attribute occupancySensorType; - ram attribute occupancySensorTypeBitmap; + ram attribute occupancySensorTypeBitmap default = 1; ram attribute holdTime default = 20; callback attribute holdTimeLimits; - ram attribute featureMap default = 0x01; + ram attribute PIROccupiedToUnoccupiedDelay default = 10; + ram attribute featureMap default = 0x02; ram attribute clusterRevision default = 5; } } diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 7b3ccf977dbc2b..cde6889cd93f19 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -16678,7 +16678,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -16726,7 +16726,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -19103,7 +19103,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -19141,6 +19141,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "PIROccupiedToUnoccupiedDelay", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "10", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, @@ -19151,7 +19167,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x01", + "defaultValue": "0x02", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -25244,7 +25260,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -25282,6 +25298,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "PIROccupiedToUnoccupiedDelay", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "10", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, @@ -25292,7 +25324,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x01", + "defaultValue": "0x02", "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index 77e044b5e68a12..bf14d7fb3b2c75 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -138,18 +138,18 @@ async def test_TC_OCC_2_1(self): self.step(7) if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: has_pir_bitmap = (occupancy_sensor_type_bitmap_dut & - Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir) == 1 + Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir) != 0 has_ultrasonic_bitmap = (occupancy_sensor_type_bitmap_dut & - Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic) == 1 + Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic) != 0 has_phy_bitmap = (occupancy_sensor_type_bitmap_dut & - Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact) == 1 - if (has_pir_bitmap == 1) or ((has_pir_bitmap == 0) & (has_ultrasonic_bitmap == 0) & (has_phy_bitmap == 0)): + Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact) != 0 + if has_pir_bitmap or (not has_ultrasonic_bitmap and not has_phy_bitmap): pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") else: logging.info("PIROccupiedToUnoccupiedDelay conformance failed") - asserts.fail("PIROccupiedToUnoccupiedDelay conformance is incorrect") + asserts.fail(f"PIROccupiedToUnoccupiedDelay conformance is incorrect: {has_pir_bitmap}, {has_ultrasonic_bitmap}, {has_phy_bitmap}") else: logging.info("PIROccupiedToUnoccupiedDelay not supported. Test step skipped") self.mark_current_step_skipped() diff --git a/src/python_testing/TC_OCC_2_3.py b/src/python_testing/TC_OCC_2_3.py index 0e1223f896ffc3..2c77e0418d9eab 100644 --- a/src/python_testing/TC_OCC_2_3.py +++ b/src/python_testing/TC_OCC_2_3.py @@ -83,18 +83,27 @@ async def test_TC_OCC_2_3(self): else: logging.info("OccupancySensorType attribute doesn't exist. Test step skipped") - self.step(4) if occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPir: + self.step(4) occupancy_pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) asserts.assert_equal(occupancy_pir_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") + self.skip_step(5) + self.skip_step(6) elif occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kUltrasonic: + self.step(4) + occupancy_pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) + + asserts.assert_equal(occupancy_pir_otou_delay_dut, occupancy_hold_time_dut, + "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") + self.step(5) occupancy_us_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.UltrasonicOccupiedToUnoccupiedDelay) asserts.assert_equal(occupancy_us_otou_delay_dut, occupancy_hold_time_dut, "HoldTime attribute value is not equal to UltrasonicOccupiedToUnoccupiedDelay") + self.skip_step(6) elif occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPIRAndUltrasonic: occupancy_pirus_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) @@ -103,6 +112,9 @@ async def test_TC_OCC_2_3(self): "HoldTime attribute value is not equal to PIROccupiedToUnoccupiedDelay") elif occupancy_sensor_type_dut == Clusters.OccupancySensing.Enums.OccupancySensorTypeEnum.kPhysicalContact: + self.skip_step(4) + self.skip_step(5) + self.step(6) occupancy_phy_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PhysicalContactOccupiedToUnoccupiedDelay) asserts.assert_equal(occupancy_phy_otou_delay_dut, occupancy_hold_time_dut, @@ -111,5 +123,6 @@ async def test_TC_OCC_2_3(self): logging.info("OccupancySensorType attribute value is out of range") + if __name__ == "__main__": default_matter_test_main() From 44664635b9bdb0e341443d38cd0959823216de2d Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 1 Aug 2024 14:28:37 -0400 Subject: [PATCH 85/86] Restyle --- src/python_testing/TC_OCC_2_1.py | 7 ++++--- src/python_testing/TC_OCC_2_3.py | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/python_testing/TC_OCC_2_1.py b/src/python_testing/TC_OCC_2_1.py index bf14d7fb3b2c75..cf39a7eff5a111 100644 --- a/src/python_testing/TC_OCC_2_1.py +++ b/src/python_testing/TC_OCC_2_1.py @@ -138,18 +138,19 @@ async def test_TC_OCC_2_1(self): self.step(7) if attributes.PIROccupiedToUnoccupiedDelay.attribute_id in attribute_list: has_pir_bitmap = (occupancy_sensor_type_bitmap_dut & - Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir) != 0 + Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPir) != 0 has_ultrasonic_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kUltrasonic) != 0 has_phy_bitmap = (occupancy_sensor_type_bitmap_dut & Clusters.OccupancySensing.Bitmaps.OccupancySensorTypeBitmap.kPhysicalContact) != 0 - if has_pir_bitmap or (not has_ultrasonic_bitmap and not has_phy_bitmap): + if has_pir_bitmap or (not has_ultrasonic_bitmap and not has_phy_bitmap): pir_otou_delay_dut = await self.read_occ_attribute_expect_success(endpoint=endpoint, attribute=attributes.PIROccupiedToUnoccupiedDelay) asserts.assert_less_equal(pir_otou_delay_dut, 0xFFFE, "PIROccupiedToUnoccupiedDelay is not in valid range") asserts.assert_greater_equal(pir_otou_delay_dut, 0, "PIROccupiedToUnoccupiedDelay is not in valid range") else: logging.info("PIROccupiedToUnoccupiedDelay conformance failed") - asserts.fail(f"PIROccupiedToUnoccupiedDelay conformance is incorrect: {has_pir_bitmap}, {has_ultrasonic_bitmap}, {has_phy_bitmap}") + asserts.fail( + f"PIROccupiedToUnoccupiedDelay conformance is incorrect: {has_pir_bitmap}, {has_ultrasonic_bitmap}, {has_phy_bitmap}") else: logging.info("PIROccupiedToUnoccupiedDelay not supported. Test step skipped") self.mark_current_step_skipped() diff --git a/src/python_testing/TC_OCC_2_3.py b/src/python_testing/TC_OCC_2_3.py index 2c77e0418d9eab..0184b670c6b306 100644 --- a/src/python_testing/TC_OCC_2_3.py +++ b/src/python_testing/TC_OCC_2_3.py @@ -123,6 +123,5 @@ async def test_TC_OCC_2_3(self): logging.info("OccupancySensorType attribute value is out of range") - if __name__ == "__main__": default_matter_test_main() From f73346831059ba3c9647b36f15da2acf9c3088f3 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 1 Aug 2024 14:30:18 -0400 Subject: [PATCH 86/86] Enable tests in ci --- .github/workflows/tests.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index f87b5a96dda9c9..c19eccb9a30457 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -571,7 +571,9 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_TestEventTrigger.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TestBatchInvoke.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TestGroupTableReports.py' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OCC_2_1.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OCC_2_2.py' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OCC_2_3.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPCREDS_3_1.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPCREDS_3_2.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_OPSTATE_2_1.py'