Skip to content

Commit acedec1

Browse files
authored
Power Topology: add test scripts (#32114)
* Initial XML for Power Topology cluster * Regen * Restyled really wants newlines at the end of every JSON file * Rename LeafTopology to TreeTopology * [Feature] Power Topology server & all-clusters-app stub * Make endpointId a constructor arg for PowerTopologyDelegate * Change PowerTopologyDelegate to not return std::vectors * Remove unneeded entries in attributeAccessInterfaceAttributes for Power Topology cluster * Typo in python/chip/clusters/__init__.py * Format zcl.json * Add DynamicPowerFlow feature to PowerTopology stub * Add Power Topology to client * Set CI PICS values * Python test script for Power Topology * Linted python script * Add Power Topology python script test * Add PWRTL_1_1 to ciTests.json * Restyled * Regen * Format PICS.yaml
1 parent 2f2c4f1 commit acedec1

File tree

8 files changed

+238
-1
lines changed

8 files changed

+238
-1
lines changed

.github/workflows/tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ jobs:
502502
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_IDM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
503503
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_IDM_1_4.py" --script-args "--hex-arg PIXIT.DGGEN.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
504504
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_IDM_4_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
505+
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_PWRTL_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
505506
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RR_1_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
506507
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCCLEANM_1_2.py" --script-args "--int-arg PIXIT_ENDPOINT:1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
507508
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_RVCRUNM_1_2.py" --script-args "--int-arg PIXIT_ENDPOINT:1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'

src/app/tests/suites/certification/PICS.yaml

+33
Original file line numberDiff line numberDiff line change
@@ -10160,3 +10160,36 @@ PICS:
1016010160

1016110161
- label: "Can the mode change be manually controlled?"
1016210162
id: EEVSEM.S.M.CAN_MANUALLY_CONTROLLED
10163+
10164+
#
10165+
# Power Topology Cluster
10166+
#
10167+
- label: "Does the device implement the Power Topology Cluster as a server?"
10168+
id: PWRTL.S
10169+
10170+
# Features
10171+
10172+
- label:
10173+
"Does the associated endpoint provide or consume power for the entire
10174+
node?"
10175+
id: PWRTL.S.F00
10176+
10177+
- label:
10178+
"Does the associated endpoint provide or consume power for itself and
10179+
its child endpoints?"
10180+
id: PWRTL.S.F01
10181+
10182+
- label:
10183+
"Does the associated endpoint provide or consume power for a provided
10184+
set of endpoints?"
10185+
id: PWRTL.S.F02
10186+
10187+
- label: "Can the provided set of endpoints change?"
10188+
id: PWRTL.S.F03
10189+
10190+
#Server attributes
10191+
- label: "Does the device implement the AvailableEndpoints attribute?"
10192+
id: PWRTL.S.A0000
10193+
10194+
- label: "Does the device implement the ActiveEndpoints attribute?"
10195+
id: PWRTL.S.A0001
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Copyright (c) 2021 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default
15+
16+
name: 44.1.1. [TC-PWRTL-1.1] Global Attributes with DUT as Server
17+
18+
PICS:
19+
- PWRTL.S
20+
21+
config:
22+
nodeId: 0x12344321
23+
cluster: "Power Topology"
24+
endpoint: 1
25+
26+
tests:
27+
- label: "Step 1: Wait for the commissioned device to be retrieved"
28+
cluster: "DelayCommands"
29+
command: "WaitForCommissionee"
30+
arguments:
31+
values:
32+
- name: "nodeId"
33+
value: nodeId
34+
35+
- label: "Step 2: TH reads the ClusterRevision from DUT"
36+
command: "readAttribute"
37+
attribute: "ClusterRevision"
38+
response:
39+
value: 1
40+
constraints:
41+
type: int16u
42+
43+
- label:
44+
"Step 3a: Given PWRTL.S.F00(Node) ensure featuremap has the correct
45+
bit set"
46+
PICS: PWRTL.S.F00
47+
command: "readAttribute"
48+
attribute: "FeatureMap"
49+
response:
50+
constraints:
51+
type: bitmap32
52+
hasMasksSet: [0x1]
53+
hasMasksClear: [0x2, 0x4, 0x8]
54+
55+
- label:
56+
"Step 3b: Given PWRTL.S.F01(Leaf) ensure featuremap has the correct
57+
bit set"
58+
PICS: PWRTL.S.F01
59+
command: "readAttribute"
60+
attribute: "FeatureMap"
61+
response:
62+
constraints:
63+
type: bitmap32
64+
hasMasksSet: [0x2]
65+
hasMasksClear: [0x1, 0x4, 0x8]
66+
67+
- label:
68+
"Step 3c: Given PWRTL.S.F02(Set) ensure featuremap has the correct bit
69+
set"
70+
PICS: PWRTL.S.F02
71+
command: "readAttribute"
72+
attribute: "FeatureMap"
73+
response:
74+
constraints:
75+
type: bitmap32
76+
hasMasksSet: [0x4]
77+
hasMasksClear: [0x1, 0x2]
78+
79+
- label:
80+
"Step 3d: Given PWRTL.S.F03(Dynamic Power Flow) ensure featuremap has
81+
the correct bit set"
82+
PICS: PWRTL.S.F03
83+
command: "readAttribute"
84+
attribute: "FeatureMap"
85+
response:
86+
constraints:
87+
type: bitmap32
88+
hasMasksSet: [0x4, 0x8]
89+
90+
- label: "Step 4a: TH reads AttributeList from DUT"
91+
PICS: "!PICS_SF_SET && !PICS_SF_DYPF"
92+
command: "readAttribute"
93+
attribute: "AttributeList"
94+
response:
95+
constraints:
96+
type: list
97+
contains: []
98+
99+
- label:
100+
"Step 4b: TH reads feature dependent attribute(AvailableEndpoints)
101+
AttributeList from DUT"
102+
PICS: "PICS_SF_SET && !PICS_SF_DYPF"
103+
command: "readAttribute"
104+
attribute: "AttributeList"
105+
response:
106+
constraints:
107+
type: list
108+
contains: [0]
109+
110+
- label:
111+
"Step 4c: TH reads feature dependent attribute(ActiveEndpoints)
112+
AttributeList from DUT"
113+
PICS: "PICS_SF_SET && PICS_SF_DYPF"
114+
command: "readAttribute"
115+
attribute: "AttributeList"
116+
response:
117+
constraints:
118+
type: list
119+
contains: [0, 1]

src/app/tests/suites/certification/ci-pics-values

+12
Original file line numberDiff line numberDiff line change
@@ -2939,3 +2939,15 @@ DEMM.S.C01.Tx=1
29392939
#Manual controllable
29402940
DEMM.S.M.CAN_TEST_MODE_FAILURE=1
29412941
DEMM.S.M.CAN_MANUALLY_CONTROLLED=1
2942+
2943+
#Power Topology Cluster
2944+
# Server
2945+
PWRTL.S=1
2946+
PWRTL.S.A0000=1
2947+
PWRTL.S.A0001=1
2948+
2949+
#Features
2950+
PWRTL.S.F00=0
2951+
PWRTL.S.F01=0
2952+
PWRTL.S.F02=1
2953+
PWRTL.S.F03=1

src/app/tests/suites/ciTests.json

+1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@
191191
"Test_TC_OO_2_4"
192192
],
193193
"PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"],
194+
"PowerTopology": ["Test_TC_PWRTL_1_1"],
194195
"PressureMeasurement": [
195196
"Test_TC_PRS_1_1",
196197
"Test_TC_PRS_2_1",

src/app/tests/suites/manualTests.json

+2
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@
311311
"AccessControlEnforcement": [],
312312
"OvenMode": ["Test_TC_OTCCM_1_1", "Test_TC_OTCCM_1_2"],
313313
"EnergyEVSE": ["Test_TC_EEVSE_1_1", "Test_TC_EEVSE_2_1"],
314+
"PowerTopology": ["Test_TC_PWRTL_1_1"],
314315
"collection": [
315316
"DeviceDiscovery",
316317
"Groups",
@@ -338,6 +339,7 @@
338339
"ModeSelect",
339340
"OTASoftwareUpdate",
340341
"PowerSourceConfiguration",
342+
"PowerTopology",
341343
"PressureMeasurement",
342344
"SecureChannel",
343345
"SoftwareDiagnostics",

src/app/zap_cluster_list.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
"MESSAGES_CLUSTER": [],
6969
"MODE_SELECT_CLUSTER": [],
7070
"NETWORK_COMMISSIONING_CLUSTER": [],
71-
"POWER_TOPOLOGY_CLUSTER": [],
7271
"SAMPLE_MEI_CLUSTER": [],
7372
"NITROGEN_DIOXIDE_CONCENTRATION_MEASUREMENT_CLUSTER": [],
7473
"OCCUPANCY_SENSING_CLUSTER": ["occupancy-sensor-server"],
@@ -91,6 +90,7 @@
9190
"POWER_PROFILE_CLUSTER": [],
9291
"POWER_SOURCE_CLUSTER": [],
9392
"POWER_SOURCE_CONFIGURATION_CLUSTER": [],
93+
"POWER_TOPOLOGY_CLUSTER": [],
9494
"PRESSURE_MEASUREMENT_CLUSTER": [],
9595
"PROXY_CONFIGURATION_CLUSTER": [],
9696
"PROXY_DISCOVERY_CLUSTER": [],

src/python_testing/TC_PWRTL_2_1.py

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#
2+
# Copyright (c) 2024 Project CHIP Authors
3+
# All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
import logging
19+
20+
import chip.clusters as Clusters
21+
from chip.clusters.Types import NullValue
22+
from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main
23+
from mobly import asserts
24+
25+
26+
class TC_PWRTL_2_1(MatterBaseTest):
27+
28+
def pics_TC_PWRTL_2_1(self) -> list[str]:
29+
return ["PWRTL.S"]
30+
31+
@async_test_body
32+
async def test_TC_PWRTL_2_1(self):
33+
34+
attributes = Clusters.PowerTopology.Attributes
35+
36+
endpoint = self.user_params.get("endpoint", 1)
37+
38+
self.print_step(1, "Commissioning, already done")
39+
40+
if not self.check_pics("PWRTL.S.A0000"):
41+
logging.info("Test skipped because PICS PWRTL.S.A0000 is not set")
42+
return
43+
44+
self.print_step(2, "Read AvailableAttributes attribute")
45+
available_endpoints = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=Clusters.Objects.PowerTopology, attribute=attributes.AvailableEndpoints)
46+
47+
if available_endpoints == NullValue:
48+
logging.info("AvailableEndpoints is null")
49+
else:
50+
logging.info("AvailableEndpoints: %s" % (available_endpoints))
51+
52+
asserts.assert_less_equal(len(available_endpoints), 21,
53+
"AvailableEndpoints length %d must be less than 21!" % len(available_endpoints))
54+
55+
if not self.check_pics("PWRTL.S.A0001"):
56+
logging.info("Test skipped because PICS PWRTL.S.A0001 is not set")
57+
return
58+
59+
self.print_step(3, "Read ActiveEndpoints attribute")
60+
active_endpoints = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=Clusters.Objects.PowerTopology, attribute=attributes.ActiveEndpoints)
61+
logging.info("ActiveEndpoints: %s" % (active_endpoints))
62+
63+
if available_endpoints == NullValue:
64+
asserts.assert_true(active_endpoints == NullValue,
65+
"ActiveEndpoints should be null when AvailableEndpoints is null: %s" % active_endpoints)
66+
67+
68+
if __name__ == "__main__":
69+
default_matter_test_main()

0 commit comments

Comments
 (0)