Skip to content

Commit 3ad1472

Browse files
cecillerestyled-commits
authored andcommitted
Choice conformance: Add choice conformance markers (project-chip#33854)
* Choice conformance: Add conformance parsing * Add to tests.yaml * Restyled by autopep8 * Restyled by isort * linter * Update .github/workflows/tests.yaml * wrap enum to contain choice, address review comments * remove equality operator and check the member directly --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent fb05d88 commit 3ad1472

File tree

4 files changed

+457
-188
lines changed

4 files changed

+457
-188
lines changed

.github/workflows/tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ jobs:
582582
scripts/run_in_python_env.sh out/venv './scripts/tests/TestTimeSyncTrustedTimeSourceRunner.py'
583583
scripts/run_in_python_env.sh out/venv './src/python_testing/test_testing/test_TC_ICDM_2_1.py'
584584
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestIdChecks.py'
585+
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestConformanceSupport.py'
585586
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/test_IDM_10_4.py'
586587
587588
- name: Uploading core files

src/python_testing/TC_DeviceConformance.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ def record_warning(location, problem):
124124
record_error(location=location, problem=f'Unknown feature with mask 0x{f:02x}')
125125
continue
126126
xml_feature = self.xml_clusters[cluster_id].features[f]
127-
conformance_decision = xml_feature.conformance(feature_map, attribute_list, all_command_list)
128-
if not conformance_allowed(conformance_decision, allow_provisional):
127+
conformance_decision_with_choice = xml_feature.conformance(feature_map, attribute_list, all_command_list)
128+
if not conformance_allowed(conformance_decision_with_choice, allow_provisional):
129129
record_error(location=location, problem=f'Disallowed feature with mask 0x{f:02x}')
130130
for feature_mask, xml_feature in self.xml_clusters[cluster_id].features.items():
131-
conformance_decision = xml_feature.conformance(feature_map, attribute_list, all_command_list)
132-
if conformance_decision == ConformanceDecision.MANDATORY and feature_mask not in feature_masks:
131+
conformance_decision_with_choice = xml_feature.conformance(feature_map, attribute_list, all_command_list)
132+
if conformance_decision_with_choice.decision == ConformanceDecision.MANDATORY and feature_mask not in feature_masks:
133133
record_error(
134134
location=location, problem=f'Required feature with mask 0x{f:02x} is not present in feature map. {conformance_str(xml_feature.conformance, feature_map, self.xml_clusters[cluster_id].features)}')
135135

@@ -145,16 +145,16 @@ def record_warning(location, problem):
145145
record_error(location=location, problem='Standard attribute found on device, but not in spec')
146146
continue
147147
xml_attribute = self.xml_clusters[cluster_id].attributes[attribute_id]
148-
conformance_decision = xml_attribute.conformance(feature_map, attribute_list, all_command_list)
149-
if not conformance_allowed(conformance_decision, allow_provisional):
148+
conformance_decision_with_choice = xml_attribute.conformance(feature_map, attribute_list, all_command_list)
149+
if not conformance_allowed(conformance_decision_with_choice, allow_provisional):
150150
location = AttributePathLocation(endpoint_id=endpoint_id, cluster_id=cluster_id, attribute_id=attribute_id)
151151
record_error(
152152
location=location, problem=f'Attribute 0x{attribute_id:02x} is included, but is disallowed by conformance. {conformance_str(xml_attribute.conformance, feature_map, self.xml_clusters[cluster_id].features)}')
153153
for attribute_id, xml_attribute in self.xml_clusters[cluster_id].attributes.items():
154154
if cluster_id in ignore_attributes and attribute_id in ignore_attributes[cluster_id]:
155155
continue
156-
conformance_decision = xml_attribute.conformance(feature_map, attribute_list, all_command_list)
157-
if conformance_decision == ConformanceDecision.MANDATORY and attribute_id not in cluster.keys():
156+
conformance_decision_with_choice = xml_attribute.conformance(feature_map, attribute_list, all_command_list)
157+
if conformance_decision_with_choice.decision == ConformanceDecision.MANDATORY and attribute_id not in cluster.keys():
158158
location = AttributePathLocation(endpoint_id=endpoint_id, cluster_id=cluster_id, attribute_id=attribute_id)
159159
record_error(
160160
location=location, problem=f'Attribute 0x{attribute_id:02x} is required, but is not present on the DUT. {conformance_str(xml_attribute.conformance, feature_map, self.xml_clusters[cluster_id].features)}')
@@ -173,13 +173,13 @@ def check_spec_conformance_for_commands(command_type: CommandType):
173173
record_error(location=location, problem='Standard command found on device, but not in spec')
174174
continue
175175
xml_command = xml_commands_dict[command_id]
176-
conformance_decision = xml_command.conformance(feature_map, attribute_list, all_command_list)
177-
if not conformance_allowed(conformance_decision, allow_provisional):
176+
conformance_decision_with_choice = xml_command.conformance(feature_map, attribute_list, all_command_list)
177+
if not conformance_allowed(conformance_decision_with_choice, allow_provisional):
178178
record_error(
179179
location=location, problem=f'Command 0x{command_id:02x} is included, but disallowed by conformance. {conformance_str(xml_command.conformance, feature_map, self.xml_clusters[cluster_id].features)}')
180180
for command_id, xml_command in xml_commands_dict.items():
181-
conformance_decision = xml_command.conformance(feature_map, attribute_list, all_command_list)
182-
if conformance_decision == ConformanceDecision.MANDATORY and command_id not in command_list:
181+
conformance_decision_with_choice = xml_command.conformance(feature_map, attribute_list, all_command_list)
182+
if conformance_decision_with_choice.decision == ConformanceDecision.MANDATORY and command_id not in command_list:
183183
location = CommandPathLocation(endpoint_id=endpoint_id, cluster_id=cluster_id, command_id=command_id)
184184
record_error(
185185
location=location, problem=f'Command 0x{command_id:02x} is required, but is not present on the DUT. {conformance_str(xml_command.conformance, feature_map, self.xml_clusters[cluster_id].features)}')

0 commit comments

Comments
 (0)