From a1b18f468d7bb8ea5726291d8d38d536c9629c27 Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Thu, 5 Oct 2023 14:12:52 +0400 Subject: [PATCH] simesp: add qemu execution retries --- gdb/testsuite/boards/simesp.exp | 49 +++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/gdb/testsuite/boards/simesp.exp b/gdb/testsuite/boards/simesp.exp index 5d06ff80e937..4ec99aed5daa 100644 --- a/gdb/testsuite/boards/simesp.exp +++ b/gdb/testsuite/boards/simesp.exp @@ -42,6 +42,7 @@ proc init_simulator { file } { global simesp_spawn_id global simesp_cpu global simesp_path + global timeout if { $file == "" } { set file $simesp_last_load_file @@ -62,28 +63,34 @@ proc init_simulator { file } { set simesp_spawn_id "" } - # Run simesp. set cmd "spawn -noecho ${simesp_path} -nographic -monitor null -cpu ${simesp_cpu} -M ${simesp_cpu} -m 4M -S -s -kernel ${file} -d trace:gdbstub_op_start -semihosting" - verbose -log "Spawning simesp: $cmd" - eval $cmd - set simesp_spawn_id $spawn_id - - expect { - -i $simesp_spawn_id -re ".*Starting gdbstub using device.*1234" {} - timeout { - verbose -log "simesp: timeout, closing simesp spawn id" - close -i $simesp_spawn_id - verbose -log "simesp: timeout, waiting for simesp process exit" - wait -i $simesp_spawn_id - set simesp_spawn_id "" - error "unable to start simesp: timeout" - } - eof { - verbose -log "simesp: eof, waiting for simesp process exit" - wait -i $simesp_spawn_id - set simesp_spawn_id "" - error "unable to start simesp: eof" - } + verbose -log "Spawning simesp (timeout $timeout): $cmd" + for {set i 0} {$i < 10} {incr i} { + # Run simesp. + verbose -log "try to execute simesp: $i" + eval $cmd + set simesp_spawn_id $spawn_id + expect { + -i $simesp_spawn_id -re "::1234" {} + timeout { + verbose -log "simesp: timeout, closing simesp spawn id" + close -i $simesp_spawn_id + verbose -log "simesp: timeout, waiting for simesp process exit" + wait -i $simesp_spawn_id + set simesp_spawn_id "" + verbose -log "unable to start simesp: timeout" + continue + } + eof { + verbose -log "simesp: eof, waiting for simesp process exit" + wait -i $simesp_spawn_id + set simesp_spawn_id "" + verbose -log "unable to start simesp: eof" + continue + } + } + verbose -log "simesp: executed ok" + break } verbose -log "simesp: simesp spawned with spawn id $simesp_spawn_id, pid [exp_pid $simesp_spawn_id]" return 0