Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TC-DESC-2.2: Fix comparison when mfg label is in the list #35849

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
8 changes: 8 additions & 0 deletions src/python_testing/TestMatterTestingSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,14 @@ def test_tag_list_problems(self):
problems = find_tag_list_problems(roots, device_types, simple)
asserts.assert_equal(len(problems), 0, "Unexpected problems found in list")

# Tags with mfg tags
tag_mfg = Clusters.Descriptor.Structs.SemanticTagStruct(mfgCode=0xFFF1, label="test")
tag_label = Clusters.Descriptor.Structs.SemanticTagStruct(tag=1, label="test")
simple[1][Clusters.Descriptor][Clusters.Descriptor.Attributes.TagList] = [tag1, tag_mfg]
simple[2][Clusters.Descriptor][Clusters.Descriptor.Attributes.TagList] = [tag1, tag_label]
problems = find_tag_list_problems(roots, device_types, simple)
asserts.assert_equal(len(problems), 0, "Unexpected problems found in list")

def test_root_node_tag_list_functions(self):
# Example topology - see comment above for the layout.
# There are 4 direct children of root 0
Expand Down
5 changes: 5 additions & 0 deletions src/python_testing/taglist_and_topology_test_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing import Any

import chip.clusters as Clusters
from chip.clusters.Types import Nullable


@dataclass
Expand Down Expand Up @@ -143,12 +144,16 @@ def create_device_type_list_for_root(direct_children, endpoint_dict: dict[int, A


def cmp_tag_list(a: Clusters.Descriptor.Structs.SemanticTagStruct, b: Clusters.Descriptor.Structs.SemanticTagStruct):
if type(a.mfgCode) != type(b.mfgCode):
return -1 if type(a.mfgCode) is Nullable else 1
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
if a.mfgCode != b.mfgCode:
return -1 if a.mfgCode < b.mfgCode else 1
if a.namespaceID != b.namespaceID:
return -1 if a.namespaceID < b.namespaceID else 1
if a.tag != b.tag:
return -1 if a.tag < b.tag else 1
if type(a.label) != type(b.label):
return -1 if type(a.label) is Nullable or a.label is None else 1
if a.label != b.label:
return -1 if a.label < b.label else 1
return 0
Expand Down
Loading