Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c6908e9
Add automatic device attribute dump on composition test failures:
j-ororke Sep 17, 2025
e2154ab
Restyled by autopep8
restyled-commits Sep 17, 2025
9c36c19
Remove duplicate on_fail() and unused import from TC_DeviceConformance
j-ororke Sep 17, 2025
5edf777
Removing unused logging import
j-ororke Sep 17, 2025
1438550
Change inheritance order to enable automatic device attribute dump on…
j-ororke Sep 17, 2025
9abde9b
Restyled by autopep8
restyled-commits Sep 17, 2025
dc5df9e
resolving linting errors and making sure that on test failures we emi…
j-ororke Sep 17, 2025
6756ca7
Restyled by autopep8
restyled-commits Sep 17, 2025
10f1ca6
Update basic_composition.py
j-ororke Sep 24, 2025
a026a85
Update basic_composition.py
j-ororke Sep 24, 2025
b1b1a4e
Merge branch 'master' into create_global_attr_log_function
j-ororke Sep 24, 2025
b149ff6
Restyled by autopep8
restyled-commits Sep 24, 2025
6992404
Move device attribute dumping from BasicCompositionTests to MatterBas…
j-ororke Oct 1, 2025
fee2649
Restyled by autopep8
restyled-commits Oct 1, 2025
855d881
Merge branch 'master' into create_global_attr_log_function
j-ororke Oct 1, 2025
13fb594
Merge branch 'master' into create_global_attr_log_function
j-ororke Oct 16, 2025
530ac3a
Fix Python 3.11 compatibility and improve test failure User Experience:
j-ororke Oct 16, 2025
f2fc773
removed duplicate log_structured_data function from basic_composition…
j-ororke Nov 6, 2025
7c93c8c
removed duplicate log_structured_data function from basic_composition…
j-ororke Nov 6, 2025
914426f
Restyled by autopep8
restyled-commits Nov 6, 2025
127cb15
Resolving linting error
j-ororke Nov 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/python_testing/TC_DeviceBasicComposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
from matter.clusters.Types import Nullable
from matter.exceptions import ChipStackError
from matter.interaction_model import InteractionModelError, Status
from matter.testing.basic_composition import BasicCompositionTests
from matter.testing.basic_composition import BasicCompositionTests, log_structured_data
from matter.testing.global_attribute_ids import (AttributeIdType, ClusterIdType, CommandIdType, GlobalAttributeIds,
attribute_id_type, cluster_id_type, command_id_type)
from matter.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main
Expand Down Expand Up @@ -965,13 +965,6 @@ def test_TC_IDM_12_1(self):
json_str, txt_str = self.dump_wildcard(dump_device_composition_path)

# Structured dump so we can pull these back out of the logs
def log_structured_data(start_tag: str, dump_string):
lines = dump_string.splitlines()
logging.info(f'{start_tag}BEGIN ({len(lines)} lines)====')
for line in lines:
logging.info(f'{start_tag}{line}')
logging.info(f'{start_tag}END ====')

log_structured_data('==== json: ', json_str)
log_structured_data('==== txt: ', txt_str)

Expand Down
3 changes: 2 additions & 1 deletion src/python_testing/TC_DeviceConformance.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
# === END CI TEST ARGUMENTS ===

# TODO: Enable 10.5 in CI once the door lock OTA requestor problem is sorted.
import logging
from typing import Callable

import matter.clusters as Clusters
from matter.testing.basic_composition import BasicCompositionTests
from matter.testing.basic_composition import BasicCompositionTests, log_structured_data
from matter.testing.choice_conformance import (evaluate_attribute_choice_conformance, evaluate_command_choice_conformance,
evaluate_feature_choice_conformance)
from matter.testing.conformance import conformance_allowed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@
from matter.testing.spec_parsing import PrebuiltDataModelDirectory, build_xml_clusters, build_xml_device_types, dm_from_spec_version


def log_structured_data(start_tag: str, dump_string: str):
"""Log structured data with a clear start and end marker.

This function is used to output device attribute dumps and other structured
data to logs in a format that can be easily extracted for debugging.

Args:
start_tag: A prefix tag to identify the type of data being logged
dump_string: The data to be logged
"""
lines = dump_string.splitlines()
logging.info(f'{start_tag}BEGIN ({len(lines)} lines)====')
for line in lines:
logging.info(f'{start_tag}{line}')
logging.info(f'{start_tag}END ====')


@dataclass
class ArlData:
have_arl: bool
Expand Down Expand Up @@ -276,3 +293,22 @@ def build_spec_xmls(self):
self.xml_clusters, self.problems = build_xml_clusters(dm)
self.xml_device_types, problems = build_xml_device_types(dm)
self.problems.extend(problems)

def on_fail(self, record):
"""Override on_fail to automatically dump device data when any composition test fails.

This ensures that whenever any test inheriting from BasicCompositionTests fails,
we automatically get the device attribute dump for debugging purposes.
"""
# Call the parent on_fail method first (this will be MatterBaseTest.on_fail)
super().on_fail(record)

# Dump device composition data if available for debugging
try:
if hasattr(self, 'endpoints_tlv') and self.endpoints_tlv:
json_str, txt_str = self.dump_wildcard(None) # Don't write to file, just get strings
log_structured_data('==== FAILURE_DUMP_json: ', json_str)
log_structured_data('==== FAILURE_DUMP_txt: ', txt_str)
except Exception as e:
# Don't let logging errors interfere with the original test failure
logging.warning(f"Failed to dump device data on test failure: {e}")
Loading