diff options
author | Andrew Burgess <aburgess@redhat.com> | 2023-11-24 11:10:08 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2023-11-28 10:23:19 +0000 |
commit | 1f0fab7ff86e03d4080dd3709ae76db4f0cb797d (patch) | |
tree | 898ded02b190e4cef0ce9c36fbccdcec5f721090 /gdb | |
parent | 640713c5a0831bb027684704c9304f999d452a43 (diff) | |
download | gdb-1f0fab7ff86e03d4080dd3709ae76db4f0cb797d.zip gdb-1f0fab7ff86e03d4080dd3709ae76db4f0cb797d.tar.gz gdb-1f0fab7ff86e03d4080dd3709ae76db4f0cb797d.tar.bz2 |
gdb/testsuite: small refactor in selftest-support.exp
Split out the code that makes a copy of the GDB executable ready for
self testing into a new proc. A later commit in this series wants to
load the GDB executable into GDB (for creating an on-disk debug
index), but doesn't need to make use of the full do_self_tests proc.
There should be no changes in what is tested after this commit.
Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/lib/selftest-support.exp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp index 1e7a2ce..abb1f43 100644 --- a/gdb/testsuite/lib/selftest-support.exp +++ b/gdb/testsuite/lib/selftest-support.exp @@ -92,11 +92,13 @@ proc selftest_setup { executable function } { return 0 } -# A simple way to run some self-tests. - -proc do_self_tests {function body} { - global GDB tool - +# Prepare for running a self-test by moving the GDB executable to a +# location where we can use it as the inferior. Return the filename +# of the new location. +# +# If the current testing setup is not suitable for running a +# self-test, then return an empty string. +proc selftest_prepare {} { # Are we testing with a remote board? In that case, the target # won't have access to the GDB's auxilliary data files # (data-directory, etc.). It's simpler to just skip. @@ -120,19 +122,31 @@ proc do_self_tests {function body} { # Run the test with self. Copy the file executable file in case # this OS doesn't like to edit its own text space. - set GDB_FULLPATH [find_gdb $GDB] + set gdb_fullpath [find_gdb $::GDB] if {[is_remote host]} { - set xgdb x$tool + set xgdb x$::tool } else { - set xgdb [standard_output_file x$tool] + set xgdb [standard_output_file x$::tool] } # Remove any old copy lying around. remote_file host delete $xgdb + set filename [remote_download host $gdb_fullpath $xgdb] + + return $filename +} + +# A simple way to run some self-tests. + +proc do_self_tests {function body} { + set file [selftest_prepare] + if { $file eq "" } { + return + } + gdb_start - set file [remote_download host $GDB_FULLPATH $xgdb] # When debugging GDB with GDB, some operations can take a relatively long # time, especially if the build is non-optimized. Bump the timeout for the |