22
22
from typing import Iterator , Set
23
23
24
24
from . import linux , runner
25
- from .test_definition import ApplicationPaths , TestDefinition , TestTarget
25
+ from .test_definition import ApplicationPaths , TestDefinition , TestRunTime , TestTag , TestTarget
26
26
27
27
_DEFAULT_CHIP_ROOT = os .path .abspath (
28
28
os .path .join (os .path .dirname (__file__ ), ".." , ".." , ".." ))
@@ -39,67 +39,118 @@ class ManualTest:
39
39
INVALID_TESTS = {
40
40
"tests.yaml" , # certification/tests.yaml is not a real test
41
41
"PICS.yaml" , # certification/PICS.yaml is not a real test
42
+
43
+ # The items below are examples and will never work (likely)
44
+ # completely exclude them
45
+ "Config_Example.yaml" ,
46
+ "Config_Variables_Example.yaml" ,
47
+ "PICS_Example.yaml" ,
48
+ "Response_Example.yaml" ,
49
+ "Test_Example.yaml" ,
42
50
}
43
51
44
52
45
- def _LoadManualTestsJson (json_file_path : str ) -> Iterator [ManualTest ]:
53
+ def _IsValidYamlTest (name : str ) -> bool :
54
+ """Check if the given file name is a valid YAML test.
55
+
56
+ This returns invalid for examples, simulated and other specific tests.
57
+ """
58
+
59
+ # Simulated tests are not runnable by repl tests, need
60
+ # separate infrastructure. Exclude them completely (they are
61
+ # not even manual)
62
+ if name .endswith ('_Simulated.yaml' ):
63
+ return False
64
+
65
+ return name not in INVALID_TESTS
66
+
67
+
68
+ def _LoadManualTestsJson (json_file_path : str ) -> Iterator [str ]:
46
69
with open (json_file_path , 'rt' ) as f :
47
70
data = json .load (f )
48
71
for c in data ["collection" ]:
49
72
for name in data [c ]:
50
- yield ManualTest ( yaml = "%s .yaml" % name , reason = json_file_path )
73
+ yield f" { name } .yaml"
51
74
52
75
53
- def _GetManualTests () -> Set [ManualTest ]:
76
+ def _GetManualTests () -> Set [str ]:
54
77
manualtests = set ()
55
78
56
- # TODO:
57
- #
58
- # These are NOT manual tests, but rather "tests that fail in yaml and
59
- # for this reason are marked as manual".
60
- #
61
- # We are working to get this list down to 0.
62
- manualtests .add (ManualTest (yaml = "Test_TC_ACL_2_10.yaml" , reason = "TODO Event Not Supported Yet" ))
63
- manualtests .add (ManualTest (yaml = "Test_TC_ACL_2_7.yaml" , reason = "TODO Event Not Supported Yet" ))
64
- manualtests .add (ManualTest (yaml = "Test_TC_ACL_2_8.yaml" , reason = "TODO Event Not Supported Yet" ))
65
- manualtests .add (ManualTest (yaml = "Test_TC_ACL_2_9.yaml" , reason = "TODO Event Not Supported Yet" ))
66
- manualtests .add (ManualTest (yaml = "TestEvents.yaml" , reason = "TODO Event Not Supported Yet" ))
67
-
68
- manualtests .add (ManualTest (yaml = "Test_TC_ACE_1_1.yaml" , reason = "TODO GetCommissionerNodeId Not Supported Yet" ))
69
- manualtests .add (ManualTest (yaml = "Test_TC_ACE_1_5.yaml" , reason = "TODO GetCommissionerNodeId Not Supported Yet" ))
70
- manualtests .add (ManualTest (yaml = "Test_TC_SC_5_1.yaml" , reason = "TODO GetCommissionerNodeId Not Supported Yet" ))
71
- manualtests .add (ManualTest (yaml = "Test_TC_SC_5_2.yaml" , reason = "TODO GetCommissionerNodeId Not Supported Yet" ))
72
- manualtests .add (ManualTest (yaml = "TestCommissionerNodeId.yaml" , reason = "TODO GetCommissionerNodeId Not Supported Yet" ))
73
-
74
- manualtests .add (ManualTest (yaml = "TestClusterMultiFabric.yaml" , reason = "TODO Enum Mismatch" ))
75
- manualtests .add (ManualTest (yaml = "TestGroupMessaging.yaml" , reason = "TODO Group Message Not Supported in chip-repl yet" ))
76
- manualtests .add (ManualTest (yaml = "TestMultiAdmin.yaml" , reason = "TODO chip-repl hangs on command expected to fail" ))
77
-
78
- # Failing, unclear why. Likely repl specific, used to pass however first
79
- # failure point seems unrelated. Historically this seems (very?) flaky
80
- # in repl.
81
- manualtests .add (ManualTest (yaml = "Test_TC_OO_2_4.yaml" , reason = "Flaky" ))
82
-
83
- # Examples:
84
- #
85
- # Currently these are not in ciTests.json, however yaml logic currently
86
- # does NOT use allowlist json but rather finds all yaml files.
87
- #
88
- # This is on purpose for now to make it harder to orphan files, however
89
- # we can reconsider as things evolve.
90
- manualtests .add (ManualTest (yaml = "Config_Example.yaml" , reason = "Example" ))
91
- manualtests .add (ManualTest (yaml = "Config_Variables_Example.yaml" , reason = "Example" ))
92
- manualtests .add (ManualTest (yaml = "PICS_Example.yaml" , reason = "Example" ))
93
- manualtests .add (ManualTest (yaml = "Response_Example.yaml" , reason = "Example" ))
94
- manualtests .add (ManualTest (yaml = "Test_Example.yaml" , reason = "Example" ))
95
-
96
79
# Flagged as manual from: src/app/tests/suites/manualTests.json
97
80
for item in _LoadManualTestsJson (os .path .join (_YAML_TEST_SUITE_PATH , "manualTests.json" )):
98
81
manualtests .add (item )
99
82
100
83
return manualtests
101
84
102
85
86
+ def _GetFlakyTests () -> Set [str ]:
87
+ """List of flaky tests, ideally this list should become empty."""
88
+ return {
89
+ "Test_TC_OO_2_4.yaml"
90
+ }
91
+
92
+
93
+ def _GetSlowTests () -> Set [str ]:
94
+ """Generally tests using sleep() a bit too freely.
95
+
96
+ 10s seems like a good threshold to consider something slow
97
+ """
98
+ return {
99
+ "DL_LockUnlock.yaml" , # ~ 10 seconds
100
+ "TestSubscribe_AdministratorCommissioning.yaml" , # ~ 15 seconds
101
+ "Test_TC_CC_5_1.yaml" , # ~ 30 seconds
102
+ "Test_TC_CC_5_2.yaml" , # ~ 30 seconds
103
+ "Test_TC_CC_5_3.yaml" , # ~ 25 seconds
104
+ "Test_TC_CC_6_1.yaml" , # ~ 35 seconds
105
+ "Test_TC_CC_6_2.yaml" , # ~ 60 seconds
106
+ "Test_TC_CC_6_3.yaml" , # ~ 50 seconds
107
+ "Test_TC_CC_7_2.yaml" , # ~ 65 seconds
108
+ "Test_TC_CC_7_3.yaml" , # ~ 70 seconds
109
+ "Test_TC_CC_7_4.yaml" , # ~ 25 seconds
110
+ "Test_TC_CC_8_1.yaml" , # ~ 60 seconds
111
+ "Test_TC_DRLK_2_4.yaml" , # ~ 60 seconds
112
+ "Test_TC_I_2_2.yaml" , # ~ 15 seconds
113
+ "Test_TC_LVL_3_1.yaml" , # ~ 35 seconds
114
+ "Test_TC_LVL_4_1.yaml" , # ~ 55 seconds
115
+ "Test_TC_LVL_5_1.yaml" , # ~ 35 seconds
116
+ "Test_TC_LVL_6_1.yaml" , # ~ 10 seconds
117
+ "Test_TC_WNCV_3_1.yaml" , # ~ 20 seconds
118
+ "Test_TC_WNCV_3_2.yaml" , # ~ 20 seconds
119
+ "Test_TC_WNCV_3_3.yaml" , # ~ 15 seconds
120
+ "Test_TC_WNCV_3_4.yaml" , # ~ 10 seconds
121
+ "Test_TC_WNCV_3_5.yaml" , # ~ 10 seconds
122
+ "Test_TC_WNCV_4_1.yaml" , # ~ 20 seconds
123
+ "Test_TC_WNCV_4_2.yaml" , # ~ 20 seconds
124
+ "Test_TC_WNCV_4_5.yaml" , # ~ 12 seconds
125
+ }
126
+
127
+
128
+ def _GetInDevelopmentTests () -> Set [str ]:
129
+ """Tests that fail in YAML for some reason.
130
+
131
+ Goal is for this set to become empty.
132
+ """
133
+ return {
134
+ # TODO: Event not yet supported:
135
+ "Test_TC_ACL_2_10.yaml" ,
136
+ "Test_TC_ACL_2_7.yaml" ,
137
+ "Test_TC_ACL_2_8.yaml" ,
138
+ "Test_TC_ACL_2_9.yaml" ,
139
+ "TestEvents.yaml" ,
140
+
141
+ # TODO: CommissionerNodeId not yet supported:
142
+ "Test_TC_ACE_1_1.yaml" ,
143
+ "Test_TC_ACE_1_5.yaml" ,
144
+ "Test_TC_SC_5_1.yaml" ,
145
+ "Test_TC_SC_5_2.yaml" ,
146
+ "TestCommissionerNodeId.yaml" ,
147
+
148
+ "TestClusterMultiFabric.yaml" , # Enum mismatch
149
+ "TestGroupMessaging.yaml" , # Needs group support in repl
150
+ "TestMultiAdmin.yaml" , # chip-repl hang on command expeted to fail
151
+ }
152
+
153
+
103
154
def _AllYamlTests ():
104
155
yaml_test_suite_path = Path (_YAML_TEST_SUITE_PATH )
105
156
@@ -111,12 +162,6 @@ def _AllYamlTests():
111
162
if not path .is_file ():
112
163
continue
113
164
114
- if path .name .endswith ('_Simulated.yaml' ):
115
- # Simulated tests are not runnable by repl tests, need
116
- # separate infrastructure. Exclude theml completely (they are
117
- # not even manual)
118
- continue
119
-
120
165
yield path
121
166
122
167
@@ -142,41 +187,60 @@ def tests_with_command(chip_tool: str, is_manual: bool):
142
187
143
188
result = subprocess .run ([chip_tool , "tests" , cmd ], capture_output = True )
144
189
190
+ test_tags = set ()
191
+ if is_manual :
192
+ test_tags .add (TestTag .MANUAL )
193
+
145
194
for name in result .stdout .decode ("utf8" ).split ("\n " ):
146
195
if not name :
147
196
continue
148
197
149
198
target = target_for_name (name )
150
199
151
200
yield TestDefinition (
152
- run_name = name , name = name , target = target , is_manual = is_manual
201
+ run_name = name , name = name , target = target , tags = test_tags
153
202
)
154
203
155
204
156
205
# TODO We will move away from hardcoded list of yamltests to run all file when yamltests
157
206
# parser/runner reaches parity with the code gen version.
158
207
def _hardcoded_python_yaml_tests ():
159
- manual_tests = set ([b .yaml for b in _GetManualTests ()])
208
+ manual_tests = _GetManualTests ()
209
+ flaky_tests = _GetFlakyTests ()
210
+ slow_tests = _GetSlowTests ()
211
+ in_development_tests = _GetInDevelopmentTests ()
160
212
161
213
for path in _AllYamlTests ():
162
- if path .name in INVALID_TESTS :
214
+ if not _IsValidYamlTest ( path .name ) :
163
215
continue
164
216
217
+ tags = set ()
218
+ if path .name in manual_tests :
219
+ tags .add (TestTag .MANUAL )
220
+
221
+ if path .name in flaky_tests :
222
+ tags .add (TestTag .FLAKY )
223
+
224
+ if path .name in slow_tests :
225
+ tags .add (TestTag .SLOW )
226
+
227
+ if path .name in in_development_tests :
228
+ tags .add (TestTag .IN_DEVELOPMENT )
229
+
165
230
yield TestDefinition (
166
231
run_name = str (path ),
167
232
name = path .stem , # `path.stem` converts "some/path/Test_ABC_1.2.yaml" to "Test_ABC.1.2"
168
233
target = target_for_name (path .name ),
169
- is_manual = path .name in manual_tests ,
170
- use_chip_repl_yaml_tester = True
234
+ tags = tags ,
171
235
)
172
236
173
237
174
- def AllTests (chip_tool : str , run_yamltests_with_chip_repl : bool ):
175
- if run_yamltests_with_chip_repl :
176
- for test in _hardcoded_python_yaml_tests ():
177
- yield test
178
- return
238
+ def AllYamlTests ():
239
+ for test in _hardcoded_python_yaml_tests ():
240
+ yield test
241
+
179
242
243
+ def AllChipToolTests (chip_tool : str ):
180
244
for test in tests_with_command (chip_tool , is_manual = False ):
181
245
yield test
182
246
0 commit comments