Skip to content

Commit

Permalink
simesp: add qemu execution retries
Browse files Browse the repository at this point in the history
  • Loading branch information
Lapshin committed Oct 23, 2023
1 parent 3c7f5b6 commit a1b18f4
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions gdb/testsuite/boards/simesp.exp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a1b18f4

Please sign in to comment.