Skip to content

Commit 8f1cff8

Browse files
authored
Merge branch 'master' into feature/fix-cluster-revisions
2 parents 7a4f5ff + fea1604 commit 8f1cff8

File tree

3 files changed

+315
-7
lines changed

3 files changed

+315
-7
lines changed

src/python_testing/TestMatterTestingSupport.py

+38-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# limitations under the License.
1616
#
1717

18+
import os
1819
import time
1920
import typing
2021
from datetime import datetime, timedelta, timezone
@@ -23,7 +24,8 @@
2324
from chip.clusters.Types import Nullable, NullValue
2425
from chip.tlv import uint
2526
from matter_testing_support import (MatterBaseTest, async_test_body, compare_time, default_matter_test_main,
26-
get_wait_seconds_from_set_time, parse_pics, type_matches, utc_time_in_matter_epoch)
27+
get_wait_seconds_from_set_time, parse_pics, parse_pics_xml, type_matches,
28+
utc_time_in_matter_epoch)
2729
from mobly import asserts, signals
2830
from taglist_and_topology_test_support import (TagProblem, create_device_type_list_for_root, create_device_type_lists,
2931
find_tag_list_problems, find_tree_roots, get_all_children,
@@ -584,6 +586,41 @@ def test_root_node_tag_list_functions(self):
584586
problems = find_tag_list_problems(roots=[0], device_types={0: device_type_list}, endpoint_dict=endpoints)
585587
asserts.assert_equal(len(problems.keys()), 0, 'Unexpected problems found in root endpoint')
586588

589+
def pics_assert(self, pics: str, support: bool):
590+
asserts.assert_equal(self.check_pics(pics), support,
591+
f'Unexpected PICS value for {pics} - expected {support}, got {self.check_pics(pics)}')
592+
593+
def test_xml_pics(self):
594+
script_dir = os.path.dirname(os.path.realpath(__file__))
595+
with open(f'{script_dir}/test_testing/example_pics_xml_basic_info.xml') as f:
596+
pics = parse_pics_xml(f.read())
597+
print(pics)
598+
# force the parsed pics here to be in the config so we can check the check_pics function
599+
self.matter_test_config.pics = pics
600+
self.pics_assert('BINFO.S', True)
601+
self.pics_assert('BINFO.S.A0000', True)
602+
self.pics_assert('BINFO.S.A0001', True)
603+
self.pics_assert('BINFO.S.A0002', True)
604+
self.pics_assert('BINFO.S.A0003', True)
605+
self.pics_assert('BINFO.S.A0004', True)
606+
self.pics_assert('BINFO.S.A0005', True)
607+
self.pics_assert('BINFO.S.A0006', True)
608+
self.pics_assert('BINFO.S.A0007', True)
609+
self.pics_assert('BINFO.S.A0008', True)
610+
self.pics_assert('BINFO.S.A0009', True)
611+
self.pics_assert('BINFO.S.A000a', True)
612+
self.pics_assert('BINFO.S.A000b', True)
613+
self.pics_assert('BINFO.S.A000c', True)
614+
self.pics_assert('BINFO.S.A000d', True)
615+
self.pics_assert('BINFO.S.A000e', True)
616+
self.pics_assert('BINFO.S.A000f', True)
617+
self.pics_assert('BINFO.S.A0010', True)
618+
self.pics_assert('BINFO.S.A0011', False)
619+
self.pics_assert('BINFO.S.A0012', True)
620+
self.pics_assert('BINFO.S.A0013', True)
621+
self.pics_assert('BINFO.S.A0014', False)
622+
self.pics_assert('PICSDOESNOTEXIST', False)
623+
587624

588625
if __name__ == "__main__":
589626
default_matter_test_main()

src/python_testing/matter_testing_support.py

+27-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import argparse
1919
import asyncio
2020
import builtins
21+
import glob
2122
import inspect
2223
import json
2324
import logging
@@ -29,6 +30,7 @@
2930
import sys
3031
import typing
3132
import uuid
33+
import xml.etree.ElementTree as ET
3234
from binascii import hexlify, unhexlify
3335
from dataclasses import asdict as dataclass_asdict
3436
from dataclasses import dataclass, field
@@ -138,7 +140,7 @@ def get_default_paa_trust_store(root_path: pathlib.Path) -> pathlib.Path:
138140
return pathlib.Path.cwd()
139141

140142

141-
def parse_pics(lines=typing.List[str]) -> dict[str, bool]:
143+
def parse_pics(lines: typing.List[str]) -> dict[str, bool]:
142144
pics = {}
143145
for raw in lines:
144146
line, _, _ = raw.partition("#")
@@ -156,11 +158,30 @@ def parse_pics(lines=typing.List[str]) -> dict[str, bool]:
156158
return pics
157159

158160

159-
def read_pics_from_file(filename: str) -> dict[str, bool]:
160-
""" Reads a dictionary of PICS from a file. """
161-
with open(filename, 'r') as f:
162-
lines = f.readlines()
163-
return parse_pics(lines)
161+
def parse_pics_xml(contents: str) -> dict[str, bool]:
162+
pics = {}
163+
mytree = ET.fromstring(contents)
164+
for pi in mytree.iter('picsItem'):
165+
name = pi.find('itemNumber').text
166+
support = pi.find('support').text
167+
pics[name] = int(json.loads(support.lower())) == 1
168+
return pics
169+
170+
171+
def read_pics_from_file(path: str) -> dict[str, bool]:
172+
""" Reads a dictionary of PICS from a file (ci format) or directory (xml format). """
173+
if os.path.isdir(os.path.abspath(path)):
174+
pics_dict = {}
175+
for filename in glob.glob(f'{path}/*.xml'):
176+
with open(filename, 'r') as f:
177+
contents = f.read()
178+
pics_dict.update(parse_pics_xml(contents))
179+
return pics_dict
180+
181+
else:
182+
with open(path, 'r') as f:
183+
lines = f.readlines()
184+
return parse_pics(lines)
164185

165186

166187
def type_matches(received_value, desired_type):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<!--
3+
Autogenerated xml file - Version No:V_24_SVE_1.2
4+
Generated date:2023-09-09 07:41:59
5+
Cluster Name -Basic Information Test Plan
6+
XML PICS -Ref Document:
7+
version master 0cb6035,
8+
Draft
9+
2023-09-08 12:46:22 -0700
10+
-->
11+
<clusterPICS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Generic-PICS-XML-Schema.xsd">
12+
<!--General cluster information-->
13+
<name>Basic Information Test Plan</name>
14+
<clusterId> </clusterId>
15+
<picsRoot> </picsRoot>
16+
<!--Cluster role information-->
17+
<usage>
18+
<picsItem>
19+
<itemNumber>BINFO.S</itemNumber>
20+
<feature>Does the device implement the Basic Information Cluster as a server?</feature>
21+
<reference>9.1. Role - index.html[pdf]</reference>
22+
<status>O</status>
23+
<support>true</support>
24+
</picsItem>
25+
</usage>
26+
<!--PIXIT-->
27+
<pixit>
28+
<pixitItem>
29+
<itemNumber>PIXIT.BINFO.PrimaryColor</itemNumber>
30+
<feature>ProductAppearance.PrimaryColor should reflect the product&#8217;s color</feature>
31+
<reference>10. PIXIT Definition - index.html[pdf]</reference>
32+
<status cond="BINFO.S.A0014">M</status>
33+
<support>0x00</support>
34+
</pixitItem>
35+
<pixitItem>
36+
<itemNumber>PIXIT.BINFO.Finish</itemNumber>
37+
<feature>ProductAppearance.Finish should reflect the product&#8217;s finish</feature>
38+
<reference>10. PIXIT Definition - index.html[pdf]</reference>
39+
<status cond="BINFO.S.A0014">M</status>
40+
<support>0x00</support>
41+
</pixitItem>
42+
</pixit>
43+
<!--Server side PICS-->
44+
<clusterSide type="Server">
45+
<!--Attributes PICS write-->
46+
<attributes>
47+
<picsItem>
48+
<itemNumber>BINFO.S.A0000</itemNumber>
49+
<feature>Does the DUT(server) support the DataModelRevision attribute?</feature>
50+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
51+
<status cond="BINFO.S">M</status>
52+
<support>true</support>
53+
</picsItem>
54+
<picsItem>
55+
<itemNumber>BINFO.S.A0001</itemNumber>
56+
<feature>Does the DUT(server) support the VendorName attribute?</feature>
57+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
58+
<status cond="BINFO.S">M</status>
59+
<support>true</support>
60+
</picsItem>
61+
<picsItem>
62+
<itemNumber>BINFO.S.A0002</itemNumber>
63+
<feature>Does the DUT(server) support the VendorID attribute?</feature>
64+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
65+
<status cond="BINFO.S">M</status>
66+
<support>true</support>
67+
</picsItem>
68+
<picsItem>
69+
<itemNumber>BINFO.S.A0003</itemNumber>
70+
<feature>Does the DUT(server) support the ProductName attribute?</feature>
71+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
72+
<status cond="BINFO.S">M</status>
73+
<support>true</support>
74+
</picsItem>
75+
<picsItem>
76+
<itemNumber>BINFO.S.A0004</itemNumber>
77+
<feature>Does the DUT(server) support the ProductID attribute?</feature>
78+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
79+
<status cond="BINFO.S">M</status>
80+
<support>true</support>
81+
</picsItem>
82+
<picsItem>
83+
<itemNumber>BINFO.S.A0005</itemNumber>
84+
<feature>Does the DUT(server) support the NodeLabel attribute?</feature>
85+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
86+
<status cond="BINFO.S">M</status>
87+
<support>true</support>
88+
</picsItem>
89+
<picsItem>
90+
<itemNumber>BINFO.S.A0006</itemNumber>
91+
<feature>Does the DUT(server) support the Location attribute?</feature>
92+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
93+
<status cond="BINFO.S">M</status>
94+
<support>true</support>
95+
</picsItem>
96+
<picsItem>
97+
<itemNumber>BINFO.S.A0007</itemNumber>
98+
<feature>Does the DUT(server) support the HardwareVersion attribute?</feature>
99+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
100+
<status cond="BINFO.S">M</status>
101+
<support>true</support>
102+
</picsItem>
103+
<picsItem>
104+
<itemNumber>BINFO.S.A0008</itemNumber>
105+
<feature>Does the DUT(server) support the HardwareVersionString attribute?</feature>
106+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
107+
<status cond="BINFO.S">M</status>
108+
<support>true</support>
109+
</picsItem>
110+
<picsItem>
111+
<itemNumber>BINFO.S.A0009</itemNumber>
112+
<feature>Does the DUT(server) support the SoftwareVersion attribute?</feature>
113+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
114+
<status cond="BINFO.S">M</status>
115+
<support>true</support>
116+
</picsItem>
117+
<picsItem>
118+
<itemNumber>BINFO.S.A000a</itemNumber>
119+
<feature>Does the DUT(server) support the SoftwareVersionString attribute?</feature>
120+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
121+
<status cond="BINFO.S">M</status>
122+
<support>true</support>
123+
</picsItem>
124+
<picsItem>
125+
<itemNumber>BINFO.S.A000b</itemNumber>
126+
<feature>Does the DUT(server) support the ManufacturingDate attribute?</feature>
127+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
128+
<status cond="BINFO.S">O</status>
129+
<support>true</support>
130+
</picsItem>
131+
<picsItem>
132+
<itemNumber>BINFO.S.A000c</itemNumber>
133+
<feature>Does the DUT(server) support the PartNumber attribute?</feature>
134+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
135+
<status cond="BINFO.S">O</status>
136+
<support>true</support>
137+
</picsItem>
138+
<picsItem>
139+
<itemNumber>BINFO.S.A000d</itemNumber>
140+
<feature>Does the DUT(server) support the ProductURL attribute?</feature>
141+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
142+
<status cond="BINFO.S">O</status>
143+
<support>true</support>
144+
</picsItem>
145+
<picsItem>
146+
<itemNumber>BINFO.S.A000e</itemNumber>
147+
<feature>Does the DUT(server) support the ProductLabel attribute?</feature>
148+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
149+
<status cond="BINFO.S">O</status>
150+
<support>true</support>
151+
</picsItem>
152+
<picsItem>
153+
<itemNumber>BINFO.S.A000f</itemNumber>
154+
<feature>Does the DUT(server) support the SerialNumber attribute?</feature>
155+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
156+
<status cond="BINFO.S">O</status>
157+
<support>true</support>
158+
</picsItem>
159+
<picsItem>
160+
<itemNumber>BINFO.S.A0010</itemNumber>
161+
<feature>Does the DUT(server) support the LocalConfigDisabled attribute?</feature>
162+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
163+
<status cond="BINFO.S">O</status>
164+
<support>true</support>
165+
</picsItem>
166+
<picsItem>
167+
<itemNumber>BINFO.S.A0011</itemNumber>
168+
<feature>Does the DUT(server) support the Reachable attribute?</feature>
169+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
170+
<status cond="BINFO.S">O</status>
171+
<support>false</support>
172+
</picsItem>
173+
<picsItem>
174+
<itemNumber>BINFO.S.A0012</itemNumber>
175+
<feature>Does the DUT(server) support the UniqueID attribute?</feature>
176+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
177+
<status cond="BINFO.S">O</status>
178+
<support>true</support>
179+
</picsItem>
180+
<picsItem>
181+
<itemNumber>BINFO.S.A0013</itemNumber>
182+
<feature>Does the DUT(server) support the CapabilityMinima attribute?</feature>
183+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
184+
<status cond="BINFO.S">M</status>
185+
<support>true</support>
186+
</picsItem>
187+
<picsItem>
188+
<itemNumber>BINFO.S.A0014</itemNumber>
189+
<feature>Does the DUT(server) support the ProductAppearance attribute?</feature>
190+
<reference>9.2.1. Attributes - index.html[pdf]</reference>
191+
<status cond="BINFO.S">O</status>
192+
<support>false</support>
193+
</picsItem>
194+
</attributes>
195+
<!--Events PICS write-->
196+
<events>
197+
<picsItem>
198+
<itemNumber>BINFO.S.E00</itemNumber>
199+
<feature>Does the DUT(server) support the StartUp event?</feature>
200+
<reference>9.2.2. Events - index.html[pdf]</reference>
201+
<status cond="BINFO.S">M</status>
202+
<support>true</support>
203+
</picsItem>
204+
<picsItem>
205+
<itemNumber>BINFO.S.E01</itemNumber>
206+
<feature>Does the DUT(server) support the ShutDown event?</feature>
207+
<reference>9.2.2. Events - index.html[pdf]</reference>
208+
<status cond="BINFO.S">O</status>
209+
<support>false</support>
210+
</picsItem>
211+
<picsItem>
212+
<itemNumber>BINFO.S.E02</itemNumber>
213+
<feature>Does the DUT(server) support the Leave event?</feature>
214+
<reference>9.2.2. Events - index.html[pdf]</reference>
215+
<status cond="BINFO.S">O</status>
216+
<support>false</support>
217+
</picsItem>
218+
<picsItem>
219+
<itemNumber>BINFO.S.E03</itemNumber>
220+
<feature>Does the DUT(server) support the ReachableChanged event?</feature>
221+
<reference>9.2.2. Events - index.html[pdf]</reference>
222+
<status cond="BINFO.S.A0011">M</status>
223+
<support>false</support>
224+
</picsItem>
225+
</events>
226+
<!--Commands generated PICS write-->
227+
<commandsGenerated />
228+
<!--Commands received PICS write-->
229+
<commandsReceived />
230+
<!--Features PICS write-->
231+
<features />
232+
<!--Manual controllable PICS write-->
233+
<manually />
234+
</clusterSide>
235+
<!--Client side PICS-->
236+
<clusterSide type="Client">
237+
<!--Attributes PICS write-->
238+
<attributes />
239+
<!--Events PICS write-->
240+
<events />
241+
<!--Commands generated PICS write-->
242+
<commandsGenerated />
243+
<!--Commands received PICS write-->
244+
<commandsReceived />
245+
<!--Features PICS write-->
246+
<features />
247+
<!--Manual controllable PICS write-->
248+
<manually />
249+
</clusterSide>
250+
</clusterPICS>

0 commit comments

Comments
 (0)