Skip to content

Commit a71bb17

Browse files
committed
Add checks for correct DEM feature map for test
1 parent f9ad5bf commit a71bb17

9 files changed

+58
-4
lines changed

src/python_testing/TC_DEMTestBase.py

+28
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424

2525
logger = logging.getLogger(__name__)
2626

27+
s_feature_strs = {Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerAdjustment: "kPowerAdjustment",
28+
Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting: "kPowerForecastReporting",
29+
Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting: "kStateForecastReporting",
30+
Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStartTimeAdjustment: "kStartTimeAdjustment",
31+
Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPausable: "kPausable",
32+
Clusters.DeviceEnergyManagement.Bitmaps.Feature.kForecastAdjustment: "kForecastAdjustment",
33+
Clusters.DeviceEnergyManagement.Bitmaps.Feature.kConstraintBasedAdjustment: "kConstraintBasedAdjustment"}
34+
2735

2836
class DEMTestBase:
2937

@@ -38,6 +46,26 @@ async def check_dem_attribute(self, attribute, expected_value, endpoint: int = N
3846
asserts.assert_equal(value, expected_value,
3947
f"Unexpected '{attribute}' value - expected {expected_value}, was {value}")
4048

49+
async def validate_feature_map(self, must_have_features, must_not_have_features):
50+
feature_map = await self.read_dem_attribute_expect_success(attribute="FeatureMap")
51+
for must_have_feature in must_have_features:
52+
asserts.assert_true(feature_map & must_have_feature,
53+
f"{s_feature_strs[must_have_feature]} must be set but is not. feature_map 0x{feature_map:x}")
54+
55+
for must_not_have_feature in must_not_have_features:
56+
asserts.assert_false(feature_map & must_not_have_feature,
57+
f"{s_feature_strs[must_not_have_feature]} is not allowed to be set. feature_map 0x{feature_map:x}")
58+
59+
async def validate_pfr_or_sfr_in_feature_map(self):
60+
feature_map = await self.read_dem_attribute_expect_success(attribute="FeatureMap")
61+
62+
illegal_combination = Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting | Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting
63+
asserts.assert_not_equal(feature_map & illegal_combination, illegal_combination,
64+
f"Cannot have kPowerForecastReporting and kStateForecastReporting both set. feature_map 0x{feature_map:x}")
65+
66+
asserts.assert_not_equal(feature_map & illegal_combination, 0,
67+
f"Must have one of kPowerForecastReporting and kStateForecastReporting set. feature_map 0x{feature_map:x}")
68+
4169
async def send_power_adjustment_command(self, power: int, duration: int,
4270
cause: Clusters.Objects.DeviceEnergyManagement.Enums.CauseEnum,
4371
endpoint: int = None, timedRequestTimeoutMs: int = 3000,

src/python_testing/TC_DEM_2_2.py

+2
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ async def test_TC_DEM_2_2(self):
155155
self.step("1")
156156
# Commission DUT - already done
157157

158+
await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerAdjustment], [])
159+
158160
# Subscribe to Events and when they are sent push them to a queue for checking later
159161
events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement)
160162
await events_callback.start(self.default_controller,

src/python_testing/TC_DEM_2_3.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# test-runner-run/run1/app: ${ENERGY_MANAGEMENT_APP}
2323
# test-runner-run/run1/factoryreset: True
2424
# test-runner-run/run1/quiet: True
25-
# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x7a
25+
# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0xa
2626
# 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
2727
# === END CI TEST ARGUMENTS ===
2828

@@ -138,6 +138,9 @@ async def test_TC_DEM_2_3(self):
138138
self.step("1")
139139
# Commission DUT - already done
140140

141+
await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStartTimeAdjustment], [])
142+
await self.validate_pfr_or_sfr_in_feature_map()
143+
141144
# Subscribe to Events and when they are sent push them to a queue for checking later
142145
events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement)
143146
await events_callback.start(self.default_controller,

src/python_testing/TC_DEM_2_4.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# test-runner-run/run1/app: ${ENERGY_MANAGEMENT_APP}
2323
# test-runner-run/run1/factoryreset: True
2424
# test-runner-run/run1/quiet: True
25-
# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x7a
25+
# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x12
2626
# 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
2727
# === END CI TEST ARGUMENTS ===
2828

@@ -159,6 +159,9 @@ async def test_TC_DEM_2_4(self):
159159
self.step("1")
160160
# Commission DUT - already done
161161

162+
await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPausable], [])
163+
await self.validate_pfr_or_sfr_in_feature_map()
164+
162165
# Subscribe to Events and when they are sent push them to a queue for checking later
163166
events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement)
164167
await events_callback.start(self.default_controller,

src/python_testing/TC_DEM_2_5.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# test-runner-run/run1/app: ${ENERGY_MANAGEMENT_APP}
2424
# test-runner-run/run1/factoryreset: True
2525
# test-runner-run/run1/quiet: True
26-
# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x7a
26+
# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x22
2727
# 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
2828
# === END CI TEST ARGUMENTS ===
2929

@@ -144,6 +144,10 @@ async def test_TC_DEM_2_5(self):
144144
self.step("1")
145145
# Commission DUT - already done
146146

147+
await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kForecastAdjustment,
148+
Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting],
149+
[])
150+
147151
# Subscribe to Events and when they are sent push them to a queue for checking later
148152
events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement)
149153
await events_callback.start(self.default_controller,

src/python_testing/TC_DEM_2_6.py

+4
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ async def test_TC_DEM_2_6(self):
140140
self.step("1")
141141
# Commission DUT - already done
142142

143+
await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kForecastAdjustment,
144+
Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting],
145+
[Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting])
146+
143147
# Subscribe to Events and when they are sent push them to a queue for checking later
144148
events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement)
145149
await events_callback.start(self.default_controller,

src/python_testing/TC_DEM_2_7.py

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ async def test_TC_DEM_2_7(self):
148148
self.step("1")
149149
# Commission DUT - already done
150150

151+
await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kConstraintBasedAdjustment,
152+
Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting],
153+
[Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting])
154+
151155
# Subscribe to Events and when they are sent push them to a queue for checking later
152156
events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement)
153157
await events_callback.start(self.default_controller,

src/python_testing/TC_DEM_2_8.py

+4
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ async def test_TC_DEM_2_8(self):
140140
self.step("1")
141141
# Commission DUT - already done
142142

143+
await self.validate_feature_map([Clusters.DeviceEnergyManagement.Bitmaps.Feature.kConstraintBasedAdjustment,
144+
Clusters.DeviceEnergyManagement.Bitmaps.Feature.kStateForecastReporting],
145+
[Clusters.DeviceEnergyManagement.Bitmaps.Feature.kPowerForecastReporting])
146+
143147
# Subscribe to Events and when they are sent push them to a queue for checking later
144148
events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement)
145149
await events_callback.start(self.default_controller,

src/python_testing/TC_DEM_2_9.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# test-runner-run/run1/app: ${ENERGY_MANAGEMENT_APP}
2424
# test-runner-run/run1/factoryreset: True
2525
# test-runner-run/run1/quiet: True
26-
# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x7e
26+
# test-runner-run/run1/app-args: --discriminator 1234 --KVS kvs1 --trace-to json:${TRACE_APP}.json --enable-key 000102030405060708090a0b0c0d0e0f --featureSet 0x7c
2727
# 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
2828
# === END CI TEST ARGUMENTS ===
2929

@@ -81,6 +81,8 @@ async def test_TC_DEM_2_9(self):
8181
self.step("1")
8282
# Commission DUT - already done
8383

84+
await self.validate_pfr_or_sfr_in_feature_map()
85+
8486
# Subscribe to Events and when they are sent push them to a queue for checking later
8587
events_callback = EventChangeCallback(Clusters.DeviceEnergyManagement)
8688
await events_callback.start(self.default_controller,

0 commit comments

Comments
 (0)