Skip to content

Commit f7374b8

Browse files
committed
check
1 parent 9e009e1 commit f7374b8

File tree

1 file changed

+33
-22
lines changed

1 file changed

+33
-22
lines changed

src/python_testing/post_certification_tests/post-cert-checks.py

+33-22
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import sys
4343
import time
4444
import uuid
45+
from dataclasses import dataclass
4546
from enum import Enum, auto
4647
from pathlib import Path
4748

@@ -70,10 +71,17 @@
7071
import fetch_paa_certs_from_dcl
7172

7273

74+
@dataclass
75+
class Failure:
76+
test: str
77+
step: str
78+
79+
7380
class Hooks():
7481
def __init__(self):
7582
self.failures = []
7683
self.current_step = 'unknown'
84+
self.current_test = 'unknown'
7785

7886
def start(self, count: int):
7987
pass
@@ -82,6 +90,7 @@ def stop(self, duration: int):
8290
pass
8391

8492
def test_start(self, filename: str, name: str, count: int):
93+
self.current_test = name
8594
pass
8695

8796
def test_stop(self, exception: Exception, duration: int):
@@ -97,7 +106,7 @@ def step_success(self, logger, logs, duration: int, request):
97106
pass
98107

99108
def step_failure(self, logger, logs, duration: int, request, received):
100-
self.failures.append(self.current_step)
109+
self.failures.append(Failures(self.current_test, self.current_step))
101110

102111
def step_unknown(self):
103112
pass
@@ -139,41 +148,50 @@ async def setup_class(self):
139148
self.vid = await self.read_single_attribute_check_success(cluster=bi, attribute=bi.Attributes.VendorID)
140149
self.pid = await self.read_single_attribute_check_success(cluster=bi, attribute=bi.Attributes.ProductID)
141150
self.software_version = await self.read_single_attribute_check_success(cluster=bi, attribute=bi.Attributes.SoftwareVersion)
142-
self.vid = 0x6006
143-
self.pid = 1
144-
self.software_version = 1300
145151

146152
def steps_Vendor(self):
147153
return [TestStep(1, "Check if device VID is listed in the DCL vendor schema", "Listing found")]
148154

149155
def test_Vendor(self):
150156
self.step(1)
151157
entry = get_dcl_vendor(self.vid)
152-
asserts.assert_true('vendorInfo' in entry.keys(), f"Unable to find vendor entry for {self.vid:04x}")
158+
key = 'vendorInfo'
159+
asserts.assert_true(key in entry.keys(), f"Unable to find vendor entry for {self.vid:04x}")
160+
logging.info(f'Found vendor key 0x{vid:04X} in DCL:')
161+
logging.info(f'{entry[key]}')
153162

154163
def steps_Model(self):
155164
return [TestStep(1, "Check if device VID/PID are listed in the DCL model schema", "Listing found")]
156165

157166
def test_Model(self):
158167
self.step(1)
168+
key = 'model'
159169
entry = get_dcl_model(self.vid, self.pid)
160-
asserts.assert_true('model' in entry.keys(), f"Unable to find model entry for {self.vid:04x} {self.pid:04x}")
170+
asserts.assert_true(key in entry.keys(), f"Unable to find model entry for {self.vid:04x} {self.pid:04x}")
171+
logging.info(f'Found model entry for vid=0x{vid:04X} pid=0x{pid:04X} in the DCL:')
172+
logging.info(f'{entry[key]}')
161173

162174
def steps_Compliance(self):
163175
return [TestStep(1, "Check if device VID/PID/SoftwareVersion are listed in the DCL compliance info schema", "Listing found")]
164176

165177
def test_Compliance(self):
166178
self.step(1)
179+
key = 'complianceInfo'
167180
entry = get_dcl_compliance_info(self.vid, self.pid, self.software_version)
168-
asserts.assert_true('complianceInfo' in entry.keys(), f"Unable to find compliance entry for {self.vid:04x} {self.pid:04x} {self.software_version}")
181+
asserts.assert_true(key in entry.keys(), f"Unable to find compliance entry for {self.vid:04x} {self.pid:04x} {self.software_version}")
182+
logging.info(f'Found compliance info for vid=0x{vid:04X} pid=0x{pid:04X} software version={software_version} in the DCL:')
183+
logging.info(f'{entry[key]}')
169184

170185
def steps_CertifiedModel(self):
171186
return [TestStep(1, "Check if device VID/PID/SoftwareVersion are listed in the DCL certified model schema", "Listing found")]
172187

173188
def test_CertifiedModel(self):
174189
self.step(1)
190+
key = 'certifiedModel'
175191
entry = get_dcl_certified_model(self.vid, self.pid, self.software_version)
176-
asserts.assert_true('certifiedModel' in entry.keys(), f"Unable to find certified model entry for {self.vid:04x} {self.pid:04x} {self.software_version}")
192+
asserts.assert_true(key in entry.keys(), f"Unable to find certified model entry for {self.vid:04x} {self.pid:04x} {self.software_version}")
193+
logging.info(f'Found certified model for vid=0x{vid:04X} pid=0x{pid:04X} software version={software_version} in the DCL:')
194+
logging.info(f'{entry[key]}')
177195

178196

179197
def get_qr() -> str:
@@ -279,11 +297,11 @@ def __exit__(self, *args):
279297
shutil.rmtree(self.cd_path)
280298

281299

282-
def run_test(test_class: MatterBaseTest, test_name: str, test_config: TestConfig) -> list[str]:
300+
def run_test(test_class: MatterBaseTest, tests: typing.list[str], test_config: TestConfig) -> list[str]:
283301
hooks = Hooks()
284302
stack = test_config.get_stack()
285303
controller = test_config.get_controller()
286-
matter_config = test_config.get_config([test_name])
304+
matter_config = test_config.get_config(tests)
287305
ok = run_tests_no_exit(test_class, matter_config, hooks, controller, stack)
288306
if not ok:
289307
print(f"Test failure. Failed on step: {hooks.get_failures()}")
@@ -297,7 +315,7 @@ def run_cert_test(test: str, test_config: TestConfig) -> list[str]:
297315
# share a name, test is test_classname
298316
module = importlib.import_module(test)
299317
test_class = getattr(module, test)
300-
return run_test(test_class, f'test_{test}', test_config)
318+
return run_test(test_class, [f'test_{test}'], test_config)
301319

302320

303321
def main():
@@ -308,22 +326,15 @@ def main():
308326
# DA-1.7 is a test of the DAC chain (up to a PAA in the given directory)
309327
failures_DA_1_7 = run_cert_test('TC_DA_1_7', test_config)
310328

311-
failures_test_event_trigger = run_test(TestEventTriggersCheck, 'test_TestEventTriggersCheck', test_config)
329+
failures_test_event_trigger = run_test(TestEventTriggersCheck, ['test_TestEventTriggersCheck'], test_config)
312330

313-
failures_dcl_vendor = run_test(DclCheck, 'test_Vendor', test_config)
314-
failures_dcl_model = run_test(DclCheck, 'test_Model', test_config)
315-
failures_dcl_compliance = run_test(DclCheck, 'test_Compliance', test_config)
316-
failures_dcl_certified_model = run_test(DclCheck, 'test_CertifiedModel', test_config)
331+
failures_dcl = run_test(DclCheck, ['test_Vendor', 'test_Model', 'test_Compliance', 'test_CertifiedModel'], test_config)s
317332

318-
failures = failures_DA_1_2 + failures_DA_1_7 + failures_test_event_trigger
333+
failures = failures_DA_1_2 + failures_DA_1_7 + failures_test_event_trigger + failures_dcl
319334

320-
print('returning')
321335
print(failures)
322336
return 0
323337

324338

325339
if __name__ == "__main__":
326-
ret = main()
327-
print(f'ret = {ret}')
328-
if ret != 0:
329-
sys.exit(1)
340+
sys.exit(main())

0 commit comments

Comments
 (0)