Skip to content

Commit 61bf37e

Browse files
authored
TC-IDM-12.1: Add a wildcard dump test (#33878)
* TC-IDM-12.1: Add a wildcard dump test This is a convenience test for the test harness that creates a device dump for submission as a part of the certification materials. Putting this as a separate test means we don't need to ask the testers to mess around with setting parameters for this test in the test harness. * linter * add wildcard read as a step * slight re-wording
1 parent 7bc498b commit 61bf37e

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

src/python_testing/TC_DeviceBasicComposition.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from chip.interaction_model import InteractionModelError, Status
3030
from chip.tlv import uint
3131
from global_attribute_ids import GlobalAttributeIds
32-
from matter_testing_support import (AttributePathLocation, ClusterPathLocation, CommandPathLocation, MatterBaseTest,
32+
from matter_testing_support import (AttributePathLocation, ClusterPathLocation, CommandPathLocation, MatterBaseTest, TestStep,
3333
async_test_body, default_matter_test_main)
3434
from mobly import asserts
3535
from taglist_and_topology_test_support import (create_device_type_list_for_root, create_device_type_lists, find_tag_list_problems,
@@ -748,6 +748,23 @@ def test_TC_DESC_2_2(self):
748748
if problems or root_problems:
749749
self.fail_current_test("Problems with tags lists")
750750

751+
def steps_TC_IDM_12_1(self):
752+
return [TestStep(0, "TH performs a wildcard read of all attributes and endpoints on the device"),
753+
TestStep(1, "TH creates a MatterTlvJson dump of the wildcard attributes for submission to certification.")]
754+
755+
def test_TC_IDM_12_1(self):
756+
# wildcard read - already done.
757+
self.step(0)
758+
759+
# Create the dump
760+
self.step(1)
761+
pid = self.endpoints[0][Clusters.BasicInformation][Clusters.BasicInformation.Attributes.ProductID]
762+
vid = self.endpoints[0][Clusters.BasicInformation][Clusters.BasicInformation.Attributes.VendorID]
763+
software_version = self.endpoints[0][Clusters.BasicInformation][Clusters.BasicInformation.Attributes.SoftwareVersion]
764+
filename = f'device_dump_0x{vid:04X}_0x{pid:04X}_{software_version}.json'
765+
dump_device_composition_path = self.user_params.get("dump_device_composition_path", filename)
766+
self.dump_wildcard(dump_device_composition_path)
767+
751768

752769
if __name__ == "__main__":
753770
default_matter_test_main()

src/python_testing/basic_composition_support.py

+17-15
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import logging
2323
import pathlib
2424
import sys
25+
import typing
2526
from pprint import pprint
2627
from typing import Any, Optional
2728

@@ -97,6 +98,16 @@ def ConvertValue(value) -> Any:
9798

9899

99100
class BasicCompositionTests:
101+
def dump_wildcard(self, dump_device_composition_path: typing.Optional[str]):
102+
node_dump_dict = {endpoint_id: MatterTlvToJson(self.endpoints_tlv[endpoint_id]) for endpoint_id in self.endpoints_tlv}
103+
logging.debug(f"Raw TLV contents of Node: {json.dumps(node_dump_dict, indent=2)}")
104+
105+
if dump_device_composition_path is not None:
106+
with open(pathlib.Path(dump_device_composition_path).with_suffix(".json"), "wt+") as outfile:
107+
json.dump(node_dump_dict, outfile, indent=2)
108+
with open(pathlib.Path(dump_device_composition_path).with_suffix(".txt"), "wt+") as outfile:
109+
pprint(self.endpoints, outfile, indent=1, width=200, compact=True)
110+
100111
async def setup_class_helper(self, default_to_pase: bool = True):
101112
dev_ctrl = self.default_controller
102113
self.problems = []
@@ -114,29 +125,20 @@ async def setup_class_helper(self, default_to_pase: bool = True):
114125
node_id = self.dut_node_id
115126

116127
wildcard_read = (await dev_ctrl.Read(node_id, [()]))
117-
endpoints_tlv = wildcard_read.tlvAttributes
118-
119-
node_dump_dict = {endpoint_id: MatterTlvToJson(endpoints_tlv[endpoint_id]) for endpoint_id in endpoints_tlv}
120-
logging.debug(f"Raw TLV contents of Node: {json.dumps(node_dump_dict, indent=2)}")
121-
122-
if dump_device_composition_path is not None:
123-
with open(pathlib.Path(dump_device_composition_path).with_suffix(".json"), "wt+") as outfile:
124-
json.dump(node_dump_dict, outfile, indent=2)
125-
with open(pathlib.Path(dump_device_composition_path).with_suffix(".txt"), "wt+") as outfile:
126-
pprint(wildcard_read.attributes, outfile, indent=1, width=200, compact=True)
127-
128-
logging.info("###########################################################")
129-
logging.info("Start of actual tests")
130-
logging.info("###########################################################")
131128

132129
# ======= State kept for use by all tests =======
133-
134130
# All endpoints in "full object" indexing format
135131
self.endpoints = wildcard_read.attributes
136132

137133
# All endpoints in raw TLV format
138134
self.endpoints_tlv = wildcard_read.tlvAttributes
139135

136+
self.dump_wildcard(dump_device_composition_path)
137+
138+
logging.info("###########################################################")
139+
logging.info("Start of actual tests")
140+
logging.info("###########################################################")
141+
140142
def get_test_name(self) -> str:
141143
"""Return the function name of the caller. Used to create logging entries."""
142144
return sys._getframe().f_back.f_code.co_name

0 commit comments

Comments
 (0)