Skip to content

Commit fd2ba46

Browse files
committed
TC-DESC-2.2: Fix comparison when mfg label is in the list
Unit tests included, also tested on an example app with mfg tags
1 parent f509f67 commit fd2ba46

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/python_testing/TestMatterTestingSupport.py

+8
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,14 @@ def test_tag_list_problems(self):
548548
problems = find_tag_list_problems(roots, device_types, simple)
549549
asserts.assert_equal(len(problems), 0, "Unexpected problems found in list")
550550

551+
# Tags with mfg tags
552+
tag_mfg = Clusters.Descriptor.Structs.SemanticTagStruct(mfgCode=0xFFF1, label="test")
553+
tag_label = Clusters.Descriptor.Structs.SemanticTagStruct(tag=1, label="test")
554+
simple[1][Clusters.Descriptor][Clusters.Descriptor.Attributes.TagList] = [tag1, tag_mfg]
555+
simple[2][Clusters.Descriptor][Clusters.Descriptor.Attributes.TagList] = [tag1, tag_label]
556+
problems = find_tag_list_problems(roots, device_types, simple)
557+
asserts.assert_equal(len(problems), 0, "Unexpected problems found in list")
558+
551559
def test_root_node_tag_list_functions(self):
552560
# Example topology - see comment above for the layout.
553561
# There are 4 direct children of root 0

src/python_testing/taglist_and_topology_test_support.py

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import functools
1919
from collections import defaultdict
2020
from dataclasses import dataclass, field
21+
from chip.clusters.Types import Nullable, NullValue
2122
from typing import Any
2223

2324
import chip.clusters as Clusters
@@ -143,12 +144,16 @@ def create_device_type_list_for_root(direct_children, endpoint_dict: dict[int, A
143144

144145

145146
def cmp_tag_list(a: Clusters.Descriptor.Structs.SemanticTagStruct, b: Clusters.Descriptor.Structs.SemanticTagStruct):
147+
if type(a.mfgCode) != type(b.mfgCode):
148+
return -1 if type(a.mfgCode) is Nullable else 1
146149
if a.mfgCode != b.mfgCode:
147150
return -1 if a.mfgCode < b.mfgCode else 1
148151
if a.namespaceID != b.namespaceID:
149152
return -1 if a.namespaceID < b.namespaceID else 1
150153
if a.tag != b.tag:
151154
return -1 if a.tag < b.tag else 1
155+
if type(a.label) != type(b.label):
156+
return -1 if type(a.label) is Nullable or a.label is None else 1
152157
if a.label != b.label:
153158
return -1 if a.label < b.label else 1
154159
return 0

0 commit comments

Comments
 (0)