Skip to content

Commit

Permalink
TC-DESC-2.2: Fix comparison when mfg label is in the list
Browse files Browse the repository at this point in the history
Unit tests included, also tested on an example app with mfg tags
  • Loading branch information
cecille committed Sep 30, 2024
1 parent f509f67 commit fd2ba46
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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 @@ -18,6 +18,7 @@
import functools
from collections import defaultdict
from dataclasses import dataclass, field
from chip.clusters.Types import Nullable, NullValue
from typing import Any

import chip.clusters as Clusters
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
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

0 comments on commit fd2ba46

Please sign in to comment.