mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-18 12:24:38 +08:00
[gdb/testsuite] Use unique portnum in parallel testing
When instrumenting get_portnum using: ... puts "PORTNUM: $res" ... and running: ... $ cd build/gdb $ make check-parallel -j2 TESTS=gdb.server/*.exp ... we run into: ... Running gdb.server/abspath.exp ... PORTNUM: 2345 ... and: ... Running gdb.server/bkpt-other-inferior.exp ... PORTNUM: 2345 ... This is because the test-cases are run in independent runtest invocations. Fix this by handling the parallel case in get_portnum using: - a file $objdir/cache/portnum to keep the portnum variable, and - a file $objdir/cache/portnum.lock to serialize access to it. Tested on aarch64-linux. Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
parent
a0a6e11019
commit
e82dca2a57
@ -141,18 +141,47 @@ proc get_portnum {} {
|
|||||||
# starting at $initial_portnum, to avoid conflicts with hung ports.
|
# starting at $initial_portnum, to avoid conflicts with hung ports.
|
||||||
set initial_portnum 2345
|
set initial_portnum 2345
|
||||||
|
|
||||||
# Currently available port number.
|
if { ![info exists ::GDB_PARALLEL] } {
|
||||||
gdb_persistent_global portnum
|
# Sequential case.
|
||||||
|
|
||||||
# Initialize, if necessary.
|
# Currently available port number.
|
||||||
if { ![info exists portnum] } {
|
gdb_persistent_global portnum
|
||||||
set portnum $initial_portnum
|
|
||||||
|
# Initialize, if necessary.
|
||||||
|
if { ![info exists portnum] } {
|
||||||
|
set portnum $initial_portnum
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return currently available port number, and update it.
|
||||||
|
set res $portnum
|
||||||
|
incr portnum
|
||||||
|
return $res
|
||||||
}
|
}
|
||||||
|
|
||||||
# Return currently available port number, and update it.
|
# Parallel case.
|
||||||
set res $portnum
|
with_lock portnum.lock {
|
||||||
incr portnum
|
# Keep portnum file alongside the lock that guards it.
|
||||||
return $res
|
set portnum_file [lock_dir]/portnum
|
||||||
|
|
||||||
|
if { [file exists $portnum_file] } {
|
||||||
|
set fd [open $portnum_file r]
|
||||||
|
set portnum [read $fd]
|
||||||
|
close $fd
|
||||||
|
|
||||||
|
set portnum [string trim $portnum]
|
||||||
|
} else {
|
||||||
|
# Initialize.
|
||||||
|
set portnum $initial_portnum
|
||||||
|
}
|
||||||
|
|
||||||
|
set next_portnum [expr $portnum + 1]
|
||||||
|
|
||||||
|
set fd [open $portnum_file w]
|
||||||
|
puts $fd $next_portnum
|
||||||
|
close $fd
|
||||||
|
}
|
||||||
|
|
||||||
|
return $portnum
|
||||||
}
|
}
|
||||||
|
|
||||||
# Locate the gdbserver binary. Returns "" if gdbserver could not be found.
|
# Locate the gdbserver binary. Returns "" if gdbserver could not be found.
|
||||||
|
Loading…
Reference in New Issue
Block a user