diff --git a/src/python_testing/TC_DEMTestBase.py b/src/python_testing/TC_DEMTestBase.py index db53c36f8cd1c9..dedeac95b8f595 100644 --- a/src/python_testing/TC_DEMTestBase.py +++ b/src/python_testing/TC_DEMTestBase.py @@ -24,6 +24,14 @@ logger = logging.getLogger(__name__) +s_feature_strs = {Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerAdjustment: "kPowerAdjustment", + Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting: "kPowerForecastReporting", + Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting: "kStateForecastReporting", + Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStartTimeAdjustment: "kStartTimeAdjustment", + Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPausable: "kPausable", + Clusters.DeviceEnergyManagement.Bitmaps.Feature.kForecastAdjustment: "kForecastAdjustment", + Clusters.DeviceEnergyManagement.Bitmaps.Feature.kConstraintBasedAdjustment: "kConstraintBasedAdjustment"} + class DEMTestBase: @@ -38,6 +46,26 @@ async def check_dem_attribute(self, attribute, expected_value, endpoint: int = N asserts.assert_equal(value, expected_value, f"Unexpected '{attribute}' value - expected {expected_value}, was {value}") + async def validate_feature_map(self, must_have_features, must_not_have_features): + feature_map = await self.read_dem_attribute_expect_success(attribute="FeatureMap") + for must_have_feature in must_have_features: + asserts.assert_true(feature_map & must_have_feature, + f"{s_feature_strs[must_have_feature]} must be set but is not. feature_map 0x{feature_map:x}") + + for must_not_have_feature in must_not_have_features: + asserts.assert_false(feature_map & must_not_have_feature, + f"{s_feature_strs[must_not_have_feature]} is not allowed to be set. feature_map 0x{feature_map:x}") + + async def validate_pfr_or_sfr_in_feature_map(self): + feature_map = await self.read_dem_attribute_expect_success(attribute="FeatureMap") + + illegal_combination = Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting | Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting + asserts.assert_not_equal(feature_map & illegal_combination, illegal_combination, + f"Cannot have kPowerForecastReporting and kStateForecastReporting both set. feature_map 0x{feature_map:x}") + + asserts.assert_not_equal(feature_map & illegal_combination, 0, + f"Must have one of kPowerForecastReporting and kStateForecastReporting set. feature_map 0x{feature_map:x}") + async def send_power_adjustment_command(self, power: int, duration: int, cause: Clusters.Objects.DeviceEnergyManagement.Enums.CauseEnum, endpoint: int = None, timedRequestTimeoutMs: int = 3000, diff --git a/src/python_testing/TC_DEM_2_2.py b/src/python_testing/TC_DEM_2_2.py index 0c32992d934174..710e8552fe6b8e 100644 --- a/src/python_testing/TC_DEM_2_2.py +++ b/src/python_testing/TC_DEM_2_2.py @@ -155,6 +155,8 @@ async def test_TC_DEM_2_2(self): self.step("1") # Commission DUT - already done + await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerAdjustment], []) + # Subscribe to Events and when they are sent push them to a queue for checking later events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) await events_callback.start(self.default_controller, diff --git a/src/python_testing/TC_DEM_2_3.py b/src/python_testing/TC_DEM_2_3.py index 6bdd81c710a914..c44271bd3b5d41 100644 --- a/src/python_testing/TC_DEM_2_3.py +++ b/src/python_testing/TC_DEM_2_3.py @@ -22,7 +22,7 @@ # test-runner-run/run1/app: ${ENERGY_MANAGEMENT_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 --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x7a +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0xa # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === @@ -138,6 +138,9 @@ async def test_TC_DEM_2_3(self): self.step("1") # Commission DUT - already done + await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStartTimeAdjustment], []) + await self.validate_pfr_or_sfr_in_feature_map() + # Subscribe to Events and when they are sent push them to a queue for checking later events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) await events_callback.start(self.default_controller, diff --git a/src/python_testing/TC_DEM_2_4.py b/src/python_testing/TC_DEM_2_4.py index 390889fc9f2d28..2528b646014d65 100644 --- a/src/python_testing/TC_DEM_2_4.py +++ b/src/python_testing/TC_DEM_2_4.py @@ -22,7 +22,7 @@ # test-runner-run/run1/app: ${ENERGY_MANAGEMENT_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 --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x7a +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x12 # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === @@ -159,6 +159,9 @@ async def test_TC_DEM_2_4(self): self.step("1") # Commission DUT - already done + await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPausable], []) + await self.validate_pfr_or_sfr_in_feature_map() + # Subscribe to Events and when they are sent push them to a queue for checking later events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) await events_callback.start(self.default_controller, diff --git a/src/python_testing/TC_DEM_2_5.py b/src/python_testing/TC_DEM_2_5.py index 85d3cd779b22f4..d7ab0521e678ab 100644 --- a/src/python_testing/TC_DEM_2_5.py +++ b/src/python_testing/TC_DEM_2_5.py @@ -23,7 +23,7 @@ # test-runner-run/run1/app: ${ENERGY_MANAGEMENT_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 --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x7a +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x22 # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === @@ -144,6 +144,10 @@ async def test_TC_DEM_2_5(self): self.step("1") # Commission DUT - already done + await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kForecastAdjustment, + Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting], + []) + # Subscribe to Events and when they are sent push them to a queue for checking later events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) await events_callback.start(self.default_controller, diff --git a/src/python_testing/TC_DEM_2_6.py b/src/python_testing/TC_DEM_2_6.py index 7390436effd937..2bc52e6b6f1cb9 100644 --- a/src/python_testing/TC_DEM_2_6.py +++ b/src/python_testing/TC_DEM_2_6.py @@ -140,6 +140,10 @@ async def test_TC_DEM_2_6(self): self.step("1") # Commission DUT - already done + await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kForecastAdjustment, + Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting], + [Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting]) + # Subscribe to Events and when they are sent push them to a queue for checking later events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) await events_callback.start(self.default_controller, diff --git a/src/python_testing/TC_DEM_2_7.py b/src/python_testing/TC_DEM_2_7.py index fa7dba14a53315..16b974d3ff58f6 100644 --- a/src/python_testing/TC_DEM_2_7.py +++ b/src/python_testing/TC_DEM_2_7.py @@ -148,6 +148,10 @@ async def test_TC_DEM_2_7(self): self.step("1") # Commission DUT - already done + await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kConstraintBasedAdjustment, + Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting], + [Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting]) + # Subscribe to Events and when they are sent push them to a queue for checking later events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) await events_callback.start(self.default_controller, diff --git a/src/python_testing/TC_DEM_2_8.py b/src/python_testing/TC_DEM_2_8.py index 773648c7e3ba8e..1c081be96e63f3 100644 --- a/src/python_testing/TC_DEM_2_8.py +++ b/src/python_testing/TC_DEM_2_8.py @@ -140,6 +140,10 @@ async def test_TC_DEM_2_8(self): self.step("1") # Commission DUT - already done + await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kConstraintBasedAdjustment, + Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting], + [Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting]) + # Subscribe to Events and when they are sent push them to a queue for checking later events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) await events_callback.start(self.default_controller, diff --git a/src/python_testing/TC_DEM_2_9.py b/src/python_testing/TC_DEM_2_9.py index 8e60b69b481d93..5f033164cfad61 100644 --- a/src/python_testing/TC_DEM_2_9.py +++ b/src/python_testing/TC_DEM_2_9.py @@ -23,7 +23,7 @@ # test-runner-run/run1/app: ${ENERGY_MANAGEMENT_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 --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x7e +# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x7c # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --endpoint 1 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto # === END CI TEST ARGUMENTS === @@ -81,6 +81,8 @@ async def test_TC_DEM_2_9(self): self.step("1") # Commission DUT - already done + await self.validate_pfr_or_sfr_in_feature_map() + # Subscribe to Events and when they are sent push them to a queue for checking later events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement) await events_callback.start(self.default_controller,