@@ -123,6 +123,26 @@ def test_cache_handling(self):
123
123
for i in range (5 ):
124
124
self .run_to_bp_and_check (dbg .TARGET_STOP_REASON_BP , 'gpio_set_level' , ['gpio_set_level' ], outmost_func_name = 'cache_handling_task' )
125
125
126
+ def test_stub_logs (self ):
127
+ """
128
+ This test checks if stub logs are enabled successfully.
129
+ """
130
+ expected_strings = ["STUB_D: cmd 4:FLASH_MAP_GET" ,
131
+ "STUB_D: stub_flash_get_size: ENTER" ,
132
+ "STUB_I: Found app image: magic 0xe9" ]
133
+
134
+ self .gdb .monitor_run ("esp stub_log on" , 5 )
135
+ self .gdb .monitor_run ("flash probe 0" , 5 )
136
+ self .gdb .monitor_run ("esp stub_log off" , 5 )
137
+
138
+ log_path = get_logger ().handlers [1 ].baseFilename # 0:StreamHandler 1:FileHandler
139
+ target_output = ''
140
+ with open (log_path , 'r' ) as file :
141
+ target_output = file .read ()
142
+
143
+ for expected_str in expected_strings :
144
+ self .assertIn (expected_str , target_output , f"Expected string '{ expected_str } ' not found in output" )
145
+
126
146
def program_esp_bins (self , actions ):
127
147
# Temp Folder where everything will be contained
128
148
tmp = tempfile .mkdtemp (prefix = "esp" )
@@ -229,30 +249,6 @@ def generate_flasher_args_json():
229
249
}
230
250
231
251
232
- class StubTestsImpl :
233
-
234
- def test_stub_logs (self ):
235
- """
236
- This test checks if stub logs are enabled successfully.
237
- """
238
- expected_strings = ["STUB_D: cmd 4:FLASH_MAP_GET" ,
239
- "STUB_D: stub_flash_get_size: ENTER" ]
240
-
241
- self .gdb .monitor_run ("esp stub_log on" , 5 )
242
- self .gdb .monitor_run ("flash probe 0" , 5 )
243
- self .gdb .monitor_run ("esp stub_log off" , 5 )
244
-
245
- log_path = get_logger ().handlers [1 ].baseFilename # 0:StreamHandler 1:FileHandler
246
- found_line_count = 0
247
- with open (log_path ) as file :
248
- for line in file :
249
- for s in expected_strings :
250
- if s in line :
251
- found_line_count += 1
252
- # We expect at least len(expected_strings) for one core.
253
- self .assertTrue (found_line_count >= len (expected_strings ))
254
-
255
-
256
252
########################################################################
257
253
# TESTS DEFINITION WITH SPECIAL TESTS #
258
254
########################################################################
@@ -285,6 +281,32 @@ def setUp(self):
285
281
DebuggerGenericTestAppTestsSingleEncrypted .setUp (self )
286
282
FlasherTestsImpl .setUp (self )
287
283
288
- class StubTestsSingle (DebuggerGenericTestAppTestsSingle , StubTestsImpl ):
289
- def setUp (self ):
290
- DebuggerGenericTestAppTestsSingle .setUp (self )
284
+ @idf_ver_min ('latest' )
285
+ @only_for_chip (['esp32c6' , 'esp32h2' ])
286
+ class FlasherTestsPreloadedStubSingle (DebuggerGenericTestAppTestsSingle ):
287
+
288
+ def __init__ (self , methodName = 'runTest' ):
289
+ super (FlasherTestsPreloadedStubSingle , self ).__init__ (methodName )
290
+ self .test_app_cfg .bin_dir = os .path .join ('output' , 'single_core_preloaded_stub' )
291
+ self .test_app_cfg .build_dir = os .path .join ('builds' , 'single_core_preloaded_stub' )
292
+
293
+ def test_preloaded_stub_binary (self ):
294
+ """
295
+ This test checks if stub codes already loaded to the targets and functioning as expected
296
+ """
297
+ expected_strings = ["Stub flasher will be running from preloaded image (5C3A9F5A)" ,
298
+ "Flash mapping 0:" ,
299
+ "Flash mapping 1:" ]
300
+
301
+ target_output = ''
302
+ def _target_stream_handler (type , stream , payload ):
303
+ nonlocal target_output
304
+ target_output += payload
305
+ self .gdb .stream_handler_add ('target' , _target_stream_handler )
306
+
307
+ self .gdb .monitor_run ("esp stub_log off" , 5 )
308
+ self .gdb .monitor_run ("flash probe 0" , 5 )
309
+ self .gdb .stream_handler_remove ('target' , _target_stream_handler )
310
+
311
+ for expected_str in expected_strings :
312
+ self .assertIn (expected_str , target_output , f"Expected string '{ expected_str } ' not found in output" )
0 commit comments