42
42
import sys
43
43
import time
44
44
import uuid
45
+ from dataclasses import dataclass
45
46
from enum import Enum , auto
46
47
from pathlib import Path
47
48
70
71
import fetch_paa_certs_from_dcl
71
72
72
73
74
+ @dataclass
75
+ class Failure :
76
+ test : str
77
+ step : str
78
+
79
+
73
80
class Hooks ():
74
81
def __init__ (self ):
75
82
self .failures = []
76
83
self .current_step = 'unknown'
84
+ self .current_test = 'unknown'
77
85
78
86
def start (self , count : int ):
79
87
pass
@@ -82,6 +90,7 @@ def stop(self, duration: int):
82
90
pass
83
91
84
92
def test_start (self , filename : str , name : str , count : int ):
93
+ self .current_test = name
85
94
pass
86
95
87
96
def test_stop (self , exception : Exception , duration : int ):
@@ -97,7 +106,7 @@ def step_success(self, logger, logs, duration: int, request):
97
106
pass
98
107
99
108
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 ) )
101
110
102
111
def step_unknown (self ):
103
112
pass
@@ -139,41 +148,50 @@ async def setup_class(self):
139
148
self .vid = await self .read_single_attribute_check_success (cluster = bi , attribute = bi .Attributes .VendorID )
140
149
self .pid = await self .read_single_attribute_check_success (cluster = bi , attribute = bi .Attributes .ProductID )
141
150
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
145
151
146
152
def steps_Vendor (self ):
147
153
return [TestStep (1 , "Check if device VID is listed in the DCL vendor schema" , "Listing found" )]
148
154
149
155
def test_Vendor (self ):
150
156
self .step (1 )
151
157
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 ]} ' )
153
162
154
163
def steps_Model (self ):
155
164
return [TestStep (1 , "Check if device VID/PID are listed in the DCL model schema" , "Listing found" )]
156
165
157
166
def test_Model (self ):
158
167
self .step (1 )
168
+ key = 'model'
159
169
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 ]} ' )
161
173
162
174
def steps_Compliance (self ):
163
175
return [TestStep (1 , "Check if device VID/PID/SoftwareVersion are listed in the DCL compliance info schema" , "Listing found" )]
164
176
165
177
def test_Compliance (self ):
166
178
self .step (1 )
179
+ key = 'complianceInfo'
167
180
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 ]} ' )
169
184
170
185
def steps_CertifiedModel (self ):
171
186
return [TestStep (1 , "Check if device VID/PID/SoftwareVersion are listed in the DCL certified model schema" , "Listing found" )]
172
187
173
188
def test_CertifiedModel (self ):
174
189
self .step (1 )
190
+ key = 'certifiedModel'
175
191
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 ]} ' )
177
195
178
196
179
197
def get_qr () -> str :
@@ -279,11 +297,11 @@ def __exit__(self, *args):
279
297
shutil .rmtree (self .cd_path )
280
298
281
299
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 ]:
283
301
hooks = Hooks ()
284
302
stack = test_config .get_stack ()
285
303
controller = test_config .get_controller ()
286
- matter_config = test_config .get_config ([ test_name ] )
304
+ matter_config = test_config .get_config (tests )
287
305
ok = run_tests_no_exit (test_class , matter_config , hooks , controller , stack )
288
306
if not ok :
289
307
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]:
297
315
# share a name, test is test_classname
298
316
module = importlib .import_module (test )
299
317
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 )
301
319
302
320
303
321
def main ():
@@ -308,22 +326,15 @@ def main():
308
326
# DA-1.7 is a test of the DAC chain (up to a PAA in the given directory)
309
327
failures_DA_1_7 = run_cert_test ('TC_DA_1_7' , test_config )
310
328
311
- failures_test_event_trigger = run_test (TestEventTriggersCheck , 'test_TestEventTriggersCheck' , test_config )
329
+ failures_test_event_trigger = run_test (TestEventTriggersCheck , [ 'test_TestEventTriggersCheck' ] , test_config )
312
330
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
317
332
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
319
334
320
- print ('returning' )
321
335
print (failures )
322
336
return 0
323
337
324
338
325
339
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