|
1 | 1 | #
|
2 |
| -# Copyright (c) 2023 Project CHIP Authors |
| 2 | +# Copyright (c) 2024 Project CHIP Authors |
3 | 3 | # All rights reserved.
|
4 | 4 | #
|
5 | 5 | # Licensed under the Apache License, Version 2.0 (the "License");
|
|
16 | 16 | #
|
17 | 17 |
|
18 | 18 | import argparse
|
19 |
| -import os |
20 | 19 | import sys
|
21 |
| - |
22 |
| -from rich.console import Console |
| 20 | +import os |
| 21 | +from pics_generator_support import pics_xml_file_list_loader, map_cluster_name_to_pics_xml |
23 | 22 |
|
24 | 23 | # Add the path to python_testing folder, in order to be able to import from matter_testing_support
|
25 | 24 | sys.path.append(os.path.abspath(sys.path[0] + "/../../python_testing"))
|
26 |
| -from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main # noqa: E402 |
27 | 25 | from spec_parsing_support import build_xml_clusters # noqa: E402
|
28 | 26 |
|
29 |
| -console = None |
30 |
| -xml_clusters = None |
31 | 27 |
|
32 | 28 | parser = argparse.ArgumentParser()
|
33 | 29 | parser.add_argument('--pics-template', required=True)
|
34 | 30 | args, unknown = parser.parse_known_args()
|
35 | 31 |
|
36 |
| -xmlTemplatePathStr = args.pics_template |
37 |
| -if not xmlTemplatePathStr.endswith('/'): |
38 |
| - xmlTemplatePathStr += '/' |
39 |
| - |
40 |
| -# Load PICS XML templates |
41 |
| -print("Capture list of PICS XML templates") |
42 |
| -xmlFileList = os.listdir(xmlTemplatePathStr) |
43 |
| -for PICSXmlFile in xmlFileList: |
44 |
| - print(f"{xmlTemplatePathStr}/{PICSXmlFile}") |
45 |
| - |
46 |
| - |
47 |
| -class XMLPICSValidator(MatterBaseTest): |
48 |
| - @async_test_body |
49 |
| - async def test_xml_pics_validator(self): |
50 |
| - |
51 |
| - # Create console to print |
52 |
| - global console |
53 |
| - console = Console() |
54 |
| - |
55 |
| - global xml_clusters |
56 |
| - xml_clusters, problems = build_xml_clusters() |
57 |
| - |
58 |
| - for cluster in xml_clusters: |
59 |
| - |
60 |
| - fileName = "" |
61 |
| - clusterName = xml_clusters[cluster].name |
62 |
| - |
63 |
| - if "ICDManagement" == clusterName: |
64 |
| - picsFileName = "ICD Management" |
65 |
| - |
66 |
| - elif "OTA Software Update Provider" in clusterName or \ |
67 |
| - "OTA Software Update Requestor" in clusterName: |
68 |
| - picsFileName = "OTA Software Update" |
69 |
| - |
70 |
| - elif "On/Off" == clusterName: |
71 |
| - picsFileName = clusterName.replace("/", "-") |
72 |
| - |
73 |
| - elif "GroupKeyManagement" == clusterName: |
74 |
| - picsFileName = "Group Communication" |
75 |
| - |
76 |
| - elif "Wake on LAN" == clusterName or \ |
77 |
| - "Low Power" == clusterName or \ |
78 |
| - "Keypad Input" == clusterName or \ |
79 |
| - "Audio Output" == clusterName or \ |
80 |
| - "Media Input" == clusterName or \ |
81 |
| - "Target Navigator" == clusterName or \ |
82 |
| - "Content Control" == clusterName or \ |
83 |
| - "Channel" == clusterName or \ |
84 |
| - "Media Playback" == clusterName or \ |
85 |
| - "Account Login" == clusterName or \ |
86 |
| - "Application Basic" == clusterName or \ |
87 |
| - "Content Launcher" == clusterName or \ |
88 |
| - "Content App Observer" == clusterName or \ |
89 |
| - "Application Launcher" == clusterName: |
90 |
| - |
91 |
| - picsFileName = "Media Cluster" |
92 |
| - |
93 |
| - elif "Operational Credentials" == clusterName: |
94 |
| - picsFileName = "Node Operational Credentials" |
95 |
| - |
96 |
| - # Workaround for naming colisions with current logic |
97 |
| - elif "Thermostat" == clusterName: |
98 |
| - picsFileName = "Thermostat Cluster" |
99 |
| - |
100 |
| - elif "Boolean State" == clusterName: |
101 |
| - picsFileName = "Boolean State Cluster" |
102 |
| - |
103 |
| - elif "AccessControl" in clusterName: |
104 |
| - picsFileName = "Access Control Cluster" |
105 |
| - |
106 |
| - else: |
107 |
| - picsFileName = clusterName |
| 32 | +xml_template_path_str = args.pics_template |
108 | 33 |
|
109 |
| - for file in xmlFileList: |
110 |
| - if file.lower().startswith(picsFileName.lower()): |
111 |
| - fileName = file |
112 |
| - break |
| 34 | +print("Build list of PICS XML") |
| 35 | +pics_xml_file_list = pics_xml_file_list_loader(xml_template_path_str, True) |
113 | 36 |
|
114 |
| - if fileName: |
115 |
| - console.print(f"[blue]\"{clusterName}\" - \"{fileName}\" ✅") |
116 |
| - else: |
117 |
| - console.print(f"[red]Could not find matching file for \"{clusterName}\" ❌") |
118 |
| - continue |
| 37 | +print("Build list of spec XML") |
| 38 | +xml_clusters, problems = build_xml_clusters() |
119 | 39 |
|
| 40 | +for cluster in xml_clusters: |
| 41 | + pics_xml_file_name = map_cluster_name_to_pics_xml(xml_clusters[cluster].name, pics_xml_file_list) |
120 | 42 |
|
121 |
| -if __name__ == "__main__": |
122 |
| - default_matter_test_main() |
| 43 | + if pics_xml_file_name: |
| 44 | + print(f"{xml_clusters[cluster].name} - {pics_xml_file_name} ✅") |
| 45 | + else: |
| 46 | + print( |
| 47 | + f"Could not find matching PICS XML file for {xml_clusters[cluster].name} - {xml_clusters[cluster].pics} (Provisional: {xml_clusters[cluster].is_provisional}) ❌") |
0 commit comments