Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 3/7] test suite update - gdb.base/[efg]
  2013-06-19 21:04 [PATCH 0/7] first batch of test suite updates Tom Tromey
                   ` (2 preceding siblings ...)
  2013-06-19 21:04 ` [PATCH 7/7] test suite update - gdb.base/[t-z] Tom Tromey
@ 2013-06-19 21:04 ` Tom Tromey
  2013-06-19 21:04 ` [PATCH 4/7] test suite update - gdb.base/[hijklm] Tom Tromey
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Tom Tromey @ 2013-06-19 21:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Files gdb.base/[efg]*.exp.
See message #0 for details.

	* ena-dis-br.exp, enum_cond.exp, enumval.exp, environ.exp,
	eu-strip-infcall.exp, eval-skip.exp, exe-lock.exp,
	expand-psymtabs.exp, exprs.exp, fileio.exp, find.exp,
	fixsection.exp, foll-exec.exp, foll-fork.exp,
	fortran-sym-case.exp, frame-args.exp, freebpcmd.exp, fullname.exp,
	funcargs.exp, gcore-buffer-overflow.exp, gcore.exp, gdb1090.exp,
	gdb11530.exp, gdb11531.exp, gdb1250.exp, gdb1555.exp, gdb1821.exp,
	gdbindex-stabs.exp, gdbvars.exp, gnu-ifunc.exp, gnu_vector.exp:
	Use standard_testfile, standard_output_file, prepare_for_testing,
	clean_restart.
---
 gdb/testsuite/gdb.base/ena-dis-br.exp            | 42 +++++++-----------------
 gdb/testsuite/gdb.base/enum_cond.exp             |  4 +--
 gdb/testsuite/gdb.base/enumval.exp               |  7 ++--
 gdb/testsuite/gdb.base/environ.exp               | 25 +++-----------
 gdb/testsuite/gdb.base/eu-strip-infcall.exp      |  3 +-
 gdb/testsuite/gdb.base/eval-skip.exp             |  9 ++---
 gdb/testsuite/gdb.base/exe-lock.exp              | 10 ++----
 gdb/testsuite/gdb.base/expand-psymtabs.exp       | 29 ++++------------
 gdb/testsuite/gdb.base/exprs.exp                 | 10 ++----
 gdb/testsuite/gdb.base/fileio.exp                |  4 +--
 gdb/testsuite/gdb.base/find.exp                  |  9 ++---
 gdb/testsuite/gdb.base/fixsection.exp            |  9 +++--
 gdb/testsuite/gdb.base/foll-exec.exp             |  7 ++--
 gdb/testsuite/gdb.base/foll-fork.exp             | 20 +++--------
 gdb/testsuite/gdb.base/fortran-sym-case.exp      |  3 +-
 gdb/testsuite/gdb.base/frame-args.exp            |  9 ++---
 gdb/testsuite/gdb.base/freebpcmd.exp             | 16 +++------
 gdb/testsuite/gdb.base/fullname.exp              | 23 +++++++------
 gdb/testsuite/gdb.base/funcargs.exp              | 21 ++++--------
 gdb/testsuite/gdb.base/gcore-buffer-overflow.exp | 12 +++----
 gdb/testsuite/gdb.base/gcore.exp                 | 19 +++--------
 gdb/testsuite/gdb.base/gdb1090.exp               | 15 +++------
 gdb/testsuite/gdb.base/gdb11530.exp              |  3 +-
 gdb/testsuite/gdb.base/gdb11531.exp              |  2 +-
 gdb/testsuite/gdb.base/gdb1250.exp               |  9 ++---
 gdb/testsuite/gdb.base/gdb1555.exp               | 13 +++-----
 gdb/testsuite/gdb.base/gdb1821.exp               | 13 +++-----
 gdb/testsuite/gdb.base/gdbindex-stabs.exp        | 10 +++---
 gdb/testsuite/gdb.base/gdbvars.exp               | 15 ++-------
 gdb/testsuite/gdb.base/gnu-ifunc.exp             | 10 +++---
 gdb/testsuite/gdb.base/gnu_vector.exp            |  4 +--
 31 files changed, 112 insertions(+), 273 deletions(-)

diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp
index b08b709..0c4f9d4 100644
--- a/gdb/testsuite/gdb.base/ena-dis-br.exp
+++ b/gdb/testsuite/gdb.base/ena-dis-br.exp
@@ -19,42 +19,24 @@
 # test running programs
 #
 
-set testfile "break"
-set srcfile ${testfile}.c
-set srcfile1 ${testfile}1.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
-     untested ena-dis-br.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
-     untested ena-dis-br.exp
-     return -1
-}
+standard_testfile break.c break1.c
 
-if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
-     untested ena-dis-br.exp
-     return -1
+if {[prepare_for_testing ${testfile}.exp ${testfile} \
+	 [list $srcfile $srcfile2] {debug nowarnings}]} {
+    return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
 set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
-set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
-set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1]
+set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile2]
+set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile2]
 set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
-set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1]
-set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1]
-set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile1]
-set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile1]
-set bp_location17 [gdb_get_line_number "set breakpoint 17 here" $srcfile1]
-set bp_location18 [gdb_get_line_number "set breakpoint 18 here" $srcfile1]
+set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile2]
+set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile2]
+set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile2]
+set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile2]
+set bp_location17 [gdb_get_line_number "set breakpoint 17 here" $srcfile2]
+set bp_location18 [gdb_get_line_number "set breakpoint 18 here" $srcfile2]
 
 if ![runto_main] then { fail "enable/disable break tests suppressed" }
 
diff --git a/gdb/testsuite/gdb.base/enum_cond.exp b/gdb/testsuite/gdb.base/enum_cond.exp
index 6ed8a65..6c5d588 100644
--- a/gdb/testsuite/gdb.base/enum_cond.exp
+++ b/gdb/testsuite/gdb.base/enum_cond.exp
@@ -17,9 +17,7 @@
 # gdb can correctly print arrays with indexes for each element of the
 # array.
 
-set testfile "enum_cond"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 set opts [list debug additional_flags=-fshort-enums]
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } {
diff --git a/gdb/testsuite/gdb.base/enumval.exp b/gdb/testsuite/gdb.base/enumval.exp
index 7f80ab3..e0964fc 100644
--- a/gdb/testsuite/gdb.base/enumval.exp
+++ b/gdb/testsuite/gdb.base/enumval.exp
@@ -15,11 +15,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "enumval"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if { [prepare_for_testing enumval.exp "enumval" "" {debug}] } {
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/environ.exp b/gdb/testsuite/gdb.base/environ.exp
index 2e171fb..b5a9b2d 100644
--- a/gdb/testsuite/gdb.base/environ.exp
+++ b/gdb/testsuite/gdb.base/environ.exp
@@ -24,31 +24,14 @@ if ![istarget "hppa*-*-hpux*"] then {
   return
 }
 
-set testfile "break"
-set srcfile ${testfile}.c
-set srcfile1 ${testfile}1.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile break.c break1.c
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
-    untested environ.exp
+if {[prepare_for_testing $testfile.exp $testfile \
+	 [list $srcfile $srcfile2] {debug nowarnings}]} {
+    untested $testfile.exp
     return -1
 }
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
-    untested environ.exp
-    return -1
-}
-
-if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
-    untested environ.exp
-    return -1
-}
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 if ![runto_main] then { fail "environment command tests suppressed" }
 
 # (No, this is not really related to the environment commands.  But it's
diff --git a/gdb/testsuite/gdb.base/eu-strip-infcall.exp b/gdb/testsuite/gdb.base/eu-strip-infcall.exp
index 0db1daa..a325668 100644
--- a/gdb/testsuite/gdb.base/eu-strip-infcall.exp
+++ b/gdb/testsuite/gdb.base/eu-strip-infcall.exp
@@ -13,8 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile eu-strip-infcall
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 if {[build_executable ${testfile}.exp $testfile] == -1} {
     return -1
diff --git a/gdb/testsuite/gdb.base/eval-skip.exp b/gdb/testsuite/gdb.base/eval-skip.exp
index ee99577..28cfa10 100644
--- a/gdb/testsuite/gdb.base/eval-skip.exp
+++ b/gdb/testsuite/gdb.base/eval-skip.exp
@@ -32,9 +32,7 @@
 # haven't tried to compile one, or the compilation failed for some reason.
 # In either case, just notify the user and skip the tests in this file.
 
-set testfile "int-type"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile int-type.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
      untested eval-skip.exp
@@ -45,10 +43,7 @@ if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 
 if ![runto_main] then {
diff --git a/gdb/testsuite/gdb.base/exe-lock.exp b/gdb/testsuite/gdb.base/exe-lock.exp
index 5c6a5d0..6bbef36 100644
--- a/gdb/testsuite/gdb.base/exe-lock.exp
+++ b/gdb/testsuite/gdb.base/exe-lock.exp
@@ -17,21 +17,17 @@
 # a filesystem lock on the executable file once the executable
 # is no longer running.
 
-set testfile "arrayidx"
-set srcfile ${testfile}.c
+standard_testfile arrayidx.c
 # $EXEEXT suffix is needed here, because otherwise, Windows targets
 # don't find the $binfile for 'file delete $binfile'.
-set binfile ${objdir}/${subdir}/${testfile}$EXEEXT
+append binfile $EXEEXT
 
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested "Couldn't compile ${srcfile}"
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 # Sanity-check: Verify that the executable exists. This is just to
 # make sure that, when we verify later that the file does not exist,
diff --git a/gdb/testsuite/gdb.base/expand-psymtabs.exp b/gdb/testsuite/gdb.base/expand-psymtabs.exp
index 4c6dc14..030f992 100644
--- a/gdb/testsuite/gdb.base/expand-psymtabs.exp
+++ b/gdb/testsuite/gdb.base/expand-psymtabs.exp
@@ -29,37 +29,20 @@
 # reading in effect, GDB can set breakpoints by line number
 # successfully in either compilation unit.  
 
-set testfile expand-psymtabs
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-set binfile_1 ${objdir}/${subdir}/${testfile}_1.o
-set binfile_2 ${objdir}/${subdir}/${testfile}_2.o
+standard_testfile
 
 # What compiler are we using?
 if [get_compiler_info] {
     return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_1}" object {debug additional_flags=-DFIRST} ] != "" } {
-     untested expand-psymtabs.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile_2}" object {debug}] != "" } {
-     untested expand-psymtabs.exp
-     return -1
-}
-
-if  { [gdb_compile "${binfile_1} ${binfile_2}" "${binfile}" executable {debug}] != "" } {
-     untested expand-psymtabs.exp
-     return -1
+# We intentionally compile the source file in twice.
+if {[prepare_for_testing_full $testfile.exp \
+	 [list $testfile debug $srcfile {debug additional_flags=-DFIRST} \
+	      $srcfile debug]]} {
+    return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 set foo_bp [gdb_get_line_number "Break here"]
 gdb_test "break $foo_bp" "Breakpoint.*" "Expand psymtabs"
 
diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/exprs.exp
index 8ef42a4..2a5ee5c 100644
--- a/gdb/testsuite/gdb.base/exprs.exp
+++ b/gdb/testsuite/gdb.base/exprs.exp
@@ -19,9 +19,8 @@
 # test running programs
 #
 
-set testfile "exprs"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested exprs.exp
      return -1
@@ -31,10 +30,7 @@ if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 #
 # set it up at a breakpoint so we can play with the variable values
diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp
index c93913e..ded043f 100644
--- a/gdb/testsuite/gdb.base/fileio.exp
+++ b/gdb/testsuite/gdb.base/fileio.exp
@@ -21,9 +21,7 @@ if [target_info exists gdb,nofileio] {
 }
 
 
-set testfile "fileio"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested fileio.exp
diff --git a/gdb/testsuite/gdb.base/find.exp b/gdb/testsuite/gdb.base/find.exp
index 9e6bd69..0de9fad 100644
--- a/gdb/testsuite/gdb.base/find.exp
+++ b/gdb/testsuite/gdb.base/find.exp
@@ -15,19 +15,14 @@
 
 # This tests the find command.
 
-set testfile "find"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
     untested find.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 gdb_test "break $srcfile:stop_here" \
     "Breakpoint.*at.* file .*$srcfile, line.*" \
diff --git a/gdb/testsuite/gdb.base/fixsection.exp b/gdb/testsuite/gdb.base/fixsection.exp
index 99871f9..74cd196 100644
--- a/gdb/testsuite/gdb.base/fixsection.exp
+++ b/gdb/testsuite/gdb.base/fixsection.exp
@@ -18,13 +18,11 @@ if {[skip_shlib_tests]} {
     return 0
 }
 
-set testfile "fixsection"
-set srcfile ${srcdir}/${subdir}/${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 set libfile "fixsectshr"
 set libsrc ${srcdir}/${subdir}/${libfile}.c
-set lib_sl ${objdir}/${subdir}/${libfile}.sl
+set lib_sl [standard_output_file ${libfile}.sl]
 
 set lib_opts [list debug nowarnings]
 set exec_opts [list debug nowarnings shlib=$lib_sl]
@@ -34,7 +32,8 @@ if [get_compiler_info] {
 }
 
 if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
-     || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} {
+     || [gdb_compile $srcdir/$subdir/$srcfile $binfile \
+	     executable $exec_opts] != ""} {
     untested "Could not compile either $libsrc or $srcfile."
     return -1
 }
diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp
index 9b04ddd..9456f42 100644
--- a/gdb/testsuite/gdb.base/foll-exec.exp
+++ b/gdb/testsuite/gdb.base/foll-exec.exp
@@ -23,12 +23,11 @@ if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
     continue
 }
 
-set testfile "foll-exec"
+standard_testfile foll-exec.c
+
 set testfile2 "execd-prog"
-set srcfile ${testfile}.c
 set srcfile2 ${testfile2}.c
-set binfile ${objdir}/${subdir}/${testfile}
-set binfile2 ${objdir}/${subdir}/${testfile2}
+set binfile2 [standard_output_file ${testfile2}]
 
 # build the first test case
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } {
diff --git a/gdb/testsuite/gdb.base/foll-fork.exp b/gdb/testsuite/gdb.base/foll-fork.exp
index 9fe5e9b..e9a0d30 100644
--- a/gdb/testsuite/gdb.base/foll-fork.exp
+++ b/gdb/testsuite/gdb.base/foll-fork.exp
@@ -24,14 +24,11 @@ if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
     continue
 }
 
-global srcfile
-set testfile "foll-fork"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested foll-fork.exp
-     return -1
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
 }
 
 proc check_fork_catchpoints {} {
@@ -331,13 +328,6 @@ By default, the debugger will follow the parent process..*" \
     if [runto_main] then { tcatch_fork_parent_follow }
 }
 
-# Start with a fresh gdb
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # The "Detaching..." and "Attaching..." messages may be hidden by
 # default.
 gdb_test_no_output "set verbose"
diff --git a/gdb/testsuite/gdb.base/fortran-sym-case.exp b/gdb/testsuite/gdb.base/fortran-sym-case.exp
index 71a38cc..1de6d22 100644
--- a/gdb/testsuite/gdb.base/fortran-sym-case.exp
+++ b/gdb/testsuite/gdb.base/fortran-sym-case.exp
@@ -13,7 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile fortran-sym-case
+standard_testfile .c
+
 if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
     return -1
 }
diff --git a/gdb/testsuite/gdb.base/frame-args.exp b/gdb/testsuite/gdb.base/frame-args.exp
index 9786897..ac67fa6 100644
--- a/gdb/testsuite/gdb.base/frame-args.exp
+++ b/gdb/testsuite/gdb.base/frame-args.exp
@@ -13,18 +13,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "frame-args"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested "Couldn't compile ${srcfile}"
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto break_me] then {
   perror "Couldn't run ${testfile}"
diff --git a/gdb/testsuite/gdb.base/freebpcmd.exp b/gdb/testsuite/gdb.base/freebpcmd.exp
index fc2fe2d..2596786 100644
--- a/gdb/testsuite/gdb.base/freebpcmd.exp
+++ b/gdb/testsuite/gdb.base/freebpcmd.exp
@@ -44,20 +44,12 @@
 # suggestions for improving this.
 
 
-set testfile "freebpcmd"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested freebpcmd.exp
-     return -1
+standard_testfile
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test "break ${srcfile}:[gdb_get_line_number "euphonium"]" ".*" \
     "set breakpoint"
 
diff --git a/gdb/testsuite/gdb.base/fullname.exp b/gdb/testsuite/gdb.base/fullname.exp
index d208b7a..32f6ea4 100644
--- a/gdb/testsuite/gdb.base/fullname.exp
+++ b/gdb/testsuite/gdb.base/fullname.exp
@@ -16,9 +16,7 @@
 # This file tests setting breakpoints according to the full path of a
 # source file.
 
-set testfile "fullname"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 # We rely on being able to copy things around.
 
@@ -30,13 +28,13 @@ if { [is_remote host] } {
 # Create a temporary file in the build directory.  Use a different
 # filename in case ${srcdir} == ${objdir}.
 if { [catch {file copy -force ${srcdir}/${subdir}/${srcfile} \
-			      ${objdir}/${subdir}/tmp-${srcfile}}] != 0 } {
+			      [standard_output_file tmp-${srcfile}]}] != 0 } {
     error "Could not create temporary file"
     return -1
 }
 
 # Build the test executable using an absolute path.
-if  { [gdb_compile "${objdir}/${subdir}/tmp-${srcfile}" "${binfile}" executable {debug}] != "" } {
+if  { [gdb_compile [standard_output_file tmp-${srcfile}] "${binfile}" executable {debug}] != "" } {
     return -1
 }
 
@@ -55,7 +53,7 @@ gdb_start
 gdb_load ${binfile}
 
 set msg "set breakpoint by full path before loading symbols - built absolute"
-if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
     pass $msg
 } else {
     fail $msg
@@ -65,7 +63,7 @@ gdb_test "break main" \
 	 "Breakpoint.*at.*line.*" "set breakpoint at main - built absolute"
 
 set msg "set breakpoint by full path after loading symbols - built absolute"
-if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
     pass $msg
 } else {
     fail $msg
@@ -81,7 +79,7 @@ gdb_start
 gdb_load ${binfile}
 
 set msg "set breakpoint by full path before loading symbols - built relative"
-if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
     pass $msg
 } else {
     fail $msg
@@ -91,7 +89,7 @@ gdb_test "break main" \
 	 "Breakpoint.*at.*line.*" "set breakpoint at main - built relative"
 
 set msg "set breakpoint by full path after loading symbols - built relative"
-if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
     pass $msg
 } else {
     fail $msg
@@ -102,7 +100,8 @@ if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] !=
 
 set save_pwd [pwd]
 cd ${subdir}
-if  { [gdb_compile "tmp-${srcfile}" "${testfile}" executable {debug}] != "" } {
+if  { [gdb_compile [standard_output_file tmp-${srcfile}] "${testfile}" \
+	   executable {debug}] != "" } {
     cd $save_pwd
     return -1
 }
@@ -113,7 +112,7 @@ gdb_start
 gdb_load ${binfile}
 
 set msg "set breakpoint by full path before loading symbols - built other"
-if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
     pass $msg
 } else {
     fail $msg
@@ -123,7 +122,7 @@ gdb_test "break main" \
 	 "Breakpoint.*at.*line.*" "set breakpoint at main - built other"
 
 set msg "set breakpoint by full path after loading symbols - built other"
-if { [gdb_breakpoint ${objdir}/${subdir}/tmp-${srcfile}:${line} {no-message}] != 0 } {
+if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
     pass $msg
 } else {
     fail $msg
diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp
index 2b89d14..d1b3f5a 100644
--- a/gdb/testsuite/gdb.base/funcargs.exp
+++ b/gdb/testsuite/gdb.base/funcargs.exp
@@ -16,26 +16,24 @@
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
 
-set testfile "funcargs"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 set compile_flags {debug nowarnings quiet}
 if [support_complex_tests] {
     lappend compile_flags "additional_flags=-DTEST_COMPLEX"
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_flags] != "" } {
-     untested funcargs.exp
-     return -1
-}
-
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
 if [get_compiler_info] {
     return -1
 }
 
+if {[prepare_for_testing $testfile.exp $testfile $srcfile $compile_flags]} {
+    untested $testfile.exp
+    return -1
+}
+
 #
 # Locate actual args; integral types.
 #
@@ -1159,13 +1157,6 @@ proc test_stepping_over_trampolines { } {
     gdb_stop_suppressing_tests
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 set prev_timeout $timeout
 if [istarget "mips*tx39-*"] {
     set timeout 300
diff --git a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
index 7bb3ba8..8d0867e 100644
--- a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
+++ b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
@@ -16,12 +16,11 @@
 # Test GDB's internal buffers safety for the GCORE command.
 
 
-set testfile "gcore-buffer-overflow"
-set srcfile  ${testfile}.c
+standard_testfile .c
 # The ${binfile} basename needs to exceed 80 characters (`sizeof (psargs)')
 # plus some additional data to overwrite the stack frame.
 set pattern  01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
-set binfile  ${objdir}/${subdir}/${testfile}-${pattern}
+append binfile -${pattern}
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested ${testfile}.exp
@@ -30,10 +29,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 # Does this gdb support gcore?
 gdb_test_multiple "help gcore" "help gcore" {
@@ -55,4 +51,4 @@ if { ! [ runto_main ] } then {
     return -1
 }
 
-gdb_gcore_cmd "${objdir}/${subdir}/gcore-buffer-overflow.test" "save a corefile"
+gdb_gcore_cmd [standard_testfile gcore-buffer-overflow.test] "save a corefile"
diff --git a/gdb/testsuite/gdb.base/gcore.exp b/gdb/testsuite/gdb.base/gcore.exp
index 68fd874..0807a60 100644
--- a/gdb/testsuite/gdb.base/gcore.exp
+++ b/gdb/testsuite/gdb.base/gcore.exp
@@ -17,22 +17,13 @@
 # This is a test for the gdb command "generate-core-file".
 
 
-set testfile "gcore"
-set srcfile  ${testfile}.c
-set binfile  ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested gcore.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # Does this gdb support gcore?
 gdb_test_multiple "help gcore" "help gcore" {
     -re "Undefined command: .gcore.*$gdb_prompt $" {
@@ -86,7 +77,7 @@ set pre_corefile_local_array \
 set pre_corefile_extern_array \
 	[capture_command_output "print extern_array" "$print_prefix"]
 
-set corefile "${objdir}/${subdir}/gcore.test"
+set corefile [standard_output_file gcore.test]
 set core_supported [gdb_gcore_cmd "$corefile" "save a corefile"]
 if {!$core_supported} {
   return -1
diff --git a/gdb/testsuite/gdb.base/gdb1090.exp b/gdb/testsuite/gdb.base/gdb1090.exp
index 9f693b0..c4e5f59 100644
--- a/gdb/testsuite/gdb.base/gdb1090.exp
+++ b/gdb/testsuite/gdb.base/gdb1090.exp
@@ -22,20 +22,13 @@
 # test running programs
 #
 
-set testfile "gdb1090"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested gdb1090.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 if ![runto_main] then {
     fail "Can't run to main"
     return 1
diff --git a/gdb/testsuite/gdb.base/gdb11530.exp b/gdb/testsuite/gdb.base/gdb11530.exp
index 09e69a1..5f80fce 100644
--- a/gdb/testsuite/gdb.base/gdb11530.exp
+++ b/gdb/testsuite/gdb.base/gdb11530.exp
@@ -18,8 +18,7 @@
 # Test GDB bug report 11530.
 # This is a problem related unnamed unions.
 
-set testfile "gdb11530"
-set binfile ${testfile}${EXEEXT}
+standard_testfile
 
 # Unnamed union is a GNU extension, thus we restrict the test
 # to gcc compiler.
diff --git a/gdb/testsuite/gdb.base/gdb11531.exp b/gdb/testsuite/gdb.base/gdb11531.exp
index cf0678b..a0087d7 100644
--- a/gdb/testsuite/gdb.base/gdb11531.exp
+++ b/gdb/testsuite/gdb.base/gdb11531.exp
@@ -20,7 +20,7 @@
 # It affects Solaris native targets.
 
 
-set testfile "gdb11531"
+standard_testfile
 
 if { [prepare_for_testing $testfile.exp $testfile $testfile.c {debug}] } {
     return -1
diff --git a/gdb/testsuite/gdb.base/gdb1250.exp b/gdb/testsuite/gdb.base/gdb1250.exp
index 35adc2c..c12e908 100644
--- a/gdb/testsuite/gdb.base/gdb1250.exp
+++ b/gdb/testsuite/gdb.base/gdb1250.exp
@@ -22,19 +22,14 @@
 # test running programs
 #
 
-set testfile "gdb1250"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested gdb1250.exp
      return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto abort {allow-pending}] then {
     continue
diff --git a/gdb/testsuite/gdb.base/gdb1555.exp b/gdb/testsuite/gdb.base/gdb1555.exp
index a74a642..32a7ab8 100644
--- a/gdb/testsuite/gdb.base/gdb1555.exp
+++ b/gdb/testsuite/gdb.base/gdb1555.exp
@@ -21,13 +21,11 @@ if {[skip_shlib_tests]} {
     return 0
 }
 
-set testfile gdb1555-main
-set libfile gdb1555
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile gdb1555-main.c gdb1555.c
 
+set libfile gdb1555
 set libsrc "${srcdir}/${subdir}/${libfile}.c"
-set libobj "${objdir}/${subdir}/${libfile}.so"
+set libobj [standard_output_file ${libfile}.so]
 set execsrc "${srcdir}/${subdir}/${srcfile}"
 
 remote_exec build "rm -f ${binfile}"
@@ -43,10 +41,7 @@ if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 gdb_load_shlibs $libobj
 
 if ![runto_main] then {
diff --git a/gdb/testsuite/gdb.base/gdb1821.exp b/gdb/testsuite/gdb.base/gdb1821.exp
index 00d910f..6e0fc1a 100644
--- a/gdb/testsuite/gdb.base/gdb1821.exp
+++ b/gdb/testsuite/gdb.base/gdb1821.exp
@@ -22,18 +22,13 @@
 # test running programs
 #
 
-set testfile "gdb1821"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
 }
 
-gdb_exit
-gdb_start
-gdb_load ${binfile}
-
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
     continue
diff --git a/gdb/testsuite/gdb.base/gdbindex-stabs.exp b/gdb/testsuite/gdb.base/gdbindex-stabs.exp
index 38ea4a9..f0c59bd 100644
--- a/gdb/testsuite/gdb.base/gdbindex-stabs.exp
+++ b/gdb/testsuite/gdb.base/gdbindex-stabs.exp
@@ -15,13 +15,11 @@
 
 # This problem is reproducible only when using `gdb/cc-with-index.sh'.
 
-set testfile gdbindex-stabs
-set executable ${testfile}
-set binfile ${objdir}/${subdir}/${executable}
+standard_testfile gdbindex-stabs.c
 set srcfile_stabs ${testfile}.c
 set srcfile_dwarf ${testfile}-dwarf.c
-set objfile_stabs ${testfile}.o
-set objfile_dwarf ${testfile}-dwarf.o
+set objfile_stabs [standard_output_file ${testfile}.o]
+set objfile_dwarf [standard_output_file ${testfile}-dwarf.o]
 
 if {[gdb_compile "${srcdir}/${subdir}/${srcfile_stabs}" ${objfile_stabs} object {additional_flags=-gstabs}] != ""
     || [gdb_compile "${srcdir}/${subdir}/${srcfile_dwarf}" ${objfile_dwarf} object {additional_flags=-gdwarf-2}] != ""
@@ -30,7 +28,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile_stabs}" ${objfile_stabs} object
      return -1
 }
 
-clean_restart ${executable}
+clean_restart ${binfile}
 
 # FAIL was: No line number known for stabs_function.
 gdb_test "list stabs_function" " marker-here .*"
diff --git a/gdb/testsuite/gdb.base/gdbvars.exp b/gdb/testsuite/gdb.base/gdbvars.exp
index da41f7e..23a6758 100644
--- a/gdb/testsuite/gdb.base/gdbvars.exp
+++ b/gdb/testsuite/gdb.base/gdbvars.exp
@@ -16,12 +16,10 @@
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
 
-set testfile "gdbvars"
-set srcfile  ${testfile}.c
-set binfile  ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested gdbvars.exp
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
@@ -112,13 +110,6 @@ proc test_with_program {} {
 	"Print contents of new convenience variable of program variable"
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test_no_output "set print sevenbit-strings"
 
 test_value_history
diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.exp b/gdb/testsuite/gdb.base/gnu-ifunc.exp
index 417ec0a..6a61f57 100644
--- a/gdb/testsuite/gdb.base/gnu-ifunc.exp
+++ b/gdb/testsuite/gdb.base/gnu-ifunc.exp
@@ -17,18 +17,16 @@ if {[skip_shlib_tests]} {
     return 0
 }
 
-set testfile "gnu-ifunc"
+standard_testfile .c
 set executable ${testfile}
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${executable}
 set staticexecutable ${executable}-static
-set staticbinfile ${objdir}/${subdir}/${staticexecutable}
+set staticbinfile [standard_output_file ${staticexecutable}]
 
 set libfile "${testfile}-lib"
 set libsrc ${libfile}.c
-set lib_so ${objdir}/${subdir}/${libfile}.so
+set lib_so [standard_output_file ${libfile}.so]
 # $lib_o must not have {debug}, it would override the STT_GNU_IFUNC ELF markers.
-set lib_o ${objdir}/${subdir}/${libfile}.o
+set lib_o [standard_output_file ${libfile}.o]
 
 # We need DWARF for the "final" function as we "step" into the function and GDB
 # would step-over the "final" function if there would be no line number debug
diff --git a/gdb/testsuite/gdb.base/gnu_vector.exp b/gdb/testsuite/gdb.base/gnu_vector.exp
index f65627b..67a44c1 100644
--- a/gdb/testsuite/gdb.base/gnu_vector.exp
+++ b/gdb/testsuite/gdb.base/gnu_vector.exp
@@ -18,9 +18,7 @@
 # Tests GDBs support for GNU vectors.
 # http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html
 
-set testfile "gnu_vector"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if [get_compiler_info] {
     return -1
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 0/7] first batch of test suite updates
@ 2013-06-19 21:04 Tom Tromey
  2013-06-19 21:04 ` [PATCH 6/7] test suite update - gdb.base/s* Tom Tromey
                   ` (9 more replies)
  0 siblings, 10 replies; 15+ messages in thread
From: Tom Tromey @ 2013-06-19 21:04 UTC (permalink / raw)
  To: gdb-patches

I've been working on a long-term project to fully parallelize the gdb
test suite.  The end goal is that it should be possible to run each
.exp file in parallel.

This project has many parts; and the full patch is not quite finished
(and is also very large).  I wanted to start sending out some of the
more straightforward changes, mostly so that I wouldn't have to
constantly rebase them.  I think these changes are reasonable in their
own right.

This series holds all the "easy" conversions from gdb.base.  This is
just straightforward changes to use standard_testfile and
standard_output_file, plus also prepare_for_testing or clean_restart
as well.

This series fixes a few spots where .exp files did not interact well.
For example, cases where the tests used the same executable name.

This regression tests cleanly; however since some file names changed
there are a few minor output changes:

    Missing tests:
    gdb.base/corefile.exp: args: -core=coremaker.core: PASS
    gdb.base/corefile.exp: args: execfile -core=coremaker.core: PASS
    gdb.base/info-proc.exp: core break.gcore: PASS

    New tests:
    gdb.base/corefile.exp: args: -core=corefile.core: PASS
    gdb.base/corefile.exp: args: execfile -core=corefile.core: PASS
    gdb.base/default.exp: set the history filename: PASS
    gdb.base/info-proc.exp: core info-proc.gcore: PASS

I don't consider this to be a problem.

I split the patch up into 7 roughly equal-sized pieces based on file
name.

After this series, gdb.base is still not parallel-clean.  There are
some lurking "trickier" cases I omitted from this series, as they
depend on new testsuite/lib infrastructure.  I plan to work through
all the easy/obvious bits first, before starting to upstream that
stuff.

Tom


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 4/7] test suite update - gdb.base/[hijklm]
  2013-06-19 21:04 [PATCH 0/7] first batch of test suite updates Tom Tromey
                   ` (3 preceding siblings ...)
  2013-06-19 21:04 ` [PATCH 3/7] test suite update - gdb.base/[efg] Tom Tromey
@ 2013-06-19 21:04 ` Tom Tromey
  2013-06-19 21:04 ` [PATCH 2/7] test suite update - gdb.base/[cd] Tom Tromey
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Tom Tromey @ 2013-06-19 21:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Files gdb.base/[hijklm]*.exp.
See message #0 for details.

	* hook-stop-continue.exp, hook-stop-frame.exp, huge.exp,
	included.exp, inferior-died.exp, infnan.exp, info-fun.exp,
	info-macros.exp, info-os.exp, info-proc.exp, info-target.exp,
	infoline.exp, interp.exp, interrupt.exp, jit-simple.exp,
	jit-so.exp, jump.exp, kill-after-signal.exp, label.exp, langs.exp,
	lineinc.exp, list.exp, logical.exp, long_long.exp, longjmp.exp,
	macscp.exp, maint.exp, memattr.exp, mips_pro.exp, miscexprs.exp,
	morestack.exp, moribund-step.exp, multi-forks.exp: Use
	standard_testfile, standard_output_file, prepare_for_testing,
	clean_restart.
---
 gdb/testsuite/gdb.base/hook-stop-continue.exp |  9 +--
 gdb/testsuite/gdb.base/hook-stop-frame.exp    | 11 +---
 gdb/testsuite/gdb.base/huge.exp               |  9 +--
 gdb/testsuite/gdb.base/included.exp           | 14 +----
 gdb/testsuite/gdb.base/inferior-died.exp      |  4 +-
 gdb/testsuite/gdb.base/infnan.exp             | 13 +----
 gdb/testsuite/gdb.base/info-fun.exp           |  9 ++-
 gdb/testsuite/gdb.base/info-macros.exp        |  4 +-
 gdb/testsuite/gdb.base/info-os.exp            |  3 +-
 gdb/testsuite/gdb.base/info-proc.exp          | 29 ++--------
 gdb/testsuite/gdb.base/info-target.exp        |  5 +-
 gdb/testsuite/gdb.base/infoline.exp           |  5 +-
 gdb/testsuite/gdb.base/interp.exp             |  4 +-
 gdb/testsuite/gdb.base/interrupt.exp          | 10 ++--
 gdb/testsuite/gdb.base/jit-simple.exp         |  7 +--
 gdb/testsuite/gdb.base/jit-so.exp             |  6 +-
 gdb/testsuite/gdb.base/jump.exp               |  9 +--
 gdb/testsuite/gdb.base/kill-after-signal.exp  |  2 +-
 gdb/testsuite/gdb.base/label.exp              |  6 +-
 gdb/testsuite/gdb.base/langs.exp              | 29 ++--------
 gdb/testsuite/gdb.base/lineinc.exp            | 11 +---
 gdb/testsuite/gdb.base/list.exp               | 22 ++-----
 gdb/testsuite/gdb.base/logical.exp            |  9 +--
 gdb/testsuite/gdb.base/long_long.exp          |  9 +--
 gdb/testsuite/gdb.base/longjmp.exp            |  9 +--
 gdb/testsuite/gdb.base/macscp.exp             | 11 +---
 gdb/testsuite/gdb.base/maint.exp              | 82 ++++++++++++---------------
 gdb/testsuite/gdb.base/memattr.exp            |  3 +-
 gdb/testsuite/gdb.base/mips_pro.exp           | 24 +++-----
 gdb/testsuite/gdb.base/miscexprs.exp          |  9 +--
 gdb/testsuite/gdb.base/morestack.exp          |  5 +-
 gdb/testsuite/gdb.base/moribund-step.exp      |  4 +-
 gdb/testsuite/gdb.base/multi-forks.exp        | 14 +----
 33 files changed, 118 insertions(+), 282 deletions(-)

diff --git a/gdb/testsuite/gdb.base/hook-stop-continue.exp b/gdb/testsuite/gdb.base/hook-stop-continue.exp
index 7455da9..26f2cf9 100644
--- a/gdb/testsuite/gdb.base/hook-stop-continue.exp
+++ b/gdb/testsuite/gdb.base/hook-stop-continue.exp
@@ -13,19 +13,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "hook-stop-continue"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if { [prepare_for_testing ${testfile}.exp "${testfile}" "${testfile}.c" {debug nowarnings}] } {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 if ![runto_main] then {
     perror "Couldn't run to main"
 }
diff --git a/gdb/testsuite/gdb.base/hook-stop-frame.exp b/gdb/testsuite/gdb.base/hook-stop-frame.exp
index 7f11b6e..ce7ece4 100644
--- a/gdb/testsuite/gdb.base/hook-stop-frame.exp
+++ b/gdb/testsuite/gdb.base/hook-stop-frame.exp
@@ -13,19 +13,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "hook-stop-frame"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if { [prepare_for_testing ${testfile}.exp "${testfile}" "${testfile}.c" {debug nowarnings}] } {
+if { [prepare_for_testing ${testfile}.exp "${testfile}" $srcfile {debug nowarnings}] } {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 if ![runto_main] then {
     perror "Couldn't run to main"
 }
diff --git a/gdb/testsuite/gdb.base/huge.exp b/gdb/testsuite/gdb.base/huge.exp
index f955c37..4504d10 100644
--- a/gdb/testsuite/gdb.base/huge.exp
+++ b/gdb/testsuite/gdb.base/huge.exp
@@ -23,9 +23,7 @@ if [target_info exists gdb,skip_huge_test] {
     return
 }
 
-set testfile "huge"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 for { set size [expr 2 * 1024 * 1024] } { $size > 10 } { set size [expr $size / 2] } {
   if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
@@ -39,10 +37,7 @@ if { $size < 10 } {
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 set prev_timeout $timeout
 set timeout 30
diff --git a/gdb/testsuite/gdb.base/included.exp b/gdb/testsuite/gdb.base/included.exp
index 45c49d4..26e0cfe 100644
--- a/gdb/testsuite/gdb.base/included.exp
+++ b/gdb/testsuite/gdb.base/included.exp
@@ -13,20 +13,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "included"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested included.exp
+standard_testfile
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test_no_output "set listsize 1"
 
 gdb_test "list main" ".*"
diff --git a/gdb/testsuite/gdb.base/inferior-died.exp b/gdb/testsuite/gdb.base/inferior-died.exp
index 8c3b33a..b974f33 100644
--- a/gdb/testsuite/gdb.base/inferior-died.exp
+++ b/gdb/testsuite/gdb.base/inferior-died.exp
@@ -31,9 +31,7 @@ if { ![support_displaced_stepping] } {
     return -1
 }
 
-set testfile "inferior-died"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c] } {
     return -1
diff --git a/gdb/testsuite/gdb.base/infnan.exp b/gdb/testsuite/gdb.base/infnan.exp
index c70a7b4..8c264e2 100644
--- a/gdb/testsuite/gdb.base/infnan.exp
+++ b/gdb/testsuite/gdb.base/infnan.exp
@@ -15,20 +15,13 @@
 
 # Script to test floating point infinities and NaNs.
 
-set testfile "infnan"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested infnan.exp
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 runto_main
 
 gdb_test "print a" "\\\$$decimal = inf"
diff --git a/gdb/testsuite/gdb.base/info-fun.exp b/gdb/testsuite/gdb.base/info-fun.exp
index f149efc..b49611f 100644
--- a/gdb/testsuite/gdb.base/info-fun.exp
+++ b/gdb/testsuite/gdb.base/info-fun.exp
@@ -19,13 +19,11 @@ if { [skip_shlib_tests] || [is_remote target] } {
 # Library file.
 set libname "info-fun-solib"
 set srcfile_lib ${srcdir}/${subdir}/${libname}.c
-set binfile_lib ${objdir}/${subdir}/${libname}.so
+set binfile_lib [standard_output_file ${libname}.so]
 set lib_flags {}
 # Binary file.
-set testfile "info-fun"
-set srcfile ${srcdir}/${subdir}/${testfile}.c
+standard_testfile .c
 set executable ${testfile}
-set binfile ${objdir}/${subdir}/${executable}
 set bin_flags [list debug shlib=${binfile_lib}]
 
 if [get_compiler_info] {
@@ -40,7 +38,8 @@ foreach libsepdebug {NO IN SEP} { with_test_prefix "$libsepdebug" {
 	lappend sep_lib_flags {debug}
     }
     if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $sep_lib_flags] != ""
-	 || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
+	 || [gdb_compile $srcdir/$subdir/${srcfile} ${binfile} \
+		 executable $bin_flags] != "" } {
       untested "Could not compile $binfile_lib or $binfile."
       return -1
     }
diff --git a/gdb/testsuite/gdb.base/info-macros.exp b/gdb/testsuite/gdb.base/info-macros.exp
index 98f177c..ed750c1 100644
--- a/gdb/testsuite/gdb.base/info-macros.exp
+++ b/gdb/testsuite/gdb.base/info-macros.exp
@@ -13,9 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "info-macros"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 get_compiler_info
 if ![test_compiler_info gcc*] {
diff --git a/gdb/testsuite/gdb.base/info-os.exp b/gdb/testsuite/gdb.base/info-os.exp
index 5ebc16f..e527328 100644
--- a/gdb/testsuite/gdb.base/info-os.exp
+++ b/gdb/testsuite/gdb.base/info-os.exp
@@ -13,8 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "info-os"
-set srcfile ${testfile}.c
+standard_testfile .c
 
 # This test is Linux-only.
 if ![istarget *-*-linux*] then {
diff --git a/gdb/testsuite/gdb.base/info-proc.exp b/gdb/testsuite/gdb.base/info-proc.exp
index 6db6975..b6b26a2 100644
--- a/gdb/testsuite/gdb.base/info-proc.exp
+++ b/gdb/testsuite/gdb.base/info-proc.exp
@@ -18,33 +18,14 @@
 
 set ws "\[ \t\]+"
 
-set testfile "break"
-set srcfile ${testfile}.c
-set srcfile1 ${testfile}1.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile break.c break1.c
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
-     untested info-proc.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
-     untested info-proc.exp
-     return -1
-}
-
-if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
-     untested info-proc.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile \
+	 [list $srcfile $srcfile2] {debug nowarnings}]} {
+    untested $testfile.exp
+    return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test "help info proc" "Show /proc process information about .*"
 
 gdb_test_multiple "info proc" "info proc without a process" {
diff --git a/gdb/testsuite/gdb.base/info-target.exp b/gdb/testsuite/gdb.base/info-target.exp
index fb68622..08c4224 100644
--- a/gdb/testsuite/gdb.base/info-target.exp
+++ b/gdb/testsuite/gdb.base/info-target.exp
@@ -14,8 +14,9 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile info-target
-if { [prepare_for_testing ${testfile}.exp $testfile start.c] } {
+standard_testfile start.c
+
+if { [prepare_for_testing ${testfile}.exp $testfile $srcfile] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/infoline.exp b/gdb/testsuite/gdb.base/infoline.exp
index 2251158..9fb2f53 100644
--- a/gdb/testsuite/gdb.base/infoline.exp
+++ b/gdb/testsuite/gdb.base/infoline.exp
@@ -13,15 +13,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile infoline
-set srcfile ${testfile}.c
+standard_testfile
 
 if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
     return -1
 }
 
-clean_restart ${testfile}
-
 # Verify that the "info line" command does not skip function prologues.
 # If it did, GDB would tell us that the line we're interested in starts
 # at <twice+N> where N is different from zero.
diff --git a/gdb/testsuite/gdb.base/interp.exp b/gdb/testsuite/gdb.base/interp.exp
index 0b5df5c..7e5ca3c 100644
--- a/gdb/testsuite/gdb.base/interp.exp
+++ b/gdb/testsuite/gdb.base/interp.exp
@@ -15,9 +15,9 @@
 
 # interp.exp   Test interpreter-exec command
 
-set testfile "interp"
+standard_testfile
 
-if { [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c {debug}] } {
+if { [prepare_for_testing ${testfile}.exp ${testfile} $srcfile {debug}] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/interrupt.exp b/gdb/testsuite/gdb.base/interrupt.exp
index 7319410..1456f33 100644
--- a/gdb/testsuite/gdb.base/interrupt.exp
+++ b/gdb/testsuite/gdb.base/interrupt.exp
@@ -24,18 +24,16 @@ if [target_info exists gdb,noinferiorio] {
 }
 
 
-set testfile interrupt
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 set options { debug }
 if { ! [target_info exists gdb,nosignals] } {
     lappend options "additional_flags=-DSIGNALS"
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $options] != "" } {
-     untested interrupt.exp
-     return -1
+if {[build_executable $testfile.exp $testfile $srcfile $options] == -1} {
+    untested $testfile.exp
+    return -1
 }
 
 gdb_start
diff --git a/gdb/testsuite/gdb.base/jit-simple.exp b/gdb/testsuite/gdb.base/jit-simple.exp
index 9f5910b..a497490 100644
--- a/gdb/testsuite/gdb.base/jit-simple.exp
+++ b/gdb/testsuite/gdb.base/jit-simple.exp
@@ -28,10 +28,9 @@ if {[get_compiler_info]} {
 # test running programs
 #
 
-set testfile jit-simple
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+standard_testfile
+
+if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
     untested jit-simple.exp
     return -1
 }
diff --git a/gdb/testsuite/gdb.base/jit-so.exp b/gdb/testsuite/gdb.base/jit-so.exp
index e3a3728..70f2a7d 100644
--- a/gdb/testsuite/gdb.base/jit-so.exp
+++ b/gdb/testsuite/gdb.base/jit-so.exp
@@ -33,7 +33,7 @@ if {[get_compiler_info]} {
 
 set testfile jit-dlmain
 set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+set binfile [standard_output_file ${testfile}]
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug shlib_load}] != "" } {
     untested jit-so.exp
     return -1
@@ -41,7 +41,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 set testfile2 jit-main
 set srcfile2 ${testfile2}.c
-set binfile2 ${objdir}/${subdir}/${testfile2}.so
+set binfile2 [standard_output_file ${testfile2}.so]
 set binfile2_dlopen [shlib_target_file ${testfile2}.so]
 if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug additional_flags="-DMAIN=jit_dl_main"}] != "" } {
     untested jit.exp
@@ -50,7 +50,7 @@ if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug add
 
 set solib_testfile "jit-solib"
 set solib_srcfile "${srcdir}/${subdir}/${solib_testfile}.c"
-set solib_binfile "${objdir}/${subdir}/${solib_testfile}.so"
+set solib_binfile [standard_output_file ${solib_testfile}.so]
 set solib_binfile_test_msg "SHLIBDIR/${solib_testfile}.so"
 
 # Note: compiling without debug info: the library goes through symbol
diff --git a/gdb/testsuite/gdb.base/jump.exp b/gdb/testsuite/gdb.base/jump.exp
index 73d1dda..a8f93f9 100644
--- a/gdb/testsuite/gdb.base/jump.exp
+++ b/gdb/testsuite/gdb.base/jump.exp
@@ -16,9 +16,7 @@
 
 clear_xfail "*-*-*"
 
-set testfile "jump"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 # Build the test case
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
@@ -29,10 +27,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 # Start with a fresh gdb
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto_main] then {
   perror "Couldn't run to main"
diff --git a/gdb/testsuite/gdb.base/kill-after-signal.exp b/gdb/testsuite/gdb.base/kill-after-signal.exp
index 3b59077..80e1ec0 100644
--- a/gdb/testsuite/gdb.base/kill-after-signal.exp
+++ b/gdb/testsuite/gdb.base/kill-after-signal.exp
@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "kill-after-signal"
+standard_testfile .c
 
 if { ![can_single_step_to_signal_handler] } {
     untested ${testfile}.exp
diff --git a/gdb/testsuite/gdb.base/label.exp b/gdb/testsuite/gdb.base/label.exp
index ac9193b..4122609 100644
--- a/gdb/testsuite/gdb.base/label.exp
+++ b/gdb/testsuite/gdb.base/label.exp
@@ -23,11 +23,9 @@ if [is_remote target] then {
 # test running programs
 #
 
-set testfile "label"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
-if { [prepare_for_testing ${testfile}.exp $testfile ${testfile}.c debug] } {
+if { [prepare_for_testing ${testfile}.exp $testfile ${srcfile} debug] } {
     untested label.exp
     return -1
 }
diff --git a/gdb/testsuite/gdb.base/langs.exp b/gdb/testsuite/gdb.base/langs.exp
index cbb0e31..b2cb52b 100644
--- a/gdb/testsuite/gdb.base/langs.exp
+++ b/gdb/testsuite/gdb.base/langs.exp
@@ -14,8 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile langs
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile langs0.c langs1.c langs2.c
 
 if [is_remote host] {
     remote_download host ${srcdir}/${subdir}/langs1.f
@@ -23,24 +22,9 @@ if [is_remote host] {
 }
 
 
-if  { [gdb_compile "${srcdir}/${subdir}/langs0.c" "${binfile}0.o" object {debug}] != "" } {
-     untested langs.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/langs1.c" "${binfile}1.o" object {debug}] != "" } {
-     untested langs.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/langs2.c" "${binfile}2.o" object {debug}] != "" } {
-     untested langs.exp
-     return -1
-}
-
-if  { [gdb_compile "${binfile}0.o ${binfile}1.o ${binfile}2.o" ${binfile} executable {debug}] != "" } {
-     untested langs.exp
-     return -1
+if {[prepare_for_testing ${testfile}.exp ${testfile} \
+	 [list $srcfile $srcfile2 $srcfile3] {debug}]} {
+    return -1
 }
 
 set oldtimeout $timeout
@@ -54,11 +38,6 @@ if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
-
 gdb_test_multiple "b langs0" "break on nonexistent function in langs.exp" {
 	-re "Function \"langs0\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" {
 
diff --git a/gdb/testsuite/gdb.base/lineinc.exp b/gdb/testsuite/gdb.base/lineinc.exp
index f3b9ef0..aa9d27b 100644
--- a/gdb/testsuite/gdb.base/lineinc.exp
+++ b/gdb/testsuite/gdb.base/lineinc.exp
@@ -78,19 +78,14 @@
 # read the above debugging info.
 
 
-set testfile "lineinc"
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
-
-if {[gdb_compile "${srcdir}/${subdir}/${testfile}.c" ${binfile} executable {debug}] != ""} {
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable {debug}] != ""} {
     untested lineinc.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 # Any command that causes GDB to read the debugging info for the
 # lineinc.c compilation unit will do here.
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 11aafd9..62504d1 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -16,30 +16,16 @@
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
 
-set testfile "list"
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile list0.c list1.c
 
 # Need to download the header to the host.
 remote_download host ${srcdir}/${subdir}/list0.h list0.h
 
-
-if  { [gdb_compile "${srcdir}/${subdir}/list0.c" "${binfile}0.o" object {debug}] != "" } {
-     untested list.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/list1.c" "${binfile}1.o" object {debug}] != "" } {
-     untested list.exp
-     return -1
-}
-
-if  { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } {
-     untested list.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile [list $srcfile $srcfile2] \
+	 {debug}]} {
+    return -1
 }
 
-
-
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
 if [get_compiler_info] {
diff --git a/gdb/testsuite/gdb.base/logical.exp b/gdb/testsuite/gdb.base/logical.exp
index e228c08..1c9ecd4 100644
--- a/gdb/testsuite/gdb.base/logical.exp
+++ b/gdb/testsuite/gdb.base/logical.exp
@@ -25,9 +25,7 @@
 # test running programs
 #
 
-set testfile "int-type"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile int-type.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
     untested logical.exp
@@ -38,10 +36,7 @@ if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 
 #
diff --git a/gdb/testsuite/gdb.base/long_long.exp b/gdb/testsuite/gdb.base/long_long.exp
index 38df863..dcd115e 100644
--- a/gdb/testsuite/gdb.base/long_long.exp
+++ b/gdb/testsuite/gdb.base/long_long.exp
@@ -22,9 +22,7 @@ if [target_info exists no_long_long] {
     return 0
 }
 
-set testfile long_long
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 # What compiler are we using?
 #
@@ -46,10 +44,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [con
 # use this to debug:
 #log_user 1
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if { ![runto known_types] } then { 
    fail "run to known_types" 
diff --git a/gdb/testsuite/gdb.base/longjmp.exp b/gdb/testsuite/gdb.base/longjmp.exp
index 9609fc6..7af3a23 100644
--- a/gdb/testsuite/gdb.base/longjmp.exp
+++ b/gdb/testsuite/gdb.base/longjmp.exp
@@ -18,9 +18,7 @@
 #
 
 
-set testfile "longjmp"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
      untested longjmp.exp
@@ -31,10 +29,7 @@ if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto_main] then {
    fail "Can't run to main"
diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp
index ab48c51..7c25eed 100644
--- a/gdb/testsuite/gdb.base/macscp.exp
+++ b/gdb/testsuite/gdb.base/macscp.exp
@@ -15,10 +15,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set srcfile macscp1.c
-set testfile "macscp"
-set objfile ${objdir}/${subdir}/${testfile}.o
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile macscp1.c
+set objfile [standard_output_file ${testfile}.o]
 
 set options { debug additional_flags=-DFROM_COMMANDLINE=ARG}
 
@@ -36,10 +34,7 @@ if  {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 
 # Ask GDB to show the current definition of MACRO, and return a list
diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index afc321f..7057ac7 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -47,31 +47,14 @@
 
 
 
-set testfile "break"
-set srcfile ${testfile}.c
-set srcfile1 ${testfile}1.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
-     untested maint.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
-     untested maint.exp
-     return -1
-}
+standard_testfile break.c break1.c
 
-if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
-     untested maint.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile \
+	 [list $srcfile $srcfile2] {debug nowarnings}]} {
+    untested $testfile.exp
+    return -1
 }
 
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
 # The commands we test here produce many lines of output; disable "press
 # <return> to continue" prompts.
 gdb_test_no_output "set height 0"
@@ -168,7 +151,7 @@ if [istarget "*-*-cygwin*"] {
 
 send_gdb "maint print statistics\n"
 gdb_expect  {
-    -re "Statistics for\[^\n\r\]*break\[^\n\r\]*:\r\n  Number of \"minimal\" symbols read: $decimal\r\n(  Number of \"partial\" symbols read: $decimal\r\n)?  Number of \"full\" symbols read: $decimal\r\n  Number of \"types\" defined: $decimal\r\n(  Number of psym tables \\(not yet expanded\\): $decimal\r\n)?(  Number of read CUs: $decimal\r\n  Number of unread CUs: $decimal\r\n)?  Number of symbol tables: $decimal\r\n  Number of symbol tables with line tables: $decimal\r\n  Number of symbol tables with blockvectors: $decimal\r\n  Total memory used for objfile obstack: $decimal\r\n  Total memory used for BFD obstack: $decimal\r\n  Total memory used for psymbol cache: $decimal\r\n  Total memory used for macro cache: $decimal\r\n  Total memory used for file name cache: $decimal\r\n" {
+    -re "Statistics for\[^\n\r\]*maint\[^\n\r\]*:\r\n  Number of \"minimal\" symbols read: $decimal\r\n(  Number of \"partial\" symbols read: $decimal\r\n)?  Number of \"full\" symbols read: $decimal\r\n  Number of \"types\" defined: $decimal\r\n(  Number of psym tables \\(not yet expanded\\): $decimal\r\n)?(  Number of read CUs: $decimal\r\n  Number of unread CUs: $decimal\r\n)?  Number of symbol tables: $decimal\r\n  Number of symbol tables with line tables: $decimal\r\n  Number of symbol tables with blockvectors: $decimal\r\n  Total memory used for objfile obstack: $decimal\r\n  Total memory used for BFD obstack: $decimal\r\n  Total memory used for psymbol cache: $decimal\r\n  Total memory used for macro cache: $decimal\r\n  Total memory used for file name cache: $decimal\r\n" {
 	gdb_expect {
 	    -re "$gdb_prompt $" {
 		pass "maint print statistics"
@@ -197,7 +180,7 @@ set keep_looking 1
 while {$keep_looking} {
     gdb_expect  {
 
-	-re ".*Object file.*break($EXEEXT)?:  Objfile at $hex, bfd at $hex, \[0-9\]* minsyms\[\r\t \]+\n" { set header 1 }
+	-re ".*Object file.*maint($EXEEXT)?:  Objfile at $hex, bfd at $hex, \[0-9\]* minsyms\[\r\t \]+\n" { set header 1 }
 	-re ".*Psymtabs:\[\r\t \]+\n" { set psymtabs 1 }
 	-re ".*Symtabs:\[\r\t \]+\n" { set symtabs 1 }
 
@@ -226,18 +209,19 @@ gdb_test "maint print psymbols" \
     "maint print psymbols w/o args"
 
 if { ! $have_gdb_index } {
-    send_gdb "maint print psymbols psymbols_output ${srcdir}/${subdir}/${srcfile}\n"
+    set psymbols_output [standard_output_file psymbols_output]
+    send_gdb "maint print psymbols $psymbols_output ${srcdir}/${subdir}/${srcfile}\n"
     gdb_expect  {
-	-re "^maint print psymbols psymbols_output \[^\n\]*\r\n$gdb_prompt $" {
-	    send_gdb "shell ls psymbols_output\n"
+	-re "^maint print psymbols $psymbols_output \[^\n\]*\r\n$gdb_prompt $" {
+	    send_gdb "shell ls $psymbols_output\n"
 	    gdb_expect {
-		-re "psymbols_output\r\n$gdb_prompt $" {
+		-re "$psymbols_output\r\n$gdb_prompt $" {
 		    # We want this grep to be as specific as possible,
 		    # so it's less likely to match symbol file names in
 		    # psymbols_output.  Yes, this actually happened;
 		    # poor expect got tons of output, and timed out
 		    # trying to match it.   --- Jim Blandy <jimb@cygnus.com>
-		    send_gdb "shell grep 'main.*function' psymbols_output\n"
+		    send_gdb "shell grep 'main.*function' $psymbols_output\n"
 		    gdb_expect {
 			-re ".main., function, $hex.*$gdb_prompt $" {
 			    pass "maint print psymbols 1"
@@ -248,7 +232,8 @@ if { ! $have_gdb_index } {
 			-re ".*$gdb_prompt $" { fail "maint print psymbols" }
 			timeout     { fail "(timeout) maint print psymbols" }
 		    }
-		    gdb_test "shell rm -f psymbols_output" ".*"
+		    gdb_test "shell rm -f $psymbols_output" ".*" \
+			"shell rm -f psymbols_output"
 		}
 		-re ".*$gdb_prompt $"       { fail "maint print psymbols" }
 		timeout           { fail "(timeout) maint print psymbols" }
@@ -264,13 +249,14 @@ gdb_test "maint print msymbols" \
     "maint print msymbols w/o args"
 
 
-send_gdb "maint print msymbols msymbols_output ${binfile}\n"
+set msymbols_output [standard_output_file msymbols_output]
+send_gdb "maint print msymbols $msymbols_output ${binfile}\n"
 gdb_expect  {
-    -re "^maint print msymbols msymbols_output \[^\n\]*\r\n$gdb_prompt $" {
-	send_gdb "shell ls msymbols_output\n"
+    -re "^maint print msymbols $msymbols_output \[^\n\]*\r\n$gdb_prompt $" {
+	send_gdb "shell ls $msymbols_output\n"
 	gdb_expect {
-	    -re "msymbols_output\r\n$gdb_prompt $" {
-		send_gdb "shell grep factorial msymbols_output\n"
+	    -re "$msymbols_output\r\n$gdb_prompt $" {
+		send_gdb "shell grep factorial $msymbols_output\n"
 		gdb_expect {
 		    -re "\\\[ *$decimal\\\] \[tT\]\[ \t\]+$hex \\.?factorial.*$gdb_prompt $" {
 			pass "maint print msymbols"
@@ -278,7 +264,8 @@ gdb_expect  {
 		    -re ".*$gdb_prompt $"     { fail "maint print msymbols" }
 		    timeout         { fail "(timeout) maint print msymbols" }
 		}
-		gdb_test "shell rm -f msymbols_output" ".*"
+		gdb_test "shell rm -f $msymbols_output" ".*" \
+		    "shell rm -f msymbols_output"
 	    }
 	    -re ".*$gdb_prompt $"     { fail "maint print msymbols" }
 	    timeout         { fail "(timeout) maint print msymbols" }
@@ -309,7 +296,8 @@ gdb_test_multiple "maint print msymbols msymbols_output2 ${subdir}/${testfile}"
 		        fail "(timeout) maint print msymbols"
 		    }
 		}
-		gdb_test "shell rm -f msymbols_output2" ".*"
+		gdb_test "shell rm -f msymbols_output2" ".*" \
+		    "shell rm -f msymbols_output2"
 	    }
 	    -re ".*$gdb_prompt $" {
 		fail "maint print msymbols"
@@ -339,14 +327,15 @@ gdb_test "maint print symbols" \
 # dump the symbol information for the entire C library - over 500MB nowadays
 # for GNU libc.
 
-send_gdb "maint print symbols symbols_output ${srcdir}/${subdir}/${srcfile}\n"
+set symbols_output [standard_output_file symbols_output]
+send_gdb "maint print symbols $symbols_output ${srcdir}/${subdir}/${srcfile}\n"
 gdb_expect  {
-    -re "^maint print symbols symbols_output \[^\n\]*\r\n$gdb_prompt $" {
-	send_gdb "shell ls symbols_output\n"
+    -re "^maint print symbols $symbols_output \[^\n\]*\r\n$gdb_prompt $" {
+	send_gdb "shell ls $symbols_output\n"
 	gdb_expect {
-	    -re "symbols_output\r\n$gdb_prompt $" {
+	    -re "$symbols_output\r\n$gdb_prompt $" {
 		# See comments for `maint print psymbols'.
-		send_gdb "shell grep 'main(.*block' symbols_output\n"
+		send_gdb "shell grep 'main(.*block' $symbols_output\n"
 		gdb_expect {
 		    -re "int main\\(int, char \\*\\*, char \\*\\*\\); block.*$gdb_prompt $" {
 			pass "maint print symbols"
@@ -354,7 +343,8 @@ gdb_expect  {
 		    -re ".*$gdb_prompt $"     { fail "maint print symbols" }
 		    timeout         { fail "(timeout) maint print symbols" }
 		}
-		gdb_test "shell rm -f symbols_output" ".*"
+		gdb_test "shell rm -f $symbols_output" ".*" \
+		    "shell rm -f symbols_output"
 	    }
 	    -re ".*$gdb_prompt $"     { fail "maint print symbols" }
 	    timeout         { fail "(timeout) maint print symbols" }
@@ -401,18 +391,18 @@ set text_section ".text"
 set data_section ".data"
 
 gdb_test_multiple "maint info sections" "maint info sections" {
-    -re "Exec file:\r\n.*break($EXEEXT)?., file type.*ER_RO.*$gdb_prompt $" {
+    -re "Exec file:\r\n.*maint($EXEEXT)?., file type.*ER_RO.*$gdb_prompt $" {
 	# Looks like RealView which uses different section names.
 	set text_section ER_RO
 	set data_section ER_RW
 	pass "maint info sections"
     }
-    -re "Exec file:\r\n.*break($EXEEXT)?., file type.*neardata.*$gdb_prompt $" {
+    -re "Exec file:\r\n.*maint($EXEEXT)?., file type.*neardata.*$gdb_prompt $" {
 	# c6x doesn't have .data section.  It has .neardata and .fardata section.
 	set data_section ".neardata"
 	pass "maint info sections"
     }
-    -re "Exec file:\r\n.*break($EXEEXT)?., file type.*$gdb_prompt $" {
+    -re "Exec file:\r\n.*maint($EXEEXT)?., file type.*$gdb_prompt $" {
 	pass "maint info sections"
     }
 }
diff --git a/gdb/testsuite/gdb.base/memattr.exp b/gdb/testsuite/gdb.base/memattr.exp
index 69f2ad4..455bea5 100644
--- a/gdb/testsuite/gdb.base/memattr.exp
+++ b/gdb/testsuite/gdb.base/memattr.exp
@@ -17,8 +17,7 @@
 
 # Test the memory attribute commands.
 
-set testfile "memattr"
-set srcfile  ${testfile}.c
+standard_testfile .c
 
 if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
     return -1
diff --git a/gdb/testsuite/gdb.base/mips_pro.exp b/gdb/testsuite/gdb.base/mips_pro.exp
index 2c8e996..72e1981 100644
--- a/gdb/testsuite/gdb.base/mips_pro.exp
+++ b/gdb/testsuite/gdb.base/mips_pro.exp
@@ -14,9 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile mips_pro
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
@@ -27,23 +25,15 @@ if [get_compiler_info] {
 
 # This test must be compiled with -O2 if using gcc.
 
+set options debug
 if { [test_compiler_info gcc-*-*] } then {
-    if  { [gdb_compile "${srcdir}/$subdir/${srcfile}" "${binfile}" \
-	    executable {debug additional_flags=-O2 additional_flags=-fno-inline}] != "" } {
-     untested mips_pro.exp
-     return -1
-    }
-} else {
-    if  { [gdb_compile "${srcdir}/$subdir/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested mips_pro.exp
-     return -1
-    }
+    lappend options additional_flags=-O2 additional_flags=-fno-inline
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile $options]} {
+    untested $testfile.exp
+    return -1
+}
 
 if [runto middle] then {
     # PR 3016
diff --git a/gdb/testsuite/gdb.base/miscexprs.exp b/gdb/testsuite/gdb.base/miscexprs.exp
index 22f9e9c..aa84950 100644
--- a/gdb/testsuite/gdb.base/miscexprs.exp
+++ b/gdb/testsuite/gdb.base/miscexprs.exp
@@ -37,9 +37,7 @@ set additional_flags "additional_flags=${storage}"
 # test running programs
 #
 
-set testfile "miscexprs"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } {
     untested miscexprs.exp
@@ -50,10 +48,7 @@ if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 
 #
diff --git a/gdb/testsuite/gdb.base/morestack.exp b/gdb/testsuite/gdb.base/morestack.exp
index 56a52b1..3fd5f20 100644
--- a/gdb/testsuite/gdb.base/morestack.exp
+++ b/gdb/testsuite/gdb.base/morestack.exp
@@ -21,8 +21,9 @@ if {$gcc_compiled == 0} {
     return -1
 }
 
-set testfile morestack
-if { [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c {additional_flags=-fsplit-stack}] } {
+standard_testfile
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} $srcfile {additional_flags=-fsplit-stack}] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/moribund-step.exp b/gdb/testsuite/gdb.base/moribund-step.exp
index 12e32fb..c088cb4 100644
--- a/gdb/testsuite/gdb.base/moribund-step.exp
+++ b/gdb/testsuite/gdb.base/moribund-step.exp
@@ -13,14 +13,14 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile moribund-step
+standard_testfile start.c
 
 if { ![support_displaced_stepping] } {
     unsupported "displaced stepping"
     return -1
 }
 
-if { [prepare_for_testing ${testfile}.exp ${testfile} start.c] } {
+if { [prepare_for_testing ${testfile}.exp ${testfile} $srcfile] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/multi-forks.exp b/gdb/testsuite/gdb.base/multi-forks.exp
index ac231d7..0ea96cc 100644
--- a/gdb/testsuite/gdb.base/multi-forks.exp
+++ b/gdb/testsuite/gdb.base/multi-forks.exp
@@ -25,9 +25,7 @@ if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-*-linux*"]} then {
 }
 
 
-set testfile "multi-forks"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested multi-forks.exp
@@ -36,10 +34,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 # Start with a fresh gdb
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 global gdb_prompt
 
@@ -142,10 +137,7 @@ if {![istarget "*-*-linux*"]} then {
 
 # Start with a fresh gdb
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 runto_main
 gdb_breakpoint $exit_bp_loc
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 6/7] test suite update - gdb.base/s*
  2013-06-19 21:04 [PATCH 0/7] first batch of test suite updates Tom Tromey
@ 2013-06-19 21:04 ` Tom Tromey
  2013-06-19 21:04 ` [PATCH 1/7] test suite update - gdb.base/[ab] Tom Tromey
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Tom Tromey @ 2013-06-19 21:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Files gdb.base/s*.exp.
See message #0 for details.

	* save-bp.exp, savedregs.exp, scope.exp, sep.exp, sepsymtab.exp,
	set-lang-auto.exp, setshow.exp, setvar.exp, shlib-call.exp,
	shreloc.exp, sigall.exp, sigaltstack.exp, sigbpt.exp, sigchld.exp,
	siginfo-addr.exp, siginfo-infcall.exp, siginfo-obj.exp,
	siginfo.exp, signals.exp, signest.exp, signull.exp, sigrepeat.exp,
	sigstep.exp, sizeof.exp, skip-solib.exp, so-impl-ld.exp,
	solib-display.exp, solib-nodir.exp, solib-overlap.exp,
	solib-symbol.exp, solib-weak.exp, source.exp, stack-checking.exp,
	stale-infcall.exp, stap-probe.exp, start.exp, step-break.exp,
	step-bt.exp, step-line.exp, step-resume-infcall.exp,
	step-test.exp, structs.exp, structs2.exp, structs3.exp,
	symbol-without-target_section.exp: Use standard_testfile,
	standard_output_file, prepare_for_testing, clean_restart.
---
 gdb/testsuite/gdb.base/save-bp.exp                 |  5 ++--
 gdb/testsuite/gdb.base/savedregs.exp               | 10 +++-----
 gdb/testsuite/gdb.base/scope.exp                   | 27 ++++------------------
 gdb/testsuite/gdb.base/sep.exp                     |  9 ++------
 gdb/testsuite/gdb.base/sepsymtab.exp               |  9 ++------
 gdb/testsuite/gdb.base/set-lang-auto.exp           | 16 ++++---------
 gdb/testsuite/gdb.base/setshow.exp                 | 10 +++-----
 gdb/testsuite/gdb.base/setvar.exp                  | 16 ++++---------
 gdb/testsuite/gdb.base/shlib-call.exp              | 20 ++++++----------
 gdb/testsuite/gdb.base/shreloc.exp                 | 25 ++++++++------------
 gdb/testsuite/gdb.base/sigall.exp                  | 16 ++++---------
 gdb/testsuite/gdb.base/sigaltstack.exp             | 10 +++-----
 gdb/testsuite/gdb.base/sigbpt.exp                  | 14 ++++-------
 gdb/testsuite/gdb.base/sigchld.exp                 |  9 ++------
 gdb/testsuite/gdb.base/siginfo-addr.exp            | 12 ++--------
 gdb/testsuite/gdb.base/siginfo-infcall.exp         |  7 +++---
 gdb/testsuite/gdb.base/siginfo-obj.exp             | 15 ++++--------
 gdb/testsuite/gdb.base/siginfo.exp                 | 15 ++++--------
 gdb/testsuite/gdb.base/signals.exp                 | 10 +++-----
 gdb/testsuite/gdb.base/signest.exp                 |  3 +--
 gdb/testsuite/gdb.base/signull.exp                 | 10 +++-----
 gdb/testsuite/gdb.base/sigrepeat.exp               | 10 +++-----
 gdb/testsuite/gdb.base/sigstep.exp                 | 15 ++++--------
 gdb/testsuite/gdb.base/sizeof.exp                  | 16 ++++---------
 gdb/testsuite/gdb.base/skip-solib.exp              |  9 ++++----
 gdb/testsuite/gdb.base/so-impl-ld.exp              | 14 ++++-------
 gdb/testsuite/gdb.base/solib-display.exp           |  4 ++--
 gdb/testsuite/gdb.base/solib-nodir.exp             |  6 ++---
 gdb/testsuite/gdb.base/solib-overlap.exp           |  6 ++---
 gdb/testsuite/gdb.base/solib-symbol.exp            |  4 ++--
 gdb/testsuite/gdb.base/solib-weak.exp              |  8 +++----
 gdb/testsuite/gdb.base/source.exp                  |  4 +---
 gdb/testsuite/gdb.base/stack-checking.exp          |  9 ++------
 gdb/testsuite/gdb.base/stale-infcall.exp           |  4 ++--
 gdb/testsuite/gdb.base/stap-probe.exp              |  6 ++---
 gdb/testsuite/gdb.base/start.exp                   | 16 ++++---------
 gdb/testsuite/gdb.base/step-break.exp              | 11 ++-------
 gdb/testsuite/gdb.base/step-bt.exp                 | 16 ++++---------
 gdb/testsuite/gdb.base/step-line.exp               | 16 ++++---------
 gdb/testsuite/gdb.base/step-resume-infcall.exp     |  4 ++--
 gdb/testsuite/gdb.base/step-test.exp               |  9 ++------
 gdb/testsuite/gdb.base/structs.exp                 |  7 ++----
 gdb/testsuite/gdb.base/structs2.exp                |  8 ++-----
 gdb/testsuite/gdb.base/structs3.exp                |  4 +---
 .../gdb.base/symbol-without-target_section.exp     | 14 +++++------
 45 files changed, 148 insertions(+), 340 deletions(-)

diff --git a/gdb/testsuite/gdb.base/save-bp.exp b/gdb/testsuite/gdb.base/save-bp.exp
index 72a6847..64df0f7 100644
--- a/gdb/testsuite/gdb.base/save-bp.exp
+++ b/gdb/testsuite/gdb.base/save-bp.exp
@@ -13,10 +13,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile save-bp
-set srcfile ${testfile}.c
+standard_testfile .c
 
-if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
+if { [prepare_for_testing ${testfile}.exp ${testfile} $srcfile] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/savedregs.exp b/gdb/testsuite/gdb.base/savedregs.exp
index 1548d0a..d4d16c3 100644
--- a/gdb/testsuite/gdb.base/savedregs.exp
+++ b/gdb/testsuite/gdb.base/savedregs.exp
@@ -30,19 +30,15 @@ if [target_info exists gdb,nosignals] {
 }
 
 
-set testfile savedregs
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested "Couldn't compile ${module}.c"
     return -1
 }
 
 # get things started
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 # Advance to main
 if { ![runto_main] } {
diff --git a/gdb/testsuite/gdb.base/scope.exp b/gdb/testsuite/gdb.base/scope.exp
index fbcc31b..e781cf0 100644
--- a/gdb/testsuite/gdb.base/scope.exp
+++ b/gdb/testsuite/gdb.base/scope.exp
@@ -16,23 +16,11 @@
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
 
-set testfile "scope"
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile scope0.c scope1.c
 
-
-if  { [gdb_compile "${srcdir}/${subdir}/scope0.c" "${binfile}0.o" object {debug}] != "" } {
-     untested scope.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/scope1.c" "${binfile}1.o" object {debug}] != "" } {
-     untested scope.exp
-     return -1
-}
-
-if  { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } {
-     untested scope.exp
-     return -1
+if {[prepare_for_testing ${testfile}.exp ${testfile} \
+	 [list $srcfile $srcfile2] {debug}]} {
+    return -1
 }
 
 # Create and source the file that provides information about the compiler
@@ -511,13 +499,6 @@ proc test_at_localscopes {} {
     gdb_stop_suppressing_tests
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 if [istarget "*-*-vxworks*"] {
     set timeout 120
     verbose "Timeout is now $timeout seconds" 2
diff --git a/gdb/testsuite/gdb.base/sep.exp b/gdb/testsuite/gdb.base/sep.exp
index af50d17..7034d03 100644
--- a/gdb/testsuite/gdb.base/sep.exp
+++ b/gdb/testsuite/gdb.base/sep.exp
@@ -13,9 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "sep"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
     untested sep.exp
@@ -24,10 +22,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 set location [gdb_get_line_number "say_hello" "sep-proc.c"]
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 # Try to display the source code inside a file which is included by
 # another source file.  The purpose of this test is to verify that
diff --git a/gdb/testsuite/gdb.base/sepsymtab.exp b/gdb/testsuite/gdb.base/sepsymtab.exp
index 407a9b0..d19075e 100644
--- a/gdb/testsuite/gdb.base/sepsymtab.exp
+++ b/gdb/testsuite/gdb.base/sepsymtab.exp
@@ -17,9 +17,7 @@
 # test running programs
 #
 
-set testfile "sepsymtab"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}${EXEEXT}
+standard_testfile .c
 
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 	  executable {debug}] != "" } {
@@ -33,10 +31,7 @@ if [gdb_gnu_strip_debug $binfile no-main] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 set command "info sym main"
 set command_regex [string_to_regexp $command]
diff --git a/gdb/testsuite/gdb.base/set-lang-auto.exp b/gdb/testsuite/gdb.base/set-lang-auto.exp
index 617310e..e2f3694 100644
--- a/gdb/testsuite/gdb.base/set-lang-auto.exp
+++ b/gdb/testsuite/gdb.base/set-lang-auto.exp
@@ -14,21 +14,13 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile start
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "Couldn't compile test program"
+standard_testfile start.c
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # Do not run the inferior as the purpose of this testcase is to test
 # the behavior of the "set language" command when there is no inferior.
 
diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp
index e172fc7..661431c 100644
--- a/gdb/testsuite/gdb.base/setshow.exp
+++ b/gdb/testsuite/gdb.base/setshow.exp
@@ -16,9 +16,8 @@
 # This file was written by Michael Snyder (msnyder@cygnus.com)
 
 
-set testfile "setshow"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable {debug}] != "" } {
      untested setshow.exp
      return -1
@@ -26,10 +25,7 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable {debug}]
 
 # Start with a fresh gdb
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 # make sure $pc is sane, in case we're talking to a board.
 if { ![runto_main] } {
diff --git a/gdb/testsuite/gdb.base/setvar.exp b/gdb/testsuite/gdb.base/setvar.exp
index 1c58300..9970499 100644
--- a/gdb/testsuite/gdb.base/setvar.exp
+++ b/gdb/testsuite/gdb.base/setvar.exp
@@ -24,13 +24,7 @@
 # test running programs
 #
 
-set testfile "setvar"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested setvar.exp
-     return -1
-}
+standard_testfile
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
@@ -38,10 +32,10 @@ if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
+}
 
 #
 # set it up at a breakpoint so we canplay with the variable values
diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp
index 747aaa5..326112d 100644
--- a/gdb/testsuite/gdb.base/shlib-call.exp
+++ b/gdb/testsuite/gdb.base/shlib-call.exp
@@ -33,15 +33,12 @@ if {[skip_shlib_tests]} {
     return 0
 }
 
-set testfile "shmain"
-set libfile1 "shr1"
-set libfile2 "shr2"
-set srcfile  ${srcdir}/${subdir}/${testfile}.c
-set lib1src  ${srcdir}/${subdir}/${libfile1}.c
-set lib2src  ${srcdir}/${subdir}/${libfile2}.c
-set lib1     ${objdir}/${subdir}/${libfile1}.sl
-set lib2     ${objdir}/${subdir}/${libfile2}.sl
-set binfile  ${objdir}/${subdir}/${testfile}
+standard_testfile shmain.c shr1.c shr2.c
+set srcfile  ${srcdir}/${subdir}/${srcfile}
+set lib1src  ${srcdir}/${subdir}/${srcfile2}
+set lib2src  ${srcdir}/${subdir}/${srcfile3}
+set lib1     [standard_output_file shr1.sl]
+set lib2     [standard_output_file shr2.sl]
 
 set lib_opts "debug"
 set exec_opts [list debug shlib=${lib1} shlib=${lib2}]
@@ -59,10 +56,7 @@ if { [gdb_compile_shlib ${lib1src} ${lib1} $lib_opts] != ""
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 gdb_load_shlibs $lib1 $lib2
 
 gdb_test_no_output "set print sevenbit-strings"
diff --git a/gdb/testsuite/gdb.base/shreloc.exp b/gdb/testsuite/gdb.base/shreloc.exp
index f93b03e..2baf676 100644
--- a/gdb/testsuite/gdb.base/shreloc.exp
+++ b/gdb/testsuite/gdb.base/shreloc.exp
@@ -28,16 +28,14 @@ if {[skip_shlib_tests]} {
 #
 
 
-set workdir ${objdir}/${subdir}
-set testfile "shreloc"
-set libfile1 "shreloc1"
-set libfile2 "shreloc2"
-set srcfile $srcdir/$subdir/$testfile.c
-set lib1src $srcdir/$subdir/$libfile1.c
-set lib2src $srcdir/$subdir/$libfile2.c
-set binfile $objdir/$subdir/$testfile
-set lib1_sl $objdir/$subdir/$libfile1.sl
-set lib2_sl $objdir/$subdir/$libfile2.sl
+standard_testfile .c shreloc1.c shreloc2.c
+
+set srcfile $srcdir/$subdir/$srcfile
+set lib1src $srcdir/$subdir/$srcfile2
+set lib2src $srcdir/$subdir/$srcfile3
+set binfile [standard_output_file $testfile]
+set lib1_sl [standard_output_file shreloc1.sl]
+set lib2_sl [standard_output_file shreloc2.sl]
 
 if [get_compiler_info] {
     return -1
@@ -73,10 +71,7 @@ if { [gdb_compile_shlib $lib1src $lib1_sl $lib_opts] != ""} {
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${workdir}/shreloc
+clean_restart $binfile
 gdb_load_shlibs $lib1_sl $lib2_sl
 
 # Load up the shared objects
@@ -226,7 +221,7 @@ proc check_different {var msymfile} {
     return 1
 }
 
-set msymfile "${workdir}/shreloc.txt"
+set msymfile [standard_output_file shreloc.txt]
 
 if [send_gdb_discard "maint print msymbols ${msymfile}"] {
     if {[check_different "static_var_\[12\]" "${msymfile}"]} {
diff --git a/gdb/testsuite/gdb.base/sigall.exp b/gdb/testsuite/gdb.base/sigall.exp
index 4bd0427..b1b8597 100644
--- a/gdb/testsuite/gdb.base/sigall.exp
+++ b/gdb/testsuite/gdb.base/sigall.exp
@@ -18,17 +18,11 @@ if [target_info exists gdb,nosignals] {
     continue
 }
 
+standard_testfile
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
-set testfile sigall
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested sigall.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
 }
 
 proc test_one_sig {nextsig} {
@@ -98,8 +92,6 @@ proc test_one_sig {nextsig} {
     set thissig $nextsig
 }
 
-gdb_load $binfile
-
 # The list of signals that the program generates, in the order they
 # are generated.
 set signals {
diff --git a/gdb/testsuite/gdb.base/sigaltstack.exp b/gdb/testsuite/gdb.base/sigaltstack.exp
index 4fc5ac8..3171318 100644
--- a/gdb/testsuite/gdb.base/sigaltstack.exp
+++ b/gdb/testsuite/gdb.base/sigaltstack.exp
@@ -28,19 +28,15 @@ if [target_info exists gdb,nosignals] {
 }
 
 
-set testfile sigaltstack
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested "Couldn't compile ${srcfile}.c"
     return -1
 }
 
 # get things started
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 # Pass all the alarms straight through (but verbosely)
 gdb_test "handle SIGALRM print pass nostop"
diff --git a/gdb/testsuite/gdb.base/sigbpt.exp b/gdb/testsuite/gdb.base/sigbpt.exp
index 51545da..eb16b8e 100644
--- a/gdb/testsuite/gdb.base/sigbpt.exp
+++ b/gdb/testsuite/gdb.base/sigbpt.exp
@@ -34,19 +34,13 @@ if [target_info exists gdb,nosignals] {
 }
 
 
-set testfile "sigbpt"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested sigbpt.exp
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 #
 # Run to `main' where we begin our tests.
 #
diff --git a/gdb/testsuite/gdb.base/sigchld.exp b/gdb/testsuite/gdb.base/sigchld.exp
index ce88576..ab2a37f 100644
--- a/gdb/testsuite/gdb.base/sigchld.exp
+++ b/gdb/testsuite/gdb.base/sigchld.exp
@@ -21,18 +21,13 @@ if [target_info exists gdb,nosignals] {
     continue
 }
 
-set testfile "sigchld"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 runto_main
 
diff --git a/gdb/testsuite/gdb.base/siginfo-addr.exp b/gdb/testsuite/gdb.base/siginfo-addr.exp
index 02810e8..021d5d1 100644
--- a/gdb/testsuite/gdb.base/siginfo-addr.exp
+++ b/gdb/testsuite/gdb.base/siginfo-addr.exp
@@ -31,20 +31,12 @@ if [gdb_skip_stdio_test "siginfo-addr.exp"] {
 }
 
 
-set testfile siginfo-addr
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+standard_testfile
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
     untested "Couldn't compile ${srcfile}.c"
     return -1
 }
 
-# get things started
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test "display/i \$pc"
 
 # Advance to main
diff --git a/gdb/testsuite/gdb.base/siginfo-infcall.exp b/gdb/testsuite/gdb.base/siginfo-infcall.exp
index 7d17b70..ed034be 100644
--- a/gdb/testsuite/gdb.base/siginfo-infcall.exp
+++ b/gdb/testsuite/gdb.base/siginfo-infcall.exp
@@ -18,10 +18,9 @@ if [target_info exists gdb,nosignals] {
     continue
 }
 
-set testfile siginfo-infcall
-set srcfile ${testfile}.c
-set executable ${testfile}
-if { [prepare_for_testing ${testfile}.exp $executable] } {
+standard_testfile .c
+
+if { [prepare_for_testing ${testfile}.exp $testfile $srcfile] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/siginfo-obj.exp b/gdb/testsuite/gdb.base/siginfo-obj.exp
index cebc2ee..6cee02e 100644
--- a/gdb/testsuite/gdb.base/siginfo-obj.exp
+++ b/gdb/testsuite/gdb.base/siginfo-obj.exp
@@ -34,20 +34,13 @@ if { ! [istarget "i?86-*-linux*"]
 }
 
 
-set testfile siginfo-obj
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "Couldn't compile ${srcfile}.c"
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-# get things started
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # Advance to main
 if { ![runto_main] } then {
     gdb_suppress_tests
diff --git a/gdb/testsuite/gdb.base/siginfo.exp b/gdb/testsuite/gdb.base/siginfo.exp
index 5389e0b..036d1a5 100644
--- a/gdb/testsuite/gdb.base/siginfo.exp
+++ b/gdb/testsuite/gdb.base/siginfo.exp
@@ -29,20 +29,13 @@ if [target_info exists gdb,nosignals] {
 }
 
 
-set testfile siginfo
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "Couldn't compile ${srcfile}.c"
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-# get things started
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test "display/i \$pc"
 
 # Advance to main
diff --git a/gdb/testsuite/gdb.base/signals.exp b/gdb/testsuite/gdb.base/signals.exp
index 7652ff0..667368c 100644
--- a/gdb/testsuite/gdb.base/signals.exp
+++ b/gdb/testsuite/gdb.base/signals.exp
@@ -19,9 +19,8 @@ if [target_info exists gdb,nosignals] {
 }
 
 
-set testfile signals
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested signals.exp
     return -1
@@ -74,10 +73,7 @@ proc test_handle_all_print {} {
 }
 test_handle_all_print
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+clean_restart $binfile
 
 if [runto_main] then {
 
diff --git a/gdb/testsuite/gdb.base/signest.exp b/gdb/testsuite/gdb.base/signest.exp
index 67dc6ee..de000f3 100644
--- a/gdb/testsuite/gdb.base/signest.exp
+++ b/gdb/testsuite/gdb.base/signest.exp
@@ -15,8 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "signest"
-set srcfile ${testfile}.c
+standard_testfile
 
 if [target_info exists gdb,nosignals] {
     verbose "Skipping ${testfile}.exp because of nosignals."
diff --git a/gdb/testsuite/gdb.base/signull.exp b/gdb/testsuite/gdb.base/signull.exp
index 5fadd3a..e440c17 100644
--- a/gdb/testsuite/gdb.base/signull.exp
+++ b/gdb/testsuite/gdb.base/signull.exp
@@ -33,18 +33,14 @@ if [target_info exists gdb,nosignals] {
 }
 
 
-set testfile "signull"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested signull.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 #
 # Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.base/sigrepeat.exp b/gdb/testsuite/gdb.base/sigrepeat.exp
index 3b423ec..08beed3 100644
--- a/gdb/testsuite/gdb.base/sigrepeat.exp
+++ b/gdb/testsuite/gdb.base/sigrepeat.exp
@@ -25,19 +25,15 @@ if [target_info exists gdb,nosignals] {
 }
 
 
-set testfile sigrepeat
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested "Couldn't compile ${srcfile}"
     return -1
 }
 
 # get things started
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 # Advance to main
 if { ![runto_main] } then {
diff --git a/gdb/testsuite/gdb.base/sigstep.exp b/gdb/testsuite/gdb.base/sigstep.exp
index e8ab8ea..9515c61 100644
--- a/gdb/testsuite/gdb.base/sigstep.exp
+++ b/gdb/testsuite/gdb.base/sigstep.exp
@@ -27,20 +27,13 @@ if [target_info exists gdb,nosignals] {
 }
 
 
-set testfile sigstep
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "Couldn't compile ${srcfile}.c"
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-# get things started
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test "display/i \$pc"
 
 # Advance to main
diff --git a/gdb/testsuite/gdb.base/sizeof.exp b/gdb/testsuite/gdb.base/sizeof.exp
index 03972bb..af59e3b 100644
--- a/gdb/testsuite/gdb.base/sizeof.exp
+++ b/gdb/testsuite/gdb.base/sizeof.exp
@@ -24,22 +24,16 @@ if [target_info exists gdb,noinferiorio] {
 # test running programs
 #
 
-set testfile "sizeof"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested sizeof.exp
-     return -1
-}
+standard_testfile
 
 if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
+}
 
 #
 # set it up at a breakpoint so we can play with the variable values
diff --git a/gdb/testsuite/gdb.base/skip-solib.exp b/gdb/testsuite/gdb.base/skip-solib.exp
index 14bf6bf..f618fc5 100644
--- a/gdb/testsuite/gdb.base/skip-solib.exp
+++ b/gdb/testsuite/gdb.base/skip-solib.exp
@@ -27,10 +27,10 @@ if { ![isnative] || [is_remote host] || ![istarget *-linux*] || [skip_shlib_test
 set test "skip-solib"
 set srcfile_main "${test}-main.c"
 set executable_main ${test}-test
-set binfile_main ${objdir}/${subdir}/${executable_main}
+set binfile_main [standard_output_file ${executable_main}]
 set srcfile_lib "${test}-lib.c"
 set libname "lib${test}"
-set binfile_lib ${objdir}/${subdir}/${libname}.so
+set binfile_lib [standard_output_file ${libname}.so]
 
 #
 # Compile our program under test.  The main program references a shared library
@@ -47,9 +47,10 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile_main}" "${binfile_main}.o" objec
     return -1
 }
 
+set testobjdir [standard_output_file {}]
 if {[gdb_compile "${binfile_main}.o" "${binfile_main}" executable \
-                 [list debug "additional_flags=-L${objdir}/${subdir} -l${test} \
-                                               -Wl,-rpath=${objdir}/${subdir}"]] != ""} {
+                 [list debug "additional_flags=-L$testobjdir -l${test} \
+                                               -Wl,-rpath=$testobjdir"]] != ""} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/so-impl-ld.exp b/gdb/testsuite/gdb.base/so-impl-ld.exp
index 64fc781..a1d0281 100644
--- a/gdb/testsuite/gdb.base/so-impl-ld.exp
+++ b/gdb/testsuite/gdb.base/so-impl-ld.exp
@@ -18,12 +18,10 @@ if {[skip_shlib_tests]} {
     return 0
 }
 
-set testfile "so-impl-ld"
+standard_testfile .c
 set libfile "solib1"
-set srcfile $srcdir/$subdir/$testfile.c
 set libsrc  $srcdir/$subdir/$libfile.c
-set binfile $objdir/$subdir/$testfile
-set lib_sl  $objdir/$subdir/$libfile.sl
+set lib_sl  [standard_output_file $libfile.sl]
 
 set lib_opts  debug
 set exec_opts [list debug shlib=$lib_sl]
@@ -41,17 +39,15 @@ if [test_compiler_info "hpcc-*"] {
 }
 
 if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
-     || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} {
+     || [gdb_compile $srcdir/$subdir/$srcfile $binfile \
+	     executable $exec_opts] != ""} {
     untested "Couldn't compile $libsrc or $srcfile."
     return -1
 }
 
 # Start with a fresh gdb
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 gdb_load_shlibs $lib_sl
 
 # This program implicitly loads SOM shared libraries.
diff --git a/gdb/testsuite/gdb.base/solib-display.exp b/gdb/testsuite/gdb.base/solib-display.exp
index 817846c..928719d 100644
--- a/gdb/testsuite/gdb.base/solib-display.exp
+++ b/gdb/testsuite/gdb.base/solib-display.exp
@@ -35,13 +35,13 @@ if { [skip_shlib_tests] || [is_remote target] } {
 # Library file.
 set libname "solib-display-lib"
 set srcfile_lib ${srcdir}/${subdir}/${libname}.c
-set binfile_lib ${objdir}/${subdir}/${libname}.so
+set binfile_lib [standard_output_file ${libname}.so]
 set lib_flags {}
 # Binary file.
 set testfile "solib-display-main"
 set srcfile ${srcdir}/${subdir}/${testfile}.c
 set executable ${testfile}
-set binfile ${objdir}/${subdir}/${executable}
+set binfile [standard_output_file ${executable}]
 set bin_flags [list debug shlib=${binfile_lib}]
 
 if [get_compiler_info] {
diff --git a/gdb/testsuite/gdb.base/solib-nodir.exp b/gdb/testsuite/gdb.base/solib-nodir.exp
index 2ed48a5..34d9410 100644
--- a/gdb/testsuite/gdb.base/solib-nodir.exp
+++ b/gdb/testsuite/gdb.base/solib-nodir.exp
@@ -24,11 +24,11 @@ set srclibfile foo.c
 # Arbitrary file containing main.
 set srcfile start.c
 set binlibfilebase ${testfile}.so
-set binlibfiledir ${objdir}/${subdir}
+set binlibfiledir [standard_output_file {}]
 set binlibfile ${binlibfiledir}/${binlibfilebase}
 set executable ${testfile}
-set objfile ${objdir}/${subdir}/${executable}.o
-set binfile ${objdir}/${subdir}/${executable}
+set objfile [standard_output_file ${executable}.o]
+set binfile [standard_output_file ${executable}]
 
 # build the first test case
 if { [get_compiler_info]
diff --git a/gdb/testsuite/gdb.base/solib-overlap.exp b/gdb/testsuite/gdb.base/solib-overlap.exp
index ba1e1ad..068c1de 100644
--- a/gdb/testsuite/gdb.base/solib-overlap.exp
+++ b/gdb/testsuite/gdb.base/solib-overlap.exp
@@ -56,14 +56,14 @@ foreach prelink_lib1 {0x40000000 0x50000000} { with_test_prefix "$prelink_lib1"
     set prelink_lib2 [format "0x%x" [expr $prelink_lib1 + 0x01000000]]
 
     # Library file.
-    set binfile_lib1 ${objdir}/${subdir}/${libname}1-${prelink_lib1}.so
+    set binfile_lib1 [standard_output_file ${libname}1-${prelink_lib1}.so]
     set binfile_lib1_test_msg OBJDIR/${subdir}/${libname}1-${prelink_lib1}.so
-    set binfile_lib2 ${objdir}/${subdir}/${libname}2-${prelink_lib1}.so
+    set binfile_lib2 [standard_output_file ${libname}2-${prelink_lib1}.so]
     set binfile_lib2_test_msg OBJDIR/${subdir}/${libname}2-${prelink_lib1}.so
     set lib_flags {debug}
     # Binary file.
     set binfile_base ${testfile}-${prelink_lib1}
-    set binfile ${objdir}/${subdir}/${binfile_base}
+    set binfile [standard_output_file ${binfile_base}]
     set binfile_test_msg OBJDIR/${subdir}/${binfile_base}
     set bin_flags [list debug shlib=${binfile_lib1} shlib=${binfile_lib2}]
     set escapedbinfile  [string_to_regexp ${binfile}]
diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/solib-symbol.exp
index b758a68..9ffe7fe 100644
--- a/gdb/testsuite/gdb.base/solib-symbol.exp
+++ b/gdb/testsuite/gdb.base/solib-symbol.exp
@@ -22,12 +22,12 @@ if {[skip_shlib_tests]} {
 # Library file.
 set libname "solib-symbol-lib"
 set srcfile_lib ${srcdir}/${subdir}/${libname}.c
-set binfile_lib ${objdir}/${subdir}/${libname}.so
+set binfile_lib [standard_output_file ${libname}.so]
 set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
 # Binary file.
 set testfile "solib-symbol-main"
 set srcfile ${srcdir}/${subdir}/${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+set binfile [standard_output_file ${testfile}]
 set bin_flags [list debug shlib=${binfile_lib}]
 
 if [get_compiler_info] {
diff --git a/gdb/testsuite/gdb.base/solib-weak.exp b/gdb/testsuite/gdb.base/solib-weak.exp
index 11c3830..5951806 100644
--- a/gdb/testsuite/gdb.base/solib-weak.exp
+++ b/gdb/testsuite/gdb.base/solib-weak.exp
@@ -39,7 +39,7 @@ if {![test_compiler_info "gcc-*"]} {
 }
 
 proc do_test { lib1opts lib2opts lib1first } {
-    global objdir srcdir subdir
+    global srcdir subdir
 
     set testfile "solib-weak"
     set srcfile ${testfile}.c
@@ -72,9 +72,9 @@ proc do_test { lib1opts lib2opts lib1first } {
 	append testfile "-lib2"
     }
 
-    set binfile ${objdir}/${subdir}/${testfile}
-    set lib1 ${objdir}/${subdir}/${libfile1}.sl
-    set lib2 ${objdir}/${subdir}/${libfile2}.sl
+    set binfile [standard_output_file ${testfile}]
+    set lib1 [standard_output_file ${libfile1}.sl]
+    set lib2 [standard_output_file ${libfile2}.sl]
 
     if $lib1first {
 	set exec_opts [list debug shlib=${lib1} shlib=${lib2}]
diff --git a/gdb/testsuite/gdb.base/source.exp b/gdb/testsuite/gdb.base/source.exp
index a398e77..61fd221 100644
--- a/gdb/testsuite/gdb.base/source.exp
+++ b/gdb/testsuite/gdb.base/source.exp
@@ -19,9 +19,7 @@
 
 
 
-set testfile "structs"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile structs.c
 
 gdb_start
 
diff --git a/gdb/testsuite/gdb.base/stack-checking.exp b/gdb/testsuite/gdb.base/stack-checking.exp
index 47d02e9..0c1fb51 100644
--- a/gdb/testsuite/gdb.base/stack-checking.exp
+++ b/gdb/testsuite/gdb.base/stack-checking.exp
@@ -14,19 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile "stack-checking"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug additional_flags=-fstack-check nowarnings]] != "" } {
      untested stack-checking.exp
      return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto_main] then {
     fail "Can't run to main"
diff --git a/gdb/testsuite/gdb.base/stale-infcall.exp b/gdb/testsuite/gdb.base/stale-infcall.exp
index 074fabb..deddf61 100644
--- a/gdb/testsuite/gdb.base/stale-infcall.exp
+++ b/gdb/testsuite/gdb.base/stale-infcall.exp
@@ -13,8 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile stale-infcall
-set srcfile ${testfile}.c
+standard_testfile .c
+
 if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
     return -1
 }
diff --git a/gdb/testsuite/gdb.base/stap-probe.exp b/gdb/testsuite/gdb.base/stap-probe.exp
index 048e082..0f2b028 100644
--- a/gdb/testsuite/gdb.base/stap-probe.exp
+++ b/gdb/testsuite/gdb.base/stap-probe.exp
@@ -13,15 +13,15 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile stap-probe
+standard_testfile
 
 # Run the tests.  We run the tests two different ways: once with a
 # plain probe, and once with a probe that has an associated semaphore.
 # This returns -1 on failure to compile or start, 0 otherwise.
 proc stap_test {exec_name {arg ""}} {
-    global testfile hex
+    global testfile hex srcfile
 
-    if {[prepare_for_testing ${testfile}.exp ${exec_name} ${testfile}.c \
+    if {[prepare_for_testing ${testfile}.exp ${exec_name} $srcfile \
 	   [concat $arg debug]]} {
 	return -1
     }
diff --git a/gdb/testsuite/gdb.base/start.exp b/gdb/testsuite/gdb.base/start.exp
index 6f1f517..296d17a 100644
--- a/gdb/testsuite/gdb.base/start.exp
+++ b/gdb/testsuite/gdb.base/start.exp
@@ -14,21 +14,13 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile start
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "Couldn't compile test program"
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # This is a testcase specifically for the `start' GDB command.  For regular
 # stop-in-main goal in the testcases consider using `runto_main' instead.
 
diff --git a/gdb/testsuite/gdb.base/step-break.exp b/gdb/testsuite/gdb.base/step-break.exp
index ca091af..29c2a3b 100644
--- a/gdb/testsuite/gdb.base/step-break.exp
+++ b/gdb/testsuite/gdb.base/step-break.exp
@@ -15,20 +15,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile step-break
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
      untested step-break.exp
      return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 if ![runto_main] then {
    fail "Can't run to main"
    return 0
diff --git a/gdb/testsuite/gdb.base/step-bt.exp b/gdb/testsuite/gdb.base/step-bt.exp
index f5b57ce..03fc453 100644
--- a/gdb/testsuite/gdb.base/step-bt.exp
+++ b/gdb/testsuite/gdb.base/step-bt.exp
@@ -17,21 +17,13 @@
 # single-stepping the instructions that prepare to call a function.
 
 
-set testfile step-bt
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "Couldn't compile test program"
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test "break *hello" \
          "Breakpoint.*at.* file .*$srcfile, line .*" \
          "breakpoint at first instruction of hello()"
diff --git a/gdb/testsuite/gdb.base/step-line.exp b/gdb/testsuite/gdb.base/step-line.exp
index 1be5dae..bc8f2bc 100644
--- a/gdb/testsuite/gdb.base/step-line.exp
+++ b/gdb/testsuite/gdb.base/step-line.exp
@@ -20,22 +20,14 @@
 # step-line.exp -- Expect script to test stepping in files with
 # #line directives.
 
-set testfile step-line
-set srcfile ${testfile}.c
+standard_testfile
 set linefile ${testfile}.inp
-set binfile ${objdir}/${subdir}/${testfile}
 
-remote_exec build "rm -f ${binfile}"
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested step-line.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 if ![runto_main] then {
    fail "Can't run to main"
    return 0
diff --git a/gdb/testsuite/gdb.base/step-resume-infcall.exp b/gdb/testsuite/gdb.base/step-resume-infcall.exp
index 44af3cb..176bede 100644
--- a/gdb/testsuite/gdb.base/step-resume-infcall.exp
+++ b/gdb/testsuite/gdb.base/step-resume-infcall.exp
@@ -13,9 +13,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "step-resume-infcall"
+standard_testfile
 
-if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
+if { [prepare_for_testing ${testfile}.exp ${testfile} $srcfile] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/step-test.exp b/gdb/testsuite/gdb.base/step-test.exp
index a493f82..c05b4de 100644
--- a/gdb/testsuite/gdb.base/step-test.exp
+++ b/gdb/testsuite/gdb.base/step-test.exp
@@ -16,9 +16,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 # step-test.exp -- Expect script to test stepping in gdb
 
-set testfile step-test
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 remote_exec build "rm -f ${binfile}"
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -26,10 +24,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
      return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto_main] then {
    fail "Can't run to main"
diff --git a/gdb/testsuite/gdb.base/structs.exp b/gdb/testsuite/gdb.base/structs.exp
index 2aa181e..1fe4c28 100644
--- a/gdb/testsuite/gdb.base/structs.exp
+++ b/gdb/testsuite/gdb.base/structs.exp
@@ -25,9 +25,7 @@ if [target_info exists gdb,cannot_call_functions] {
     continue
 }
 
-set testfile "structs"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 # Regex matching any value of `char' type like: a = 65 'A'
 set anychar_re {-?[0-9]{1,3} '(.|\\([0-7]{3}|[a-z]|\\|'))'}
@@ -49,7 +47,6 @@ proc start_structs_test { types } {
     global testfile
     global srcfile
     global binfile
-    global objdir
     global subdir
     global srcdir
     global gdb_prompt
@@ -67,7 +64,7 @@ proc start_structs_test { types } {
 	append testfile "-" "$t"
     }
 
-    set binfile ${objdir}/${subdir}/${testfile}
+    set binfile [standard_output_file ${testfile}]
     if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } {
 	# built the second test case since we can't use prototypes
 	warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
diff --git a/gdb/testsuite/gdb.base/structs2.exp b/gdb/testsuite/gdb.base/structs2.exp
index 0753086..fc77cd7 100644
--- a/gdb/testsuite/gdb.base/structs2.exp
+++ b/gdb/testsuite/gdb.base/structs2.exp
@@ -14,9 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 set prototypes 1
-set testfile "structs2"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
@@ -37,9 +35,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 # Start with a fresh gdb.
 
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 gdb_test_no_output "set width 0"
 
diff --git a/gdb/testsuite/gdb.base/structs3.exp b/gdb/testsuite/gdb.base/structs3.exp
index e11d171..251c9b7 100644
--- a/gdb/testsuite/gdb.base/structs3.exp
+++ b/gdb/testsuite/gdb.base/structs3.exp
@@ -15,9 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "structs3"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if { [prepare_for_testing structs3.exp "structs3" "" {debug}] } {
     return -1
diff --git a/gdb/testsuite/gdb.base/symbol-without-target_section.exp b/gdb/testsuite/gdb.base/symbol-without-target_section.exp
index 76ef840..45af158 100644
--- a/gdb/testsuite/gdb.base/symbol-without-target_section.exp
+++ b/gdb/testsuite/gdb.base/symbol-without-target_section.exp
@@ -18,22 +18,20 @@
 # Such file is ${binmainfile} through add-symbol-file here.  Set context first
 # by "list main" to have some local BLOCK set in lookup_symbol_global.
 
-set testfile symbol-without-target_section
-set srclibfile ${testfile}.c
+standard_testfile start.c .c
 set binlibfile ${testfile}.x
-set srcmainfile start.c
-set binmainfile ${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srclibfile}" \
-		  "${objdir}/${subdir}/${binlibfile}" object {debug}] != "" } {
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" \
+		  [standard_output_file ${binlibfile}] object {debug}] != "" } {
     untested ${testfile}.exp
     return -1
 }
-if {[build_executable ${testfile}.exp ${binmainfile} ${srcmainfile} {debug}] == -1} {
+if {[build_executable ${testfile}.exp ${testfile} ${srcfile} {debug}] == -1} {
     return -1
 }
 clean_restart ${binlibfile}
 
-gdb_test "add-symbol-file ${objdir}/${subdir}/${binmainfile} 0" \
+gdb_test "add-symbol-file [standard_output_file ${testfile}] 0" \
     "Reading symbols from .*" \
     "add-symbol-file" \
     "add symbol table from file \".*\" at.*\\(y or n\\) " "y"
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/7] test suite update - gdb.base/[ab]
  2013-06-19 21:04 [PATCH 0/7] first batch of test suite updates Tom Tromey
  2013-06-19 21:04 ` [PATCH 6/7] test suite update - gdb.base/s* Tom Tromey
@ 2013-06-19 21:04 ` Tom Tromey
  2013-07-01  8:19   ` [patch] testsuite build regression on CentOS-5 [Re: [PATCH 1/7] test suite update - gdb.base/[ab]] Jan Kratochvil
  2013-06-19 21:04 ` [PATCH 7/7] test suite update - gdb.base/[t-z] Tom Tromey
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Tom Tromey @ 2013-06-19 21:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Files gdb.base/[ab]*.exp.
See message #0 for details.

	* a2-run.exp, all-bin.exp, annota1.exp, annota3.exp, anon.exp,
	args.exp, arithmet.exp, arrayidx.exp, assign.exp, async-shell.exp,
	async.exp, attach-pie-misread.exp, attach-pie-noexec.exp,
	attach-twice.exp, attach.exp, auxv.exp, bang.exp, bfp-test.exp,
	bigcore.exp, bitfields.exp, bitfields2.exp, break-entry.exp,
	break-interp.exp, break-on-linker-gcd-function.exp,
	breakpoint-shadow.exp: Use standard_testfile,
	standard_output_file, prepare_for_testing, clean_restart.
---
 gdb/testsuite/gdb.base/a2-run.exp                    |  5 +++--
 gdb/testsuite/gdb.base/all-bin.exp                   | 18 +++++-------------
 gdb/testsuite/gdb.base/annota1.exp                   | 13 ++++---------
 gdb/testsuite/gdb.base/annota3.exp                   |  9 ++-------
 gdb/testsuite/gdb.base/anon.exp                      |  4 ++--
 gdb/testsuite/gdb.base/args.exp                      | 20 ++++++--------------
 gdb/testsuite/gdb.base/arithmet.exp                  | 19 ++++++-------------
 gdb/testsuite/gdb.base/arrayidx.exp                  | 10 +++-------
 gdb/testsuite/gdb.base/assign.exp                    | 10 ++--------
 gdb/testsuite/gdb.base/async-shell.exp               |  4 ++--
 gdb/testsuite/gdb.base/async.exp                     | 10 ++++------
 gdb/testsuite/gdb.base/attach-pie-misread.exp        | 10 ++++------
 gdb/testsuite/gdb.base/attach-pie-noexec.exp         |  3 +--
 gdb/testsuite/gdb.base/attach-twice.exp              |  3 +--
 gdb/testsuite/gdb.base/attach.exp                    | 12 ++++--------
 gdb/testsuite/gdb.base/auxv.exp                      | 16 ++++++----------
 gdb/testsuite/gdb.base/bang.exp                      | 12 +++---------
 gdb/testsuite/gdb.base/bfp-test.exp                  | 10 +++-------
 gdb/testsuite/gdb.base/bigcore.exp                   | 11 +++--------
 gdb/testsuite/gdb.base/bitfields.exp                 | 13 ++++---------
 gdb/testsuite/gdb.base/bitfields2.exp                |  9 +++------
 gdb/testsuite/gdb.base/break-entry.exp               |  4 ++--
 gdb/testsuite/gdb.base/break-interp.exp              | 11 ++++++-----
 .../gdb.base/break-on-linker-gcd-function.exp        | 12 ++++--------
 gdb/testsuite/gdb.base/breakpoint-shadow.exp         | 14 ++++----------
 25 files changed, 87 insertions(+), 175 deletions(-)

diff --git a/gdb/testsuite/gdb.base/a2-run.exp b/gdb/testsuite/gdb.base/a2-run.exp
index bd70928..c8467dc 100644
--- a/gdb/testsuite/gdb.base/a2-run.exp
+++ b/gdb/testsuite/gdb.base/a2-run.exp
@@ -24,8 +24,9 @@ if [gdb_skip_stdio_test "a2run.exp"] {
 # test running programs
 #
 
-set testfile a2-run
-if { [prepare_for_testing ${testfile}.exp $testfile run.c] } {
+standard_testfile run.c
+
+if { [prepare_for_testing ${testfile}.exp $testfile $srcfile] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/all-bin.exp b/gdb/testsuite/gdb.base/all-bin.exp
index 53f6d5b..815844a 100644
--- a/gdb/testsuite/gdb.base/all-bin.exp
+++ b/gdb/testsuite/gdb.base/all-bin.exp
@@ -27,24 +27,16 @@
 # test running programs
 #
 
-set testfile "all-types"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
-    untested all-bin.exp
-    return -1
-    }
+standard_testfile all-types.c
 
 if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
+}
 
 #
 # set it up at a breakpoint so we can play with the variable values
diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp
index 2015154..541108a 100644
--- a/gdb/testsuite/gdb.base/annota1.exp
+++ b/gdb/testsuite/gdb.base/annota1.exp
@@ -31,9 +31,7 @@ set breakpoints_invalid "\r\n\032\032breakpoints-invalid\r\n"
 # test running programs
 #
 
-set testfile "annota1"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
     untested annota1.exp
@@ -41,10 +39,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 }
 
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 # The commands we test here produce many lines of output; disable "press 
 # <return> to continue" prompts.
@@ -445,10 +440,10 @@ if { [remote_file host exists core] } {
 }
 
 proc thread_test {} {
-    global objdir subdir srcdir testfile
+    global subdir srcdir testfile
     global gdb_prompt old_gdb_prompt
     set srcfile watch_thread_num.c
-    set binfile ${objdir}/${subdir}/${testfile}-watch_thread_num
+    set binfile [standard_output_file ${testfile}-watch_thread_num]
     set gdb_prompt $old_gdb_prompt
 
     if { ![get_compiler_info] && [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] == "" } {
diff --git a/gdb/testsuite/gdb.base/annota3.exp b/gdb/testsuite/gdb.base/annota3.exp
index a742d09..1d98a4f 100644
--- a/gdb/testsuite/gdb.base/annota3.exp
+++ b/gdb/testsuite/gdb.base/annota3.exp
@@ -30,9 +30,7 @@ if [is_remote target] then {
 # test running programs
 #
 
-set testfile "annota3"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}$EXEEXT
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
     untested annota3.exp
@@ -40,10 +38,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 }
 
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 # The commands we test here produce many lines of output; disable "press 
 # <return> to continue" prompts.
diff --git a/gdb/testsuite/gdb.base/anon.exp b/gdb/testsuite/gdb.base/anon.exp
index 3edb10a..6d69aac 100644
--- a/gdb/testsuite/gdb.base/anon.exp
+++ b/gdb/testsuite/gdb.base/anon.exp
@@ -14,8 +14,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-set testfile "anon"
-set srcfile $testfile.c
+standard_testfile .c
+
 if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug}] } {
     return -1
 }
diff --git a/gdb/testsuite/gdb.base/args.exp b/gdb/testsuite/gdb.base/args.exp
index 5ba9393..9fdbcaf 100644
--- a/gdb/testsuite/gdb.base/args.exp
+++ b/gdb/testsuite/gdb.base/args.exp
@@ -23,30 +23,22 @@ if [target_info exists noargs] {
     return
 }
 
-set testfile "args"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
-    untested args.exp
+if {[build_executable $testfile.exp $testfile \
+	 $srcfile {debug nowarnings}] == -1} {
+    untested $testfile.exp
     return -1
 }
 
 proc args_test { name arglist } {
     global srcdir
     global subdir
-    global binfile
+    global testfile
     global hex
     global decimal
 
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-
-    # No loading needs to be done when the target is `exec'.  Some targets
-    # require that the program be loaded, however, and it doesn't hurt
-    # for `exec'.
-    gdb_load $binfile
+    clean_restart $testfile
 
     runto_main
     gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
diff --git a/gdb/testsuite/gdb.base/arithmet.exp b/gdb/testsuite/gdb.base/arithmet.exp
index f44d1e2..4143f22 100644
--- a/gdb/testsuite/gdb.base/arithmet.exp
+++ b/gdb/testsuite/gdb.base/arithmet.exp
@@ -26,19 +26,12 @@
 # test running programs
 #
 
-set testfile "int-type"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
-     untested arithmet.exp
-     return -1
-    }
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+standard_testfile int-type.c
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug nowarnings}]} {
+    untested $testfile.exp
+    return -1
+}
 
 
 #
diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp
index 387b34f..37ed4c3 100644
--- a/gdb/testsuite/gdb.base/arrayidx.exp
+++ b/gdb/testsuite/gdb.base/arrayidx.exp
@@ -17,18 +17,14 @@
 # gdb can correctly print arrays with indexes for each element of the
 # array.
 
-set testfile "arrayidx"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested "Couldn't compile ${srcfile}"
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
diff --git a/gdb/testsuite/gdb.base/assign.exp b/gdb/testsuite/gdb.base/assign.exp
index fd9486a..61197ee 100644
--- a/gdb/testsuite/gdb.base/assign.exp
+++ b/gdb/testsuite/gdb.base/assign.exp
@@ -25,9 +25,7 @@
 # test running programs
 #
 
-set testfile "all-types"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile all-types.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
      untested assign.exp
@@ -35,11 +33,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     }
 
 
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 
 #
diff --git a/gdb/testsuite/gdb.base/async-shell.exp b/gdb/testsuite/gdb.base/async-shell.exp
index 89ceebe..186637c 100644
--- a/gdb/testsuite/gdb.base/async-shell.exp
+++ b/gdb/testsuite/gdb.base/async-shell.exp
@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile async-shell
+standard_testfile
 
 if { ![support_displaced_stepping] } { 
     unsupported "displaced stepping"
@@ -25,7 +25,7 @@ if [target_info exists use_gdb_stub] {
     return 0
 }
 
-if { [prepare_for_testing ${testfile}.exp ${testfile}] } {
+if { [prepare_for_testing ${testfile}.exp ${testfile} $srcfile] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp
index f75552e..11e0824 100644
--- a/gdb/testsuite/gdb.base/async.exp
+++ b/gdb/testsuite/gdb.base/async.exp
@@ -18,16 +18,14 @@
 # test running programs
 #
 
-set testfile "async"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
-    untested async.exp
+if [get_compiler_info] {
     return -1
 }
 
-if [get_compiler_info] {
+if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
+    untested $testfile.exp
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/attach-pie-misread.exp b/gdb/testsuite/gdb.base/attach-pie-misread.exp
index 0640a63..443804d 100644
--- a/gdb/testsuite/gdb.base/attach-pie-misread.exp
+++ b/gdb/testsuite/gdb.base/attach-pie-misread.exp
@@ -21,13 +21,11 @@ if { ![isnative] || [is_remote host] || [target_info exists use_gdb_stub]
 
 load_lib prelink-support.exp
 
-set test "attach-pie-misread"
-set srcfile ${test}.c
-set genfile ${objdir}/${subdir}/${test}-gen.h
-set executable ${test}
-set binfile ${objdir}/${subdir}/${executable}
+standard_testfile .c
+set genfile [standard_output_file ${testfile}-gen.h]
+set executable $testfile
 
-if {[build_executable_own_libs ${test}.exp $executable $srcfile [list additional_flags=-fPIE ldflags=-pie]] == ""} {
+if {[build_executable_own_libs ${testfile}.exp $executable $srcfile [list additional_flags=-fPIE ldflags=-pie]] == ""} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/attach-pie-noexec.exp b/gdb/testsuite/gdb.base/attach-pie-noexec.exp
index cb48a55..9aa5d83 100644
--- a/gdb/testsuite/gdb.base/attach-pie-noexec.exp
+++ b/gdb/testsuite/gdb.base/attach-pie-noexec.exp
@@ -18,9 +18,8 @@ if [is_remote target] then {
     return 0
 }
 
-set testfile attach-pie-noexec
+standard_testfile .c
 set executable ${testfile}
-set binfile ${objdir}/${subdir}/${executable}
 
 if { [prepare_for_testing ${testfile}.exp $executable "" [list debug "additional_flags=-fPIE -pie"]] } {
     return -1
diff --git a/gdb/testsuite/gdb.base/attach-twice.exp b/gdb/testsuite/gdb.base/attach-twice.exp
index 2a79c35..0a0035b 100644
--- a/gdb/testsuite/gdb.base/attach-twice.exp
+++ b/gdb/testsuite/gdb.base/attach-twice.exp
@@ -18,9 +18,8 @@ if [is_remote target] then {
     return 0
 }
 
-set testfile attach-twice
+standard_testfile
 set executable ${testfile}
-set binfile ${objdir}/${subdir}/${executable}
 
 if { [prepare_for_testing ${testfile}.exp $executable] } {
     return -1
diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp
index 929ac9a..edd3d0c 100644
--- a/gdb/testsuite/gdb.base/attach.exp
+++ b/gdb/testsuite/gdb.base/attach.exp
@@ -30,12 +30,9 @@ if [is_remote target] then {
     return 0
 }
 
-set testfile "attach"
-set srcfile  ${testfile}.c
-set srcfile2 ${testfile}2.c
-set binfile  ${objdir}/${subdir}/${testfile}
-set binfile2 ${objdir}/${subdir}/${testfile}2
-set escapedbinfile  [string_to_regexp ${objdir}/${subdir}/${testfile}]
+standard_testfile attach.c attach2.c
+set binfile2 ${binfile}2
+set escapedbinfile  [string_to_regexp $binfile]
 
 #execute_anywhere "rm -f ${binfile} ${binfile2}"
 remote_exec build "rm -f ${binfile} ${binfile2}"
@@ -67,7 +64,6 @@ proc do_attach_tests {} {
     global escapedbinfile
     global srcfile
     global testfile
-    global objdir
     global subdir
     global timeout
     
@@ -298,7 +294,7 @@ proc do_attach_tests {} {
     # when we're cd'd to some directory that doesn't contain the
     # a.out.  (We use the source path set by the "dir" command.)
     
-    gdb_test "dir ${objdir}/${subdir}" "Source directories searched: .*" \
+    gdb_test "dir [standard_output_file {}]" "Source directories searched: .*" \
 	"set source path"
 
     gdb_test "cd /tmp" "Working directory /tmp." \
diff --git a/gdb/testsuite/gdb.base/auxv.exp b/gdb/testsuite/gdb.base/auxv.exp
index b1d0662..ab51b2c 100644
--- a/gdb/testsuite/gdb.base/auxv.exp
+++ b/gdb/testsuite/gdb.base/auxv.exp
@@ -24,11 +24,10 @@ if { ! [istarget "*-*-linux*"] && ! [istarget "*-*-solaris*"] } {
 }
 
 
-set testfile "auxv"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-set corefile ${objdir}/${subdir}/${testfile}.corefile
-set gcorefile ${objdir}/${subdir}/${testfile}.gcore
+standard_testfile .c
+
+set corefile ${binfile}.corefile
+set gcorefile ${binfile}.gcore
 
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
 		  {debug additional_flags=-DUSE_RLIMIT}] != ""
@@ -40,16 +39,13 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
 
 # Use a fresh directory to confine the native core dumps.
 # Make it the working directory for gdb and its child.
-set coredir "${objdir}/${subdir}/coredir.[getpid]"
+set coredir [standard_output_file coredir.[getpid]]
 file mkdir $coredir
 set core_works [expr [isnative] && ! [is_remote target]]
 
 # Run GDB on the test program up to where it will dump core.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 gdb_test_no_output "set print sevenbit-strings"
 gdb_test_no_output "set width 0"
 
diff --git a/gdb/testsuite/gdb.base/bang.exp b/gdb/testsuite/gdb.base/bang.exp
index e1ef8cf..6fd3a59 100644
--- a/gdb/testsuite/gdb.base/bang.exp
+++ b/gdb/testsuite/gdb.base/bang.exp
@@ -16,20 +16,14 @@
 # This is a test that verifies that GDB is able to "run" when the name
 # of the executable file contains a '!'.
 
-set testfile "args"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/bang!
+standard_testfile args.c
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
+if {[prepare_for_testing $testfile.exp ${testfile}! $srcfile \
+	 {debug nowarnings}]} {
     untested bang.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # Verify that we can run the program and that it terminates normally.
 
 gdb_run_cmd
diff --git a/gdb/testsuite/gdb.base/bfp-test.exp b/gdb/testsuite/gdb.base/bfp-test.exp
index 5c55308..42830c4 100644
--- a/gdb/testsuite/gdb.base/bfp-test.exp
+++ b/gdb/testsuite/gdb.base/bfp-test.exp
@@ -16,18 +16,14 @@
 # This file is part of the gdb testsuite.  It is intended to test that
 # gdb could correctly handle floating point constant with a suffix.
 
-set testfile "bfp-test"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested "Couldn't compile ${srcfile}"
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
diff --git a/gdb/testsuite/gdb.base/bigcore.exp b/gdb/testsuite/gdb.base/bigcore.exp
index 5cc0144..ac3c5fb 100644
--- a/gdb/testsuite/gdb.base/bigcore.exp
+++ b/gdb/testsuite/gdb.base/bigcore.exp
@@ -46,10 +46,8 @@ if { [istarget "*-*-*irix*"] } {
     return
 }
 
-set testfile "bigcore"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-set corefile ${objdir}/${subdir}/${testfile}.corefile
+standard_testfile .c
+set corefile ${binfile}.corefile
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested bigcore.exp
@@ -58,10 +56,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 # Run GDB on the bigcore program up-to where it will dump core.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 gdb_test_no_output "set print sevenbit-strings"
 gdb_test_no_output "set width 0"
 
diff --git a/gdb/testsuite/gdb.base/bitfields.exp b/gdb/testsuite/gdb.base/bitfields.exp
index a5b85ea..ceba529 100644
--- a/gdb/testsuite/gdb.base/bitfields.exp
+++ b/gdb/testsuite/gdb.base/bitfields.exp
@@ -16,11 +16,10 @@
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
 
-set testfile "bitfields"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested bitfields.exp
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
@@ -270,10 +269,6 @@ proc bitfield_internalvar {} {
     gdb_test "print \$myvar.f" "\\$\[0-9\]\+ = -1"
 }
 
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test_no_output "set print sevenbit-strings"
 
 bitfield_uniqueness
diff --git a/gdb/testsuite/gdb.base/bitfields2.exp b/gdb/testsuite/gdb.base/bitfields2.exp
index 843da17..41a9e3b 100644
--- a/gdb/testsuite/gdb.base/bitfields2.exp
+++ b/gdb/testsuite/gdb.base/bitfields2.exp
@@ -23,9 +23,8 @@
 #
 
 
-set testfile "bitfields2"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested bitfields2.exp
     return -1
@@ -279,9 +278,7 @@ proc bitfield_set {} {
     gdb_stop_suppressing_tests
 }
 
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 gdb_test_no_output "set print sevenbit-strings"
 runto_main
diff --git a/gdb/testsuite/gdb.base/break-entry.exp b/gdb/testsuite/gdb.base/break-entry.exp
index 78f65db..69484e7 100644
--- a/gdb/testsuite/gdb.base/break-entry.exp
+++ b/gdb/testsuite/gdb.base/break-entry.exp
@@ -25,14 +25,14 @@
 # continues the process with the equivalent of "jump *$PC", which
 # triggers any breakpoint at $PC.  The latter is what we want to test.
 
-set testfile break-entry
+standard_testfile start.c
 
 if [target_info exists use_gdb_stub] {
     untested ${testfile}.exp
     return
 }
 
-if { [prepare_for_testing ${testfile}.exp ${testfile} start.c {additional_flags=-static}] } {
+if { [prepare_for_testing ${testfile}.exp ${testfile} $srcfile {additional_flags=-static}] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
index 8707e3b..fe9cbb4 100644
--- a/gdb/testsuite/gdb.base/break-interp.exp
+++ b/gdb/testsuite/gdb.base/break-interp.exp
@@ -22,11 +22,11 @@ if { ![isnative] || [is_remote host] || [target_info exists use_gdb_stub]
 load_lib prelink-support.exp
 
 set test "break-interp"
-set binprefix ${objdir}/${subdir}/${test}
+set binprefix [standard_output_file ${test}]
 # Only to get the $interp_system name.
 set srcfile_test "start.c"
 set binfile_test ${test}-test
-set binfile_lib ${objdir}/${subdir}/${test}.so
+set binfile_lib ${binprefix}.so
 set srcfile "${test}-main.c"
 set srcfile_lib "${test}-lib.c"
 
@@ -83,7 +83,7 @@ gdb_test_multiple $test $test {
     }
 }
 
-set interp_system [section_get ${objdir}/${subdir}/$binfile_test .interp]
+set interp_system [section_get [standard_output_file $binfile_test] .interp]
 set interp_system_debug [system_debug_get $interp_system]
 verbose -log "$interp_system has debug $interp_system_debug"
 
@@ -390,10 +390,11 @@ proc test_ld {file ifmain trynosym displacement} {
     if $ifmain {
 	gdb_test_no_output "set args segv"
     } else {
-	global objdir binfile_test
+	global binfile_test
 
 	# ld.so needs some executable to run to reach _dl_debug_state.
-	gdb_test_no_output "set args ${objdir}/${subdir}/$binfile_test" "set args OBJDIR/${subdir}/$binfile_test"
+	gdb_test_no_output "set args [standard_output_file $binfile_test]" \
+	    "set args OBJDIR/${subdir}/$binfile_test"
     }
 
     reach $solib_bp "run" $displacement
diff --git a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
index 13db347..7a4ef83 100644
--- a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
+++ b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
@@ -25,23 +25,19 @@
 #
 if { [skip_cplus_tests] } { continue }
 
-set testfile "break-on-linker-gcd-function"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1
 }
 
 set additional_flags {-ffunction-sections -Wl,--gc-sections}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
-	   [list debug c++ additional_flags=$additional_flags]] != "" } {
-    untested $srcfile
+if {[prepare_for_testing $testfile.exp $testfile $srcfile \
+	 [list debug c++ additional_flags=$additional_flags]]} {
+    untested $testfile.exp
     return -1
 }
 
-clean_restart $testfile
-
 # Single hex digit
 set xd {[0-9a-f]}
 
diff --git a/gdb/testsuite/gdb.base/breakpoint-shadow.exp b/gdb/testsuite/gdb.base/breakpoint-shadow.exp
index dc96274..009c6df 100644
--- a/gdb/testsuite/gdb.base/breakpoint-shadow.exp
+++ b/gdb/testsuite/gdb.base/breakpoint-shadow.exp
@@ -13,19 +13,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile breakpoint-shadow
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "Couldn't compile test program"
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # We need to start the inferior to place the breakpoints in the memory at all.
 if ![runto_main] {
     untested start
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2/7] test suite update - gdb.base/[cd]
  2013-06-19 21:04 [PATCH 0/7] first batch of test suite updates Tom Tromey
                   ` (4 preceding siblings ...)
  2013-06-19 21:04 ` [PATCH 4/7] test suite update - gdb.base/[hijklm] Tom Tromey
@ 2013-06-19 21:04 ` Tom Tromey
  2013-06-19 21:14 ` [PATCH 5/7] test suite update - gdb.base/[nopqr] Tom Tromey
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Tom Tromey @ 2013-06-19 21:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Files gdb.base/[cd]*.exp.
See message #0 for details.

	* call-ar-st.exp, call-rt-st.exp, call-sc.exp,
	call-signal-resume.exp, call-strs.exp, callexit.exp,
	callfuncs.exp, catch-load.exp, catch-syscall.exp, charset.exp,
	checkpoint.exp, chng-syms.exp, code-expr.exp, code_elim.exp,
	commands.exp, completion.exp, complex.exp, cond-expr.exp,
	condbreak.exp, consecutive.exp, constvars.exp, corefile.exp,
	ctxobj.exp, cursal.exp, cvexpr.exp, dbx.exp, default.exp,
	define.exp, del.exp, detach.exp, dfp-test.exp, display.exp,
	dmsym.exp, dump.exp, dup-sect.exp: Use standard_testfile,
	standard_output_file, prepare_for_testing, clean_restart.
---
 gdb/testsuite/gdb.base/call-ar-st.exp         | 30 ++++-------
 gdb/testsuite/gdb.base/call-rt-st.exp         | 10 +---
 gdb/testsuite/gdb.base/call-sc.exp            |  7 +--
 gdb/testsuite/gdb.base/call-signal-resume.exp |  9 +---
 gdb/testsuite/gdb.base/call-strs.exp          | 20 ++-----
 gdb/testsuite/gdb.base/callexit.exp           |  9 +---
 gdb/testsuite/gdb.base/callfuncs.exp          |  4 +-
 gdb/testsuite/gdb.base/catch-load.exp         |  6 +--
 gdb/testsuite/gdb.base/catch-syscall.exp      |  5 +-
 gdb/testsuite/gdb.base/charset.exp            |  7 ++-
 gdb/testsuite/gdb.base/checkpoint.exp         |  9 +---
 gdb/testsuite/gdb.base/chng-syms.exp          |  9 +---
 gdb/testsuite/gdb.base/code-expr.exp          |  9 +---
 gdb/testsuite/gdb.base/code_elim.exp          |  4 +-
 gdb/testsuite/gdb.base/commands.exp           | 40 ++++++++------
 gdb/testsuite/gdb.base/completion.exp         | 30 +++--------
 gdb/testsuite/gdb.base/complex.exp            | 22 ++------
 gdb/testsuite/gdb.base/cond-expr.exp          | 10 ++--
 gdb/testsuite/gdb.base/condbreak.exp          | 76 +++++++++++----------------
 gdb/testsuite/gdb.base/consecutive.exp        | 15 ++----
 gdb/testsuite/gdb.base/constvars.exp          |  9 +---
 gdb/testsuite/gdb.base/corefile.exp           | 21 ++++----
 gdb/testsuite/gdb.base/ctxobj.exp             |  6 +--
 gdb/testsuite/gdb.base/cursal.exp             |  4 +-
 gdb/testsuite/gdb.base/cvexpr.exp             |  9 +---
 gdb/testsuite/gdb.base/dbx.exp                | 26 ++-------
 gdb/testsuite/gdb.base/default.exp            |  3 ++
 gdb/testsuite/gdb.base/define.exp             | 26 ++-------
 gdb/testsuite/gdb.base/del.exp                | 16 ++----
 gdb/testsuite/gdb.base/detach.exp             |  6 +--
 gdb/testsuite/gdb.base/dfp-test.exp           |  9 +---
 gdb/testsuite/gdb.base/display.exp            | 14 ++---
 gdb/testsuite/gdb.base/dmsym.exp              |  8 +--
 gdb/testsuite/gdb.base/dump.exp               |  4 +-
 gdb/testsuite/gdb.base/dup-sect.exp           |  4 +-
 35 files changed, 159 insertions(+), 337 deletions(-)

diff --git a/gdb/testsuite/gdb.base/call-ar-st.exp b/gdb/testsuite/gdb.base/call-ar-st.exp
index 925d2af..21df59d 100644
--- a/gdb/testsuite/gdb.base/call-ar-st.exp
+++ b/gdb/testsuite/gdb.base/call-ar-st.exp
@@ -17,21 +17,21 @@
 
 
 
-set testfile "call-ar-st"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 # Test depends on printf, which the sparclet stub doesn't support.  
 if { [istarget "sparclet-*-*"] } {
     return 0
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "couldn't compile ${srcdir}/${subdir}/${srcfile}"
-    return -1
+# Some targets can't call functions, so don't even bother with this
+# test.
+if [target_info exists gdb,cannot_call_functions] {
+    setup_xfail "*-*-*" 2416
+    fail "This target can not call functions"
+    continue
 }
 
-
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
 
@@ -39,23 +39,15 @@ if [get_compiler_info] {
     return -1
 }
 
-# Some targets can't call functions, so don't even bother with this
-# test.
-if [target_info exists gdb,cannot_call_functions] {
-    setup_xfail "*-*-*" 2416
-    fail "This target can not call functions"
-    continue
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
 }
 
+
 set oldtimeout $timeout
 set timeout [expr "$timeout + 60"]
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
 gdb_test_no_output "set print sevenbit-strings"
 gdb_test_no_output "set print address off"
 gdb_test_no_output "set width 0"
diff --git a/gdb/testsuite/gdb.base/call-rt-st.exp b/gdb/testsuite/gdb.base/call-rt-st.exp
index d71824c..f01a18f 100644
--- a/gdb/testsuite/gdb.base/call-rt-st.exp
+++ b/gdb/testsuite/gdb.base/call-rt-st.exp
@@ -21,10 +21,7 @@
 
 
 
-set testfile "call-rt-st"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-
+standard_testfile .c
 
 # Test depends on printf, which the sparclet stub doesn't support.  
 if { [istarget "sparclet-*-*"] } {
@@ -55,10 +52,7 @@ if [target_info exists gdb,cannot_call_functions] {
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 gdb_test_no_output "set print sevenbit-strings"
 gdb_test_no_output "set print address off"
 gdb_test_no_output "set width 0"
diff --git a/gdb/testsuite/gdb.base/call-sc.exp b/gdb/testsuite/gdb.base/call-sc.exp
index e62021b..d3bd8ad 100644
--- a/gdb/testsuite/gdb.base/call-sc.exp
+++ b/gdb/testsuite/gdb.base/call-sc.exp
@@ -28,9 +28,7 @@ if [target_info exists gdb,cannot_call_functions] {
     continue
 }
 
-set testfile "call-sc"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 # Create and source the file that provides information about the
 # compiler used to compile the test case.
@@ -47,7 +45,6 @@ proc start_scalars_test { type } {
     global testfile
     global srcfile
     global binfile
-    global objdir
     global subdir
     global srcdir
     global gdb_prompt
@@ -57,7 +54,7 @@ proc start_scalars_test { type } {
     set flags "debug additional_flags=-DT=${type}"
     set testfile "call-sc-${type}"
 
-    set binfile ${objdir}/${subdir}/${testfile}
+    set binfile [standard_output_file ${testfile}]
     if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } {
 	# built the second test case since we can't use prototypes
 	warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
diff --git a/gdb/testsuite/gdb.base/call-signal-resume.exp b/gdb/testsuite/gdb.base/call-signal-resume.exp
index b7c4c0b..656e8dc 100644
--- a/gdb/testsuite/gdb.base/call-signal-resume.exp
+++ b/gdb/testsuite/gdb.base/call-signal-resume.exp
@@ -31,9 +31,7 @@ if [target_info exists gdb,nosignals] {
 }
 
 
-set testfile "call-signals"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile call-signals.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested call-signal-resume.exp
@@ -61,10 +59,7 @@ proc get_dummy_frame_number { } {
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if { ![runto_main] } {
     fail "Can't run to main"
diff --git a/gdb/testsuite/gdb.base/call-strs.exp b/gdb/testsuite/gdb.base/call-strs.exp
index 37a2828..764912a 100644
--- a/gdb/testsuite/gdb.base/call-strs.exp
+++ b/gdb/testsuite/gdb.base/call-strs.exp
@@ -23,22 +23,13 @@
 #debug strarg
 
 
-set testfile "call-strs"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 # Test depends on printf, which the sparclet stub doesn't support.  
 if { [istarget "sparclet-*-*"] } {
     return 0
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested call-strs.exp
-    return -1
-}
-
-
-
 # Some targets can't call functions, so don't even bother with this
 # test.
 if [target_info exists gdb,cannot_call_functions] {
@@ -48,12 +39,11 @@ if [target_info exists gdb,cannot_call_functions] {
 }
 
 
-# Start with a fresh gdb.
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
+}
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
 gdb_test_no_output "set print sevenbit-strings"
 gdb_test_no_output "set print address off"
 gdb_test_no_output "set print symbol off"
diff --git a/gdb/testsuite/gdb.base/callexit.exp b/gdb/testsuite/gdb.base/callexit.exp
index 87d2d91..e33d5f7 100644
--- a/gdb/testsuite/gdb.base/callexit.exp
+++ b/gdb/testsuite/gdb.base/callexit.exp
@@ -14,9 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile "callexit"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested callexit.exp
@@ -33,10 +31,7 @@ if [target_info exists gdb,cannot_call_functions] {
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if { ![runto_main] } {
     fail "Can't run to main"
diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
index 6e1ebab..e3f49f9 100644
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -16,9 +16,7 @@
 # This file was written by Fred Fish. (fnf@cygnus.com)
 # and modified by Bob Manson. (manson@cygnus.com)
 
-set testfile "callfuncs"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 set compile_flags {debug}
 if [support_complex_tests] {
diff --git a/gdb/testsuite/gdb.base/catch-load.exp b/gdb/testsuite/gdb.base/catch-load.exp
index c66318e..4bcaa44 100644
--- a/gdb/testsuite/gdb.base/catch-load.exp
+++ b/gdb/testsuite/gdb.base/catch-load.exp
@@ -24,9 +24,7 @@ if {[get_compiler_info]} {
     return -1
 }
 
-set testfile catch-load
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug shlib_load}] != "" } {
     untested catch-load.exp
     return -1
@@ -34,7 +32,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 set testfile2 catch-load-so
 set srcfile2 ${testfile2}.c
-set binfile2 ${objdir}/${subdir}/${testfile2}.so
+set binfile2 [standard_output_file ${testfile2}.so]
 set binfile2_dlopen [shlib_target_file ${testfile2}.so]
 if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug}] != "" } {
     untested catch-load.exp
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
index 4a05292..395fcd4 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.exp
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -38,10 +38,7 @@ if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"]
      continue
 }
 
-global srcfile
-set testfile "catch-syscall"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 # All (but the last) syscalls from the example code
 # They are ordered according to the file, so do not change this.
diff --git a/gdb/testsuite/gdb.base/charset.exp b/gdb/testsuite/gdb.base/charset.exp
index d8d471e..a5dbb28 100644
--- a/gdb/testsuite/gdb.base/charset.exp
+++ b/gdb/testsuite/gdb.base/charset.exp
@@ -21,10 +21,9 @@
 # Test GDB's character set support.
 
 
-set testfile "charset"
-set srcfile ${testfile}.c
-set srcmallocfile ${testfile}-malloc.c
-if { [prepare_for_testing ${testfile}.exp ${testfile} [list $srcfile $srcmallocfile]] } {
+standard_testfile .c charset-malloc.c
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} [list $srcfile $srcfile2]] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index d9c28e0..b86fead 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -25,9 +25,7 @@ if {![istarget "*-*-linux*"]} then {
 }
 
 
-set testfile "checkpoint"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested checkpoint.exp
@@ -36,10 +34,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 # Start with a fresh gdb
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 global gdb_prompt
 
diff --git a/gdb/testsuite/gdb.base/chng-syms.exp b/gdb/testsuite/gdb.base/chng-syms.exp
index 8ae0390..d729f1a 100644
--- a/gdb/testsuite/gdb.base/chng-syms.exp
+++ b/gdb/testsuite/gdb.base/chng-syms.exp
@@ -18,9 +18,7 @@
 # Test that GDB cleans up properly after errors that result when a 
 # breakpoint is reset. 
 
-set testfile "chng-syms"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var1}] != "" } {
     untested chng-syms.exp
@@ -53,10 +51,7 @@ proc expect_to_stop_here { ident } {
     return 1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 gdb_test "break stop_here if (var1 == 42)" \
     "Breakpoint.*at.* file .*$srcfile, line.*" \
diff --git a/gdb/testsuite/gdb.base/code-expr.exp b/gdb/testsuite/gdb.base/code-expr.exp
index 529a699..de2f03a 100644
--- a/gdb/testsuite/gdb.base/code-expr.exp
+++ b/gdb/testsuite/gdb.base/code-expr.exp
@@ -22,19 +22,14 @@
 # test running programs
 #
 
-set testfile "cvexpr"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile cvexpr.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested code-expr.exp
      return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 gdb_test_no_output "set print sevenbit-strings"
 gdb_test_no_output "set print address off"
diff --git a/gdb/testsuite/gdb.base/code_elim.exp b/gdb/testsuite/gdb.base/code_elim.exp
index 4be9200..c603077 100644
--- a/gdb/testsuite/gdb.base/code_elim.exp
+++ b/gdb/testsuite/gdb.base/code_elim.exp
@@ -20,8 +20,8 @@ set testfile1 code_elim1
 set testfile2 code_elim2
 set srcfile1 ${testfile1}.c
 set srcfile2 ${testfile2}.c
-set binfile1 ${objdir}/${subdir}/${testfile1}
-set binfile2 ${objdir}/${subdir}/${testfile2}
+set binfile1 [standard_output_file ${testfile1}]
+set binfile2 [standard_output_file ${testfile2}]
 set opts [list debug]
 lappend opts "additional_flags=-ffunction-sections"
 lappend opts "additional_flags=-fdata-sections"
diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index 39ad3f3..b608e0c 100644
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -17,6 +17,8 @@
 # test special commands (if, while, etc)
 #
 
+standard_testfile
+
 if { [prepare_for_testing commands.exp commands run.c {debug additional_flags=-DFAKEARGV}] } {
     return -1
 }
@@ -555,7 +557,9 @@ proc stray_arg0_test { } {
 
 # Test that GDB is able to source a file with an indented comment.
 proc source_file_with_indented_comment {} {
-    set fd [open "file1" w]
+    set file1 [standard_output_file file1]
+
+    set fd [open "$file1" w]
     puts $fd \
 {define my_fun
     #indented comment
@@ -563,40 +567,44 @@ end
 echo Done!\n}
     close $fd
 
-    gdb_test "source file1" "Done!" "source file with indented comment"
+    gdb_test "source $file1" "Done!" "source file with indented comment"
 }
 
 # Test that GDB can handle arguments when sourcing files recursively.
 # If the arguments are overwritten with ####### then the test has failed.
 proc recursive_source_test {} {
-    set fd [open "file1" w]
+    set file1 [standard_output_file file1]
+    set file2 [standard_output_file file2]
+    set file3 [standard_output_file file3]
+
+    set fd [open "$file1" w]
     puts $fd \
-{source file2
-abcdef qwerty}
+"source $file2
+abcdef qwerty"
     close $fd
 
-    set fd [open "file2" w]
+    set fd [open "$file2" w]
     puts $fd \
-{define abcdef
-  echo 1: <<<$arg0>>>\n
-  source file3
-  echo 2: <<<$arg0>>>\n
-end}
+"define abcdef
+  echo 1: <<<\$arg0>>>\\n
+  source $file3
+  echo 2: <<<\$arg0>>>\\n
+end"
     close $fd
 
-    set fd [open "file3" w]
+    set fd [open "$file3" w]
     puts $fd \
 "echo in file3\\n
 #################################################################"
     close $fd
 
-    gdb_test "source file1" \
+    gdb_test "source $file1" \
 	"1: <<<qwerty>>>\[\r\n]+in file3\[\r\n]+2: <<<qwerty>>>" \
 	"recursive source test"
 
-    file delete file1
-    file delete file2
-    file delete file3
+    file delete $file1
+    file delete $file2
+    file delete $file3
 }
 
 proc gdb_test_no_prompt { command result msg } {
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 80cfbff..b3147da 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -50,35 +50,17 @@
 # test running programs
 #
 
-set testfile "break"
-set srcfile ${testfile}.c
-set srcfile1 ${testfile}1.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
-     untested completion.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
-     untested completion.exp
-     return -1
-}
-
-if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
-     untested completion.exp
-     return -1
-}
+standard_testfile break.c break1.c
 
 if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile \
+	 [list $srcfile $srcfile2] {debug nowarnings}]} {
+    untested $testfile.exp
+    return -1
+}
 
 if ![runto_main] then {
         perror "tests suppressed"
diff --git a/gdb/testsuite/gdb.base/complex.exp b/gdb/testsuite/gdb.base/complex.exp
index 5cf4845..f29b405 100644
--- a/gdb/testsuite/gdb.base/complex.exp
+++ b/gdb/testsuite/gdb.base/complex.exp
@@ -14,28 +14,16 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile complex
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-set options debug
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $options] != "" } {
-  # No support for __complex__, presumably.
-  unsupported "print complex packed value in C"
-  unsupported "print complex value in C"
-  return 0
-}
-
-# Start with a fresh gdb.
+standard_testfile
 
 if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
+}
 
 if [runto f2] then {
     get_debug_format
diff --git a/gdb/testsuite/gdb.base/cond-expr.exp b/gdb/testsuite/gdb.base/cond-expr.exp
index 95dbe03..4358844 100644
--- a/gdb/testsuite/gdb.base/cond-expr.exp
+++ b/gdb/testsuite/gdb.base/cond-expr.exp
@@ -31,19 +31,15 @@
 # haven't tried to compile one, or the compilation failed for some reason.
 # In either case, just notify the user and skip the tests in this file.
 
-set testfile "int-type"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile int-type.c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
      untested cond-expr.exp
      return -1
     }
 
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 
 if ![runto_main] then {
diff --git a/gdb/testsuite/gdb.base/condbreak.exp b/gdb/testsuite/gdb.base/condbreak.exp
index c09228c..faccb5b 100644
--- a/gdb/testsuite/gdb.base/condbreak.exp
+++ b/gdb/testsuite/gdb.base/condbreak.exp
@@ -21,46 +21,30 @@
 # test running programs
 #
 
-set testfile "break"
-set srcfile ${testfile}.c
-set srcfile1 ${testfile}1.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
-     untested condbreak.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
-     untested condbreak.exp
-     return -1
-}
+standard_testfile break.c break1.c
 
-if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
-     untested condbreak.exp
-     return -1
+if {[prepare_for_testing ${testfile}.exp $testfile [list $srcfile $srcfile2] \
+	 {debug nowarnings}]} {
+    return -1
 }
 
 if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 
 set bp_location1  [gdb_get_line_number "set breakpoint 1 here"]
 set bp_location6  [gdb_get_line_number "set breakpoint 6 here"]
-set bp_location8  [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
-set bp_location9  [gdb_get_line_number "set breakpoint 9 here" $srcfile1]
-set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1]
-set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1]
-set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile1]
-set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile1]
-set bp_location17 [gdb_get_line_number "set breakpoint 17 here" $srcfile1]
-set bp_location18 [gdb_get_line_number "set breakpoint 18 here" $srcfile1]
+set bp_location8  [gdb_get_line_number "set breakpoint 8 here" $srcfile2]
+set bp_location9  [gdb_get_line_number "set breakpoint 9 here" $srcfile2]
+set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile2]
+set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile2]
+set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile2]
+set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile2]
+set bp_location17 [gdb_get_line_number "set breakpoint 17 here" $srcfile2]
+set bp_location18 [gdb_get_line_number "set breakpoint 18 here" $srcfile2]
 
 #
 # test break at function
@@ -73,7 +57,7 @@ gdb_test "break main" \
 # test conditional break at function
 #
 gdb_test "break marker1 if 1==1" \
-    "Breakpoint.*at.* file .*$srcfile1, line.*"
+    "Breakpoint.*at.* file .*$srcfile2, line.*"
 
 gdb_test_no_output "delete 2"
 
@@ -89,7 +73,7 @@ gdb_test_no_output "delete 3"
 # test conditional break at function
 #
 gdb_test "break marker1 if (1==1)" \
-    "Breakpoint.*at.* file .*$srcfile1, line.*"
+    "Breakpoint.*at.* file .*$srcfile2, line.*"
 
 #
 # test conditional break at line number
@@ -98,16 +82,16 @@ gdb_test "break $srcfile:$bp_location1 if (1==1)" \
     "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\."
 
 gdb_test "break marker2 if (a==43)" \
-    "Breakpoint.*at.* file .*$srcfile1, line.*"
+    "Breakpoint.*at.* file .*$srcfile2, line.*"
 
 #
 # Check break involving inferior function call.
 # Ensure there is at least one additional breakpoint with higher VMA.
 #
 gdb_test "break marker3 if (multi_line_if_conditional(1,1,1)==0)" \
-    "Breakpoint.*at.* file .*$srcfile1, line.*"
+    "Breakpoint.*at.* file .*$srcfile2, line.*"
 gdb_test "break marker4" \
-    "Breakpoint.*at.* file .*$srcfile1, line.*"
+    "Breakpoint.*at.* file .*$srcfile2, line.*"
 
 #
 # check to see what breakpoints are set
@@ -129,15 +113,15 @@ if {$hp_aCC_compiler} {
 gdb_test "info break" \
     "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
 \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$bp_location6.*
-\[0-9\]+\[\t \]+breakpoint     keep y.* in marker1$marker1_proto at .*$srcfile1:($bp_location15|$bp_location16).*
+\[0-9\]+\[\t \]+breakpoint     keep y.* in marker1$marker1_proto at .*$srcfile2:($bp_location15|$bp_location16).*
 \[\t \]+stop only if \\(1==1\\).*
 \[0-9\]+\[\t \]+breakpoint     keep y.* in main at .*$srcfile:$bp_location1.*
 \[\t \]+stop only if \\(1==1\\).*
-\[0-9\]+\[\t \]+breakpoint     keep y.* in marker2$marker2_proto at .*$srcfile1:($bp_location8|$bp_location9).*
+\[0-9\]+\[\t \]+breakpoint     keep y.* in marker2$marker2_proto at .*$srcfile2:($bp_location8|$bp_location9).*
 \[\t \]+stop only if \\(a==43\\).*
-\[0-9\]+\[\t \]+breakpoint     keep y.* in marker3$marker3_proto at .*$srcfile1:($bp_location17|$bp_location18).*
+\[0-9\]+\[\t \]+breakpoint     keep y.* in marker3$marker3_proto at .*$srcfile2:($bp_location17|$bp_location18).*
 \[\t \]+stop only if \\(multi_line_if_conditional\\(1,1,1\\)==0\\).*
-\[0-9\]+\[\t \]+breakpoint     keep y.* in marker4$marker4_proto at .*$srcfile1:($bp_location13|$bp_location14).*" \
+\[0-9\]+\[\t \]+breakpoint     keep y.* in marker4$marker4_proto at .*$srcfile2:($bp_location13|$bp_location14).*" \
     "breakpoint info"
 
 
@@ -195,10 +179,10 @@ gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.
 #
 # Until the Dwarf2 writer gets fixed, I'm going to XFAIL its behavior.
 gdb_test_multiple "continue" "run until breakpoint at marker1" {
-    -re  "Continuing\\..*Breakpoint \[0-9\]+, marker1 \\(\\) at .*$srcfile1:($bp_location15|$bp_location16).*($bp_location15|$bp_location16)\[\t \]+.*$gdb_prompt $" {
+    -re  "Continuing\\..*Breakpoint \[0-9\]+, marker1 \\(\\) at .*$srcfile2:($bp_location15|$bp_location16).*($bp_location15|$bp_location16)\[\t \]+.*$gdb_prompt $" {
 	pass "run until breakpoint at marker1"
     }
-    -re  "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker1 \\(\\) at .*$srcfile1:($bp_location15|$bp_location16).*($bp_location15|$bp_location16)\[\t \]+.*$gdb_prompt $" {
+    -re  "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker1 \\(\\) at .*$srcfile2:($bp_location15|$bp_location16).*($bp_location15|$bp_location16)\[\t \]+.*$gdb_prompt $" {
 	xfail "run until breakpoint at marker1"
     }
 }
@@ -207,10 +191,10 @@ gdb_test_multiple "continue" "run until breakpoint at marker1" {
 # Same issues here as above.
 setup_xfail hppa2.0w-*-* 11512CLLbs
 gdb_test_multiple "continue" "run until breakpoint at marker2" {
-    -re "Continuing\\..*Breakpoint \[0-9\]+, marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*$gdb_prompt $" {
+    -re "Continuing\\..*Breakpoint \[0-9\]+, marker2 \\(a=43\\) at .*$srcfile2:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*$gdb_prompt $" {
 	pass "run until breakpoint at marker2"
     }
-    -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*$gdb_prompt $" {
+    -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker2 \\(a=43\\) at .*$srcfile2:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*$gdb_prompt $" {
 	xfail "run until breakpoint at marker2"
     }
 }
@@ -244,20 +228,20 @@ gdb_test "break *main if (1==1) ta 999" \
 
 set test "run until breakpoint at marker3"
 gdb_test_multiple "continue" $test {
-    -re "Continuing\\..*Breakpoint \[0-9\]+, marker3 \\(a=$hex \"stack\", b=$hex \"trace\"\\) at .*$srcfile1:($bp_location17|$bp_location18).*($bp_location17|$bp_location18)\[\t \]+.*$gdb_prompt $" {
+    -re "Continuing\\..*Breakpoint \[0-9\]+, marker3 \\(a=$hex \"stack\", b=$hex \"trace\"\\) at .*$srcfile2:($bp_location17|$bp_location18).*($bp_location17|$bp_location18)\[\t \]+.*$gdb_prompt $" {
 	pass $test
     }
-    -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker3 \\(a=$hex \"stack\", b=$hex \"trace\"\\) at .*$srcfile1:($bp_location17|$bp_location18).*($bp_location17|$bp_location18)\[\t \]+.*$gdb_prompt $" {
+    -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker3 \\(a=$hex \"stack\", b=$hex \"trace\"\\) at .*$srcfile2:($bp_location17|$bp_location18).*($bp_location17|$bp_location18)\[\t \]+.*$gdb_prompt $" {
 	xfail $test
     }
 }
 
 set test "run until breakpoint at marker4"
 gdb_test_multiple "continue" $test {
-    -re "Continuing\\..*Breakpoint \[0-9\]+, marker4 \\(d=177601976\\) at .*$srcfile1:($bp_location13|$bp_location14).*($bp_location13|$bp_location14)\[\t \]+.*$gdb_prompt $" {
+    -re "Continuing\\..*Breakpoint \[0-9\]+, marker4 \\(d=177601976\\) at .*$srcfile2:($bp_location13|$bp_location14).*($bp_location13|$bp_location14)\[\t \]+.*$gdb_prompt $" {
 	pass $test
     }
-    -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker4 \\(d=177601976\\) at .*$srcfile1:($bp_location13|$bp_location14).*($bp_location13|$bp_location14)\[\t \]+.*$gdb_prompt $" {
+    -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker4 \\(d=177601976\\) at .*$srcfile2:($bp_location13|$bp_location14).*($bp_location13|$bp_location14)\[\t \]+.*$gdb_prompt $" {
 	xfail $test
     }
 }
diff --git a/gdb/testsuite/gdb.base/consecutive.exp b/gdb/testsuite/gdb.base/consecutive.exp
index dd29431..be70e9f 100644
--- a/gdb/testsuite/gdb.base/consecutive.exp
+++ b/gdb/testsuite/gdb.base/consecutive.exp
@@ -20,24 +20,17 @@
 #
 
 
-set testfile "consecutive"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
-    untested consecutive.exp
+if [get_compiler_info] {
     return -1
 }
 
-if [get_compiler_info] {
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug nowarnings}]} {
+    untested $testfile.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
     continue
diff --git a/gdb/testsuite/gdb.base/constvars.exp b/gdb/testsuite/gdb.base/constvars.exp
index 0e07349..554e265 100644
--- a/gdb/testsuite/gdb.base/constvars.exp
+++ b/gdb/testsuite/gdb.base/constvars.exp
@@ -27,9 +27,7 @@
 # test running programs
 #
 
-set testfile "constvars"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
@@ -42,10 +40,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 
 #
diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp
index 054ed3e..24a33a3 100644
--- a/gdb/testsuite/gdb.base/corefile.exp
+++ b/gdb/testsuite/gdb.base/corefile.exp
@@ -21,13 +21,7 @@ if ![isnative] then {
     return
 }
 
-set testfile "coremaker"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested corefile.exp
-     return -1
-}
+standard_testfile coremaker.c
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
@@ -35,6 +29,11 @@ if [get_compiler_info] {
     return -1
 }
 
+if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
+    untested $testfile.exp
+    return -1
+}
+
 set corefile [core_find $binfile {coremmap.data}]
 if {$corefile == ""} {
     return 0
@@ -49,7 +48,7 @@ if {$corefile == ""} {
 #
 # Another problem is that on some systems (solaris for example), there
 # is apparently a limit on the length of a fully specified path to 
-# the coremaker executable, at about 80 chars.  For this case, consider
+# the corefile executable, at about 80 chars.  For this case, consider
 # it a pass, but note that the program name is bad.
 
 gdb_exit
@@ -65,7 +64,7 @@ expect {
     -re "Couldn't find .* registers in core file.*$gdb_prompt $" {
         fail "args: -core=[file tail $corefile] (couldn't find regs)"
     }
-    -re "Core was generated by .*coremaker.*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
+    -re "Core was generated by .*corefile.*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
 	pass "args: -core=[file tail $corefile]"
     }
     -re "Core was generated by .*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
@@ -93,7 +92,7 @@ if $verbose>1 then {
 
 eval "spawn $GDB $INTERNAL_GDBFLAGS $GDBFLAGS $binfile -core=$corefile"
 expect {
-    -re "Core was generated by .*coremaker.*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
+    -re "Core was generated by .*corefile.*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
 	pass "args: execfile -core=[file tail $corefile]"
     }
     -re "Core was generated by .*\r\n\#0  .*\(\).*\r\n$gdb_prompt $"	 {
@@ -124,7 +123,7 @@ gdb_test_multiple "core-file $corefile" "core-file command" {
 	send_gdb "y\n"
 	exp_continue
     }
-    -re "Core was generated by .*coremaker.*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
+    -re "Core was generated by .*corefile.*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
 	pass "core-file command"
     }
     -re "Core was generated by .*\r\n\#0  .*\(\).*\r\n$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.base/ctxobj.exp b/gdb/testsuite/gdb.base/ctxobj.exp
index cd68dfc..f803a12 100644
--- a/gdb/testsuite/gdb.base/ctxobj.exp
+++ b/gdb/testsuite/gdb.base/ctxobj.exp
@@ -30,8 +30,8 @@ set executable ctxobj-m
 set libsrc [list "${srcdir}/${subdir}/ctxobj-v.c" \
                  "${srcdir}/${subdir}/ctxobj-f.c"]
 
-set libobj1 "${objdir}/${subdir}/libctxobj1.so"
-set libobj2 "${objdir}/${subdir}/libctxobj2.so"
+set libobj1 [standard_output_file libctxobj1.so]
+set libobj2 [standard_output_file libctxobj2.so]
 
 set libobj1_opts { debug additional_flags=-fPIC
                    additional_flags=-DVERSION=104
@@ -47,7 +47,7 @@ if { [gdb_compile_shlib $libsrc $libobj2 $libobj2_opts ] != "" } {
     return -1
 }
 if { [gdb_compile "${srcdir}/${subdir}/${executable}.c" \
-                  "${objdir}/${subdir}/${executable}" \
+                  [standard_output_file ${executable}] \
                   executable \
                   [list debug shlib=${libobj1} shlib=${libobj2}]]
      != ""} {
diff --git a/gdb/testsuite/gdb.base/cursal.exp b/gdb/testsuite/gdb.base/cursal.exp
index a5840cb..fb58dd4 100644
--- a/gdb/testsuite/gdb.base/cursal.exp
+++ b/gdb/testsuite/gdb.base/cursal.exp
@@ -14,9 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile "cursal"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != ""} {
     untested "Couldn't compile $srcfile"
diff --git a/gdb/testsuite/gdb.base/cvexpr.exp b/gdb/testsuite/gdb.base/cvexpr.exp
index 7ae8548..c5e4faf 100644
--- a/gdb/testsuite/gdb.base/cvexpr.exp
+++ b/gdb/testsuite/gdb.base/cvexpr.exp
@@ -22,19 +22,14 @@
 # test running programs
 #
 
-set testfile "cvexpr"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested cvexpr.exp
      return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 gdb_test_no_output "set print sevenbit-strings"
 gdb_test_no_output "set print address off"
diff --git a/gdb/testsuite/gdb.base/dbx.exp b/gdb/testsuite/gdb.base/dbx.exp
index 31bda5d..7d89b81 100644
--- a/gdb/testsuite/gdb.base/dbx.exp
+++ b/gdb/testsuite/gdb.base/dbx.exp
@@ -14,28 +14,12 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-set testfile1 "average"
-set testfile2 "sum"
-set testfile "dbx-test"
-set binfile1 ${objdir}/${subdir}/${testfile1}
-set binfile2 ${objdir}/${subdir}/${testfile2}
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile average.c sum.c
 
-
-
-if  { [gdb_compile "${srcdir}/${subdir}/average.c" "${binfile1}.o" object {debug}] != "" } {
-     untested dbx.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/sum.c" "${binfile2}.o" object {debug}] != "" } {
-     untested dbx.exp
-     return -1
-}
-
-if  { [gdb_compile "${binfile1}.o ${binfile2}.o" ${binfile} executable {debug}] != "" } {
-     untested dbx.exp
-     return -1
+if {[build_executable $testfile.exp $testfile \
+	 [list $srcfile $srcfile2] debug] == -1} {
+    untested $testfile.exp
+    return -1
 }
 
 #
diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp
index 9230ee8..e6fef15 100644
--- a/gdb/testsuite/gdb.base/default.exp
+++ b/gdb/testsuite/gdb.base/default.exp
@@ -521,6 +521,9 @@ gdb_test "set height" "Argument required .integer to set it to.*" "set height"
 gdb_test_no_output "set history expansion" "set history expansion"
 #test set history filename
 gdb_test "set history filename" "Argument required .filename to set it to.*" "set history filename"
+# Make sure the history ends up in the right place.
+gdb_test_no_output "set history filename [standard_output_file .gdb_history]" \
+    "set the history filename"
 #test set history save
 gdb_test_no_output "set history save" "set history save"
 #test set history size
diff --git a/gdb/testsuite/gdb.base/define.exp b/gdb/testsuite/gdb.base/define.exp
index 9b7eef9..6b647f2 100644
--- a/gdb/testsuite/gdb.base/define.exp
+++ b/gdb/testsuite/gdb.base/define.exp
@@ -20,31 +20,13 @@
 # test running programs
 #
 
-set testfile "break"
-set srcfile ${testfile}.c
-set srcfile1 ${testfile}1.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
-     untested define.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
-     untested define.exp
-     return -1
-}
+standard_testfile break.c break1.c
 
-if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
-     untested define.exp
-     return -1
+if {[prepare_for_testing ${testfile}.exp ${testfile} \
+	 [list $srcfile $srcfile2] {debug nowarnings}]} {
+    return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
 set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
 
diff --git a/gdb/testsuite/gdb.base/del.exp b/gdb/testsuite/gdb.base/del.exp
index febcfc6..958d491 100644
--- a/gdb/testsuite/gdb.base/del.exp
+++ b/gdb/testsuite/gdb.base/del.exp
@@ -17,21 +17,13 @@
 # shortcuts of the "delete" command never stop working.
 
 
-set testfile del
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "Couldn't compile test program"
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # A function to test that ALIAS is working as a shortcut of the "delete"
 # command.
 
diff --git a/gdb/testsuite/gdb.base/detach.exp b/gdb/testsuite/gdb.base/detach.exp
index 3d2e90c..0a61d11 100644
--- a/gdb/testsuite/gdb.base/detach.exp
+++ b/gdb/testsuite/gdb.base/detach.exp
@@ -27,10 +27,8 @@ if [is_remote target] then {
     return 0
 }
 
-set testfile "attach"
-set srcfile  ${testfile}.c
-set binfile  ${objdir}/${subdir}/${testfile}
-set escapedbinfile  [string_to_regexp ${objdir}/${subdir}/${testfile}]
+standard_testfile attach.c
+set escapedbinfile  [string_to_regexp ${binfile}]
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested detach.exp
diff --git a/gdb/testsuite/gdb.base/dfp-test.exp b/gdb/testsuite/gdb.base/dfp-test.exp
index f121808..ce402df 100644
--- a/gdb/testsuite/gdb.base/dfp-test.exp
+++ b/gdb/testsuite/gdb.base/dfp-test.exp
@@ -18,9 +18,7 @@
 # This file is part of the gdb testsuite.  It is intended to test that
 # gdb could correctly handle decimal floating point introduced in IEEE 754R.
 
-set testfile "dfp-test"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 # Try to compile the test case.  If we can't, assume the
 # toolchain does not yet provide DFP support and bail out.
@@ -29,10 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quie
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp
index fa44003..5db84cc 100644
--- a/gdb/testsuite/gdb.base/display.exp
+++ b/gdb/testsuite/gdb.base/display.exp
@@ -16,13 +16,10 @@
 # display.exp   Test display commands
 #               Also do some printing stuff for coverage's sake.
 #
-set testfile display
-set srcfile  ${testfile}.c
-set binfile  ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
+if {[prepare_for_testing $testfile.exp $testfile $srcfile \
+	 {debug nowarnings}]} {
     untested display.exp
     return -1
 }
@@ -36,11 +33,6 @@ verbose "Timeout is now $timeout seconds" 2
 # use this to debug:
 #log_user 1
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # Some coverage stuff
 #
 if !$use_gdb_stub {
diff --git a/gdb/testsuite/gdb.base/dmsym.exp b/gdb/testsuite/gdb.base/dmsym.exp
index 02b1a9c..822eed7 100644
--- a/gdb/testsuite/gdb.base/dmsym.exp
+++ b/gdb/testsuite/gdb.base/dmsym.exp
@@ -21,16 +21,18 @@ set testfile dmsym_main
 # This is why we use gdb_compile instead of relying on the usual
 # call to prepare_for_testing.
 
+set dmsym_o [standard_output_file dmsym.o]
+
 if {[gdb_compile "${srcdir}/${subdir}/dmsym.c" \
-                 ${objdir}/${subdir}/dmsym.o \
+                 $dmsym_o \
                  object {}] != ""} {
   untested dmsym.exp
   return -1
 }
 
 if {[gdb_compile \
-      [list ${srcdir}/${subdir}/dmsym_main.c ${objdir}/${subdir}/dmsym.o] \
-      ${objdir}/${subdir}/${testfile} \
+      [list ${srcdir}/${subdir}/dmsym_main.c $dmsym_o] \
+      [standard_output_file ${testfile}] \
       executable {debug}] != ""} {
     untested dmsym.exp
     return -1
diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
index b2d0b3a..ea93b89 100644
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -17,10 +17,8 @@
 # This is a test for the gdb command "dump".
 
 
-set testfile "dump"
+standard_testfile
 
-set srcfile  ${testfile}.c
-set binfile  ${objdir}/${subdir}/${testfile}
 set options  {debug}
 
 set is64bitonly "no"
diff --git a/gdb/testsuite/gdb.base/dup-sect.exp b/gdb/testsuite/gdb.base/dup-sect.exp
index 6076801..fcc762e 100644
--- a/gdb/testsuite/gdb.base/dup-sect.exp
+++ b/gdb/testsuite/gdb.base/dup-sect.exp
@@ -33,11 +33,9 @@ if {![istarget *-*-linux*]
     return 0
 }
 
-set testfile dup-sect
-set srcfile ${testfile}.S
+standard_testfile .S
 set srcmainfile start.c
 set executable ${testfile}
-set binfile ${objdir}/${subdir}/${executable}
 
 if {[build_executable ${testfile}.exp $executable [list ${srcfile} ${srcmainfile}] {}] == -1} {
     return -1
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 7/7] test suite update - gdb.base/[t-z]
  2013-06-19 21:04 [PATCH 0/7] first batch of test suite updates Tom Tromey
  2013-06-19 21:04 ` [PATCH 6/7] test suite update - gdb.base/s* Tom Tromey
  2013-06-19 21:04 ` [PATCH 1/7] test suite update - gdb.base/[ab] Tom Tromey
@ 2013-06-19 21:04 ` Tom Tromey
  2013-06-19 21:04 ` [PATCH 3/7] test suite update - gdb.base/[efg] Tom Tromey
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Tom Tromey @ 2013-06-19 21:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Files gdb.base/[t-z]*.exp.
See message #0 for details.

	* testenv.exp, tui-layout.exp, twice.exp, type-opaque.exp,
	unload.exp, unwindonsignal.exp, valgrind-db-attach.exp,
	valgrind-infcall.exp, value-double-free.exp, varargs.exp,
	watch-cond-infcall.exp, watch-cond.exp, watch-non-mem.exp,
	watch-read.exp, watch-vfork.exp, watch_thread_num.exp,
	watchpoint-cond-gone.exp, watchpoint-delete.exp,
	watchpoint-hw.exp, watchpoint-solib.exp, watchpoint.exp,
	watchpoints.exp, wchar.exp, whatis.exp: Use standard_testfile,
	standard_output_file, prepare_for_testing, clean_restart.
---
 gdb/testsuite/gdb.base/testenv.exp              |  4 +---
 gdb/testsuite/gdb.base/tui-layout.exp           |  5 +++--
 gdb/testsuite/gdb.base/twice.exp                | 14 +++++---------
 gdb/testsuite/gdb.base/type-opaque.exp          | 13 ++++---------
 gdb/testsuite/gdb.base/unload.exp               |  8 ++++----
 gdb/testsuite/gdb.base/unwindonsignal.exp       | 19 +++++--------------
 gdb/testsuite/gdb.base/valgrind-db-attach.exp   |  7 ++-----
 gdb/testsuite/gdb.base/valgrind-infcall.exp     |  9 +++------
 gdb/testsuite/gdb.base/value-double-free.exp    | 16 ++++------------
 gdb/testsuite/gdb.base/varargs.exp              | 10 +++-------
 gdb/testsuite/gdb.base/watch-cond-infcall.exp   |  4 +---
 gdb/testsuite/gdb.base/watch-cond.exp           |  4 +---
 gdb/testsuite/gdb.base/watch-non-mem.exp        |  4 +---
 gdb/testsuite/gdb.base/watch-read.exp           |  3 +--
 gdb/testsuite/gdb.base/watch-vfork.exp          |  6 +++---
 gdb/testsuite/gdb.base/watch_thread_num.exp     |  9 ++-------
 gdb/testsuite/gdb.base/watchpoint-cond-gone.exp | 14 ++++----------
 gdb/testsuite/gdb.base/watchpoint-delete.exp    |  4 +---
 gdb/testsuite/gdb.base/watchpoint-hw.exp        | 14 ++++----------
 gdb/testsuite/gdb.base/watchpoint-solib.exp     |  6 +++---
 gdb/testsuite/gdb.base/watchpoint.exp           |  4 +---
 gdb/testsuite/gdb.base/watchpoints.exp          | 17 ++++-------------
 gdb/testsuite/gdb.base/wchar.exp                |  4 ++--
 gdb/testsuite/gdb.base/whatis.exp               | 10 +++-------
 24 files changed, 65 insertions(+), 143 deletions(-)

diff --git a/gdb/testsuite/gdb.base/testenv.exp b/gdb/testsuite/gdb.base/testenv.exp
index ae8d2fa..e9a4d3d 100644
--- a/gdb/testsuite/gdb.base/testenv.exp
+++ b/gdb/testsuite/gdb.base/testenv.exp
@@ -23,9 +23,7 @@ if { [is_remote target] } {
     return 0
 }
 
-set testfile "testenv"
-set srcfile ${testfile}.c
-set binfile ${testfile}
+standard_testfile .c
 
 # Compile binary
 # and start with a fresh gdb
diff --git a/gdb/testsuite/gdb.base/tui-layout.exp b/gdb/testsuite/gdb.base/tui-layout.exp
index 265ead4..8f97b54 100644
--- a/gdb/testsuite/gdb.base/tui-layout.exp
+++ b/gdb/testsuite/gdb.base/tui-layout.exp
@@ -13,8 +13,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile tui-layout
-if { [prepare_for_testing ${testfile}.exp ${testfile} start.c] } {
+standard_testfile start.c
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} $srcfile] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/twice.exp b/gdb/testsuite/gdb.base/twice.exp
index fada7a1..936ddcb 100644
--- a/gdb/testsuite/gdb.base/twice.exp
+++ b/gdb/testsuite/gdb.base/twice.exp
@@ -14,29 +14,25 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile twice-tmp
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_output_file twice.c
 set options debug
 lappend options "additional_flags=-I."
 
-set fileid [open ${objdir}/${subdir}/${srcfile} w]
+set local_srcfile [standard_output_file twice-tmp.c]
+set fileid [open $local_srcfile w]
 puts $fileid "#include \"twice.c\""
 close $fileid
 
 remote_download host ${srcdir}/${subdir}/twice.c twice.c
 
-if  { [gdb_compile "${objdir}/${subdir}/${srcfile}" "${binfile}" executable $options] != "" } {
+if  { [gdb_compile $local_srcfile "${binfile}" executable $options] != "" } {
      untested twice.exp
      return -1
 }
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+clean_restart $binfile
 
 if [runto_main] then {
     # Test that GDB can still detect whether we have line numbers
diff --git a/gdb/testsuite/gdb.base/type-opaque.exp b/gdb/testsuite/gdb.base/type-opaque.exp
index 633d763..7caaeb1 100644
--- a/gdb/testsuite/gdb.base/type-opaque.exp
+++ b/gdb/testsuite/gdb.base/type-opaque.exp
@@ -19,13 +19,11 @@ if {[skip_shlib_tests]} {
     return -1
 }
 
-set testfile type-opaque-main
-set libfile type-opaque-lib
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile type-opaque-main.c
 
+set libfile type-opaque-lib
 set libsrc "${srcdir}/${subdir}/${libfile}.c"
-set libobj "${objdir}/${subdir}/${libfile}.so"
+set libobj [standard_output_file ${libfile}.so]
 set execsrc "${srcdir}/${subdir}/${srcfile}"
 
 remote_exec build "rm -f ${binfile}"
@@ -41,10 +39,7 @@ if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 gdb_load_shlibs ${libobj}
 
 if ![runto_main] then {
diff --git a/gdb/testsuite/gdb.base/unload.exp b/gdb/testsuite/gdb.base/unload.exp
index 9198b3d..adb2f05 100644
--- a/gdb/testsuite/gdb.base/unload.exp
+++ b/gdb/testsuite/gdb.base/unload.exp
@@ -31,12 +31,12 @@ set libname2 "${libfile2}.sl"
 set libsrcfile ${libfile}.c
 set libsrcfile2 ${libfile2}.c
 set srcfile $srcdir/$subdir/$testfile.c
-set binfile $objdir/$subdir/$testfile
-set shlibdir ${objdir}/${subdir}
+set binfile [standard_output_file $testfile]
+set shlibdir [standard_output_file {}]
 set libsrc  $srcdir/$subdir/$libfile.c
 set libsrc2  $srcdir/$subdir/$libfile2.c
-set lib_sl  $objdir/$subdir/$libname
-set lib_sl2  $objdir/$subdir/$libname2
+set lib_sl  [standard_output_file $libname]
+set lib_sl2  [standard_output_file $libname2]
 set lib_dlopen [shlib_target_file ${libname}]
 set lib_dlopen2 [shlib_target_file ${libname2}]
 set lib_syms [shlib_symbol_file ${libname}]
diff --git a/gdb/testsuite/gdb.base/unwindonsignal.exp b/gdb/testsuite/gdb.base/unwindonsignal.exp
index cba27aa..c3c040f 100644
--- a/gdb/testsuite/gdb.base/unwindonsignal.exp
+++ b/gdb/testsuite/gdb.base/unwindonsignal.exp
@@ -24,15 +24,6 @@ if [target_info exists gdb,nosignals] {
 }
 
 
-set testfile "unwindonsignal"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested unwindonsignal.exp
-     return -1
-}
-
 # Some targets can't do function calls, so don't even bother with this
 # test.
 if [target_info exists gdb,cannot_call_functions] {
@@ -41,12 +32,12 @@ if [target_info exists gdb,cannot_call_functions] {
     continue
 }
 
-# Start with a fresh gdb.
+standard_testfile
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
+}
 
 if { ![runto_main] } {
     fail "Can't run to main"
diff --git a/gdb/testsuite/gdb.base/valgrind-db-attach.exp b/gdb/testsuite/gdb.base/valgrind-db-attach.exp
index b1e1ec6..56c6914 100644
--- a/gdb/testsuite/gdb.base/valgrind-db-attach.exp
+++ b/gdb/testsuite/gdb.base/valgrind-db-attach.exp
@@ -18,11 +18,8 @@ if [is_remote target] {
     return 0
 }
 
-set test valgrind-db-attach
-set srcfile $test.c
-set executable $test
-set binfile ${objdir}/${subdir}/${executable}
-if {[build_executable $test.exp $executable $srcfile {debug}] == -1} {
+standard_testfile .c
+if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/valgrind-infcall.exp b/gdb/testsuite/gdb.base/valgrind-infcall.exp
index 6d2893a..349b32d 100644
--- a/gdb/testsuite/gdb.base/valgrind-infcall.exp
+++ b/gdb/testsuite/gdb.base/valgrind-infcall.exp
@@ -18,11 +18,8 @@ if [is_remote target] {
     return 0
 }
 
-set test valgrind-infcall
-set srcfile $test.c
-set executable $test
-set binfile ${objdir}/${subdir}/${executable}
-if {[build_executable $test.exp $executable $srcfile {debug}] == -1} {
+standard_testfile .c
+if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
     return -1
 }
 
@@ -84,7 +81,7 @@ unset gdb_spawn_id
 set board [host_info name]
 unset_board_info fileid
 
-clean_restart $executable
+clean_restart $testfile
 
 gdb_test "$vgdbcmd" " in \\.?_start .*" "target remote for vgdb"
 
diff --git a/gdb/testsuite/gdb.base/value-double-free.exp b/gdb/testsuite/gdb.base/value-double-free.exp
index f3d098f..f47a454 100644
--- a/gdb/testsuite/gdb.base/value-double-free.exp
+++ b/gdb/testsuite/gdb.base/value-double-free.exp
@@ -13,21 +13,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile value-double-free
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "Couldn't compile test program"
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 if ![runto_main] {
     return -1
 }
diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp
index 70de81d..7a427ff 100644
--- a/gdb/testsuite/gdb.base/varargs.exp
+++ b/gdb/testsuite/gdb.base/varargs.exp
@@ -30,9 +30,8 @@
 
 
 set prototypes 0
-set testfile "varargs"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+
+standard_testfile .c
 
 if [get_compiler_info] {
     return -1
@@ -56,10 +55,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 gdb_test_no_output "set print sevenbit-strings"
 gdb_test_no_output "set print address off"
 gdb_test_no_output "set width 0"
diff --git a/gdb/testsuite/gdb.base/watch-cond-infcall.exp b/gdb/testsuite/gdb.base/watch-cond-infcall.exp
index 403ec84..5dcec5b 100644
--- a/gdb/testsuite/gdb.base/watch-cond-infcall.exp
+++ b/gdb/testsuite/gdb.base/watch-cond-infcall.exp
@@ -16,9 +16,7 @@
 # Test for watchpoints with conditions that involve inferior function
 # calls.
 
-set testfile "watch-cond-infcall"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 if { [build_executable ${testfile}.exp ${testfile} ${testfile}.c {debug}] } {
     untested ${testfile}.exp
diff --git a/gdb/testsuite/gdb.base/watch-cond.exp b/gdb/testsuite/gdb.base/watch-cond.exp
index 184aacc..2f2a05b 100644
--- a/gdb/testsuite/gdb.base/watch-cond.exp
+++ b/gdb/testsuite/gdb.base/watch-cond.exp
@@ -17,9 +17,7 @@
 # Tests involving watchpoint conditions with local expressions.
 #
 
-set testfile "watch-cond"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
     untested ${testfile}.exp
diff --git a/gdb/testsuite/gdb.base/watch-non-mem.exp b/gdb/testsuite/gdb.base/watch-non-mem.exp
index cb08985..7e7e2bc 100644
--- a/gdb/testsuite/gdb.base/watch-non-mem.exp
+++ b/gdb/testsuite/gdb.base/watch-non-mem.exp
@@ -17,9 +17,7 @@
 # Tests watchpoints that watch expressions that don't involve memory.
 #
 
-set testfile "watch-non-mem"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
     untested ${testfile}.exp
diff --git a/gdb/testsuite/gdb.base/watch-read.exp b/gdb/testsuite/gdb.base/watch-read.exp
index 9a5e388..95a6964 100644
--- a/gdb/testsuite/gdb.base/watch-read.exp
+++ b/gdb/testsuite/gdb.base/watch-read.exp
@@ -22,8 +22,7 @@
 # watching the same memory as read watchpoints.
 #
 
-set testfile "watch-read"
-set srcfile ${testfile}.c
+standard_testfile .c
 
 if {[skip_hw_watchpoint_access_tests]} {
     return 0
diff --git a/gdb/testsuite/gdb.base/watch-vfork.exp b/gdb/testsuite/gdb.base/watch-vfork.exp
index 51d8eae..bb14147 100644
--- a/gdb/testsuite/gdb.base/watch-vfork.exp
+++ b/gdb/testsuite/gdb.base/watch-vfork.exp
@@ -20,9 +20,9 @@ if { [is_remote target] } {
     return 0
 }
 
-global srcfile
-set testfile "watch-vfork"
-if { [build_executable ${testfile}.exp ${testfile} ${testfile}.c {debug}] } {
+standard_testfile .c
+
+if { [build_executable ${testfile}.exp ${testfile} $srcfile {debug}] } {
     untested ${testfile}.exp
     return -1
 }
diff --git a/gdb/testsuite/gdb.base/watch_thread_num.exp b/gdb/testsuite/gdb.base/watch_thread_num.exp
index d8995fc..fb02917 100644
--- a/gdb/testsuite/gdb.base/watch_thread_num.exp
+++ b/gdb/testsuite/gdb.base/watch_thread_num.exp
@@ -25,9 +25,7 @@ if {[skip_hw_watchpoint_tests]} {
     return 0
 }
 
-set testfile watch_thread_num
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 # What compiler are we using?
 #
@@ -39,10 +37,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if { ![runto main] } then {
    fail "run to main"
diff --git a/gdb/testsuite/gdb.base/watchpoint-cond-gone.exp b/gdb/testsuite/gdb.base/watchpoint-cond-gone.exp
index 44f1f7e..9c908ca 100644
--- a/gdb/testsuite/gdb.base/watchpoint-cond-gone.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-cond-gone.exp
@@ -13,24 +13,18 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "watchpoint-cond-gone"
-set srcfile ${testfile}.c
-set srcfilestripped ${testfile}-stripped.c
-set objfilestripped ${objdir}/${subdir}/${testfile}-stripped.o
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c watchpoint-cond-gone-stripped.c
 
 # We need to generate a function without DWARF to crash older GDB.
 # Stepping into a dynamic function trampoline or stepping out of MAIN may work
 # but it is not a reliable FAIL case.
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfilestripped}" "${objfilestripped}" object {}] != ""
-      || [gdb_compile "${srcdir}/${subdir}/${srcfile} ${objfilestripped}" "${binfile}" executable {debug}] != "" } {
-    untested watchpoint-cond-gone.exp
+if {[prepare_for_testing_full $testfile.exp \
+	 [list $testfile debug $srcfile debug $srcfile2 {}]]} {
+    untested $testfile.exp
     return -1
 }
 
-clean_restart ${testfile}
-
 # Problem does not occur otherwise.
 gdb_test_no_output "set can-use-hw-watchpoints 0"
 
diff --git a/gdb/testsuite/gdb.base/watchpoint-delete.exp b/gdb/testsuite/gdb.base/watchpoint-delete.exp
index 0a32f1e..6fc1042 100644
--- a/gdb/testsuite/gdb.base/watchpoint-delete.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-delete.exp
@@ -13,9 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "watchpoint-delete"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
     untested ${testfile}.exp
diff --git a/gdb/testsuite/gdb.base/watchpoint-hw.exp b/gdb/testsuite/gdb.base/watchpoint-hw.exp
index a1e4def..9021f41 100644
--- a/gdb/testsuite/gdb.base/watchpoint-hw.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-hw.exp
@@ -18,19 +18,13 @@ if {[skip_hw_watchpoint_tests]} {
     return 0
 }
 
-set testfile watchpoint-hw
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "Couldn't compile test program"
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # Create the watchpoint before the inferior gets started.  Now the native CPU
 # target is still not active and its `to_can_use_hw_breakpoint' is not
 # installed, therefore only a software watchpoint gets created.
diff --git a/gdb/testsuite/gdb.base/watchpoint-solib.exp b/gdb/testsuite/gdb.base/watchpoint-solib.exp
index b4fdb69..03ccf44 100644
--- a/gdb/testsuite/gdb.base/watchpoint-solib.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-solib.exp
@@ -26,10 +26,10 @@ set libfile "watchpoint-solib-shr"
 set libname "${libfile}.sl"
 set libsrcfile ${libfile}.c
 set srcfile $srcdir/$subdir/$testfile.c
-set binfile $objdir/$subdir/$testfile
-set shlibdir ${objdir}/${subdir}
+set binfile [standard_output_file $testfile]
+set shlibdir [standard_output_file {}]
 set libsrc  $srcdir/$subdir/$libfile.c
-set lib_sl  $objdir/$subdir/$libname
+set lib_sl  [standard_output_file $libname]
 set lib_dlopen [shlib_target_file ${libname}]
 set lib_syms [shlib_symbol_file ${libname}]
 
diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index 5961ef6..e0f7adc 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -16,9 +16,7 @@
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
 
-set testfile "watchpoint"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 if [get_compiler_info] {
     return -1
diff --git a/gdb/testsuite/gdb.base/watchpoints.exp b/gdb/testsuite/gdb.base/watchpoints.exp
index c26b766..7c10d81 100644
--- a/gdb/testsuite/gdb.base/watchpoints.exp
+++ b/gdb/testsuite/gdb.base/watchpoints.exp
@@ -16,9 +16,7 @@
 # This file was written by Pierre Muller. (muller@ics.u-strasbg.fr)
 
 
-set testfile "watchpoints"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 set wp_set 1
 
@@ -26,18 +24,11 @@ if [get_compiler_info] {
     return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested watchpoint.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
-
     # Disable hardware watchpoints if necessary.
     if [target_info exists gdb,no_hardware_watchpoints] {
         gdb_test_no_output "set can-use-hw-watchpoints 0" ""
diff --git a/gdb/testsuite/gdb.base/wchar.exp b/gdb/testsuite/gdb.base/wchar.exp
index 8757cca..b3d3019 100644
--- a/gdb/testsuite/gdb.base/wchar.exp
+++ b/gdb/testsuite/gdb.base/wchar.exp
@@ -13,8 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile wchar
-set srcfile ${testfile}.c
+standard_testfile .c
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
     return -1
 }
diff --git a/gdb/testsuite/gdb.base/whatis.exp b/gdb/testsuite/gdb.base/whatis.exp
index 40f317a..7cfaf2b 100644
--- a/gdb/testsuite/gdb.base/whatis.exp
+++ b/gdb/testsuite/gdb.base/whatis.exp
@@ -25,9 +25,8 @@ if [target_info exists no_long_long] {
     set exec_opts [list debug]
 }
 
-set testfile whatis
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $exec_opts] != "" } {
      untested whatis.exp
      return -1
@@ -41,10 +40,7 @@ if [get_compiler_info] {
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+clean_restart $binfile
 
 # Define a procedure to set up an xfail for all targets that put out a
 # `long' type as an `int' type.
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 5/7] test suite update - gdb.base/[nopqr]
  2013-06-19 21:04 [PATCH 0/7] first batch of test suite updates Tom Tromey
                   ` (5 preceding siblings ...)
  2013-06-19 21:04 ` [PATCH 2/7] test suite update - gdb.base/[cd] Tom Tromey
@ 2013-06-19 21:14 ` Tom Tromey
  2013-06-20 14:27 ` [PATCH 0/7] first batch of test suite updates Joel Brobecker
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Tom Tromey @ 2013-06-19 21:14 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Files gdb.base/[nopqr]*.exp.
See message #0 for details.

	* nextoverexit.exp, nextoverexit.exp, nodebug.exp, nofield.exp,
	nostdlib.exp, opaque.exp, overlays.exp, pc-fp.exp, pending.exp,
	permissions.exp, pie-execl.exp, pointers.exp, pr11022.exp,
	print-file-var.exp, printcmds.exp, prologue.exp, psymtab.exp,
	ptr-typedef.exp, ptype.exp, randomize.exp, readline-ask.exp,
	recpar.exp, recurse.exp, relativedebug.exp, relocate.exp,
	remote.exp, reread.exp, return-nodebug.exp, return2.exp: Use
	standard_testfile, standard_output_file, prepare_for_testing,
	clean_restart.
---
 gdb/testsuite/gdb.base/nextoverexit.exp   |  5 +----
 gdb/testsuite/gdb.base/nodebug.exp        | 11 +++-------
 gdb/testsuite/gdb.base/nofield.exp        | 10 +++------
 gdb/testsuite/gdb.base/nostdlib.exp       |  7 ++-----
 gdb/testsuite/gdb.base/opaque.exp         | 34 ++++++-------------------------
 gdb/testsuite/gdb.base/overlays.exp       | 33 ++++--------------------------
 gdb/testsuite/gdb.base/pc-fp.exp          | 15 ++++----------
 gdb/testsuite/gdb.base/pending.exp        |  6 ++----
 gdb/testsuite/gdb.base/permissions.exp    | 15 +++++++-------
 gdb/testsuite/gdb.base/pie-execl.exp      |  7 +++----
 gdb/testsuite/gdb.base/pointers.exp       |  9 ++------
 gdb/testsuite/gdb.base/pr11022.exp        | 10 +++------
 gdb/testsuite/gdb.base/print-file-var.exp |  6 +++---
 gdb/testsuite/gdb.base/printcmds.exp      |  5 ++---
 gdb/testsuite/gdb.base/prologue.exp       |  9 ++------
 gdb/testsuite/gdb.base/psymtab.exp        | 27 ++++++------------------
 gdb/testsuite/gdb.base/ptr-typedef.exp    | 10 +++------
 gdb/testsuite/gdb.base/ptype.exp          | 26 +++++------------------
 gdb/testsuite/gdb.base/randomize.exp      | 16 ++++-----------
 gdb/testsuite/gdb.base/readline-ask.exp   |  7 ++-----
 gdb/testsuite/gdb.base/recpar.exp         |  4 ++--
 gdb/testsuite/gdb.base/recurse.exp        | 18 +++++-----------
 gdb/testsuite/gdb.base/relativedebug.exp  | 10 +++------
 gdb/testsuite/gdb.base/relocate.exp       |  5 ++---
 gdb/testsuite/gdb.base/remote.exp         |  4 +---
 gdb/testsuite/gdb.base/reread.exp         |  6 +++---
 gdb/testsuite/gdb.base/return-nodebug.exp | 24 +++++-----------------
 gdb/testsuite/gdb.base/return2.exp        | 10 +++------
 28 files changed, 91 insertions(+), 258 deletions(-)

diff --git a/gdb/testsuite/gdb.base/nextoverexit.exp b/gdb/testsuite/gdb.base/nextoverexit.exp
index 4f4529f..6cf6f90 100644
--- a/gdb/testsuite/gdb.base/nextoverexit.exp
+++ b/gdb/testsuite/gdb.base/nextoverexit.exp
@@ -12,10 +12,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "nextoverexit"
-set executable $testfile
-set srcfile $testfile.c
-set binfile $objdir/$subdir/$testfile
+standard_testfile
 
 if {[prepare_for_testing $testfile.exp $testfile $testfile.c]} {
     return -1
diff --git a/gdb/testsuite/gdb.base/nodebug.exp b/gdb/testsuite/gdb.base/nodebug.exp
index e451b7b..2c991dc 100644
--- a/gdb/testsuite/gdb.base/nodebug.exp
+++ b/gdb/testsuite/gdb.base/nodebug.exp
@@ -16,9 +16,7 @@
 # Test that things still (sort of) work when compiled without -g.
 
 
-set testfile nodebug
-set srcfile $srcdir/$subdir/$testfile.c
-set binfile $objdir/$subdir/$testfile
+standard_testfile .c
 
 if [get_compiler_info] {
     return -1
@@ -32,17 +30,14 @@ if [test_compiler_info "xlc-*"] {
     set exec_opts ""
 }
 
-if  { [gdb_compile $srcfile $binfile executable $exec_opts] != "" } {
+if  { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
     untested "Couldn't compile $srcfile."
     return -1
 }
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+clean_restart $binfile
 
 if [runto inner] then {
     
diff --git a/gdb/testsuite/gdb.base/nofield.exp b/gdb/testsuite/gdb.base/nofield.exp
index 9b8ef06..bdaf6ca 100644
--- a/gdb/testsuite/gdb.base/nofield.exp
+++ b/gdb/testsuite/gdb.base/nofield.exp
@@ -13,9 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "nofield"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested "Couldn't compile ${srcfile}"
     return -1
@@ -24,10 +23,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
 set eol "\[\r\n\]+"
 set sp "\[ \t\]*"
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 gdb_test "ptype struct not_empty" \
          "type = struct not_empty {$eol${sp}void \\*e;$eol${sp}void \\*u;$eol}" \
diff --git a/gdb/testsuite/gdb.base/nostdlib.exp b/gdb/testsuite/gdb.base/nostdlib.exp
index 177023c..e139f3e 100644
--- a/gdb/testsuite/gdb.base/nostdlib.exp
+++ b/gdb/testsuite/gdb.base/nostdlib.exp
@@ -13,10 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile "nostdlib"
-set srcfile ${testfile}.c
-set executable ${testfile}
-set binfile ${objdir}/${subdir}/${executable}
+standard_testfile .c
 
 # If we're using a stub, breakpoints at the entry point will not trigger.
 # See also the comment in break-entry.exp.
@@ -48,7 +45,7 @@ if {$err != ""} {
     return -1
 }
 
-clean_restart $executable
+clean_restart $binfile
 
 gdb_breakpoint "*marker"
 gdb_breakpoint "*_start"
diff --git a/gdb/testsuite/gdb.base/opaque.exp b/gdb/testsuite/gdb.base/opaque.exp
index 3628e5c..94f0412 100644
--- a/gdb/testsuite/gdb.base/opaque.exp
+++ b/gdb/testsuite/gdb.base/opaque.exp
@@ -16,41 +16,19 @@
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
 
-set testfile "opaque"
-set binfile ${objdir}/${subdir}/opaque
-
-#if  { [gdb_compile "${srcdir}/${subdir}/opaque0.c ${srcdir}/${subdir}/opaque1.c" "${binfile}" executable {debug}] != "" } {
-#     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
-#}
-
-if  { [gdb_compile "${srcdir}/${subdir}/opaque0.c" "${binfile}0.o" object {debug}] != "" } {
-     untested opaque.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/opaque1.c" "${binfile}1.o" object {debug}] != "" } {
-     untested opaque.exp
-     return -1
-}
-
-if  { [gdb_compile "${binfile}0.o ${binfile}1.o" ${binfile} executable {debug}] != "" } {
-     untested opaque.exp
-     return -1
-}
-
-
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
 if [get_compiler_info] {
     return -1
 }
 
-# Start with a fresh gdb.
+standard_testfile opaque0.c opaque1.c
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile \
+	 [list $srcfile $srcfile2] debug]} {
+    untested $testfile.exp
+    return -1
+}
 
 #
 # Test basic opaque structure handling (statically).
diff --git a/gdb/testsuite/gdb.base/overlays.exp b/gdb/testsuite/gdb.base/overlays.exp
index d294378..13d2463 100644
--- a/gdb/testsuite/gdb.base/overlays.exp
+++ b/gdb/testsuite/gdb.base/overlays.exp
@@ -39,36 +39,11 @@ if [istarget "*-*-linux*"] then {
     return 
 }
 
-set testfile "overlays"
-set binfile ${objdir}/${subdir}/${testfile}
-set srcfile ${testfile}.c
+standard_testfile overlays.c ovlymgr.c foo.c bar.c baz.c grbx.c
 
-if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${testfile}.o" object {debug}] != ""} then {
-     untested overlays.exp
-     return -1
-}
-if {[gdb_compile "${srcdir}/${subdir}/ovlymgr.c" ovlymgr.o object {debug}] != ""} then {
-     untested overlays.exp
-     return -1
-}
-if {[gdb_compile "${srcdir}/${subdir}/foo.c" foo.o object {debug} ] != ""} then {
-     untested overlays.exp
-     return -1
-}
-
-if {[gdb_compile "${srcdir}/${subdir}/bar.c" bar.o object {debug}] != ""} then {
-     untested overlays.exp
-     return -1
-}
-if {[gdb_compile "${srcdir}/${subdir}/baz.c" baz.o object {debug}] != ""} then {
-     untested overlays.exp
-     return -1
-}
-if {[gdb_compile "${srcdir}/${subdir}/grbx.c" grbx.o object {debug}] != ""} then {
-     untested overlays.exp
-     return -1
-}
-if  {[gdb_compile "${testfile}.o ovlymgr.o foo.o bar.o baz.o grbx.o" ${binfile} executable "ldscript=-Wl,-T$linker_script"] != "" } {
+if {[build_executable $testfile.exp $testfile \
+	 [list $srcfile $srcfile2 $srcfile3 $srcfile4 $srcfile5 $srcfile6] \
+	 {debug ldscript=-Wl,-T$linker_script}] == -1} {
      untested overlays.exp
      return -1
 }
diff --git a/gdb/testsuite/gdb.base/pc-fp.exp b/gdb/testsuite/gdb.base/pc-fp.exp
index edf1d66..7bf2f37 100644
--- a/gdb/testsuite/gdb.base/pc-fp.exp
+++ b/gdb/testsuite/gdb.base/pc-fp.exp
@@ -24,24 +24,17 @@
 # test running programs
 #
 
-set testfile "pc-fp"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
-    untested pc-fp.exp
+if [get_compiler_info] {
     return -1
 }
 
-if [get_compiler_info] {
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug nowarnings}]} {
+    untested $testfile.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
     continue
diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp
index 1ab896a..1d621de 100644
--- a/gdb/testsuite/gdb.base/pending.exp
+++ b/gdb/testsuite/gdb.base/pending.exp
@@ -23,12 +23,10 @@ if {[skip_shlib_tests]} {
     return 0
 }
 
-set testfile "pending"
+standard_testfile .c
 set libfile "pendshr"
-set srcfile $testfile.c
 set libsrc  $srcdir/$subdir/$libfile.c
-set binfile $objdir/$subdir/$testfile
-set lib_sl  $objdir/$subdir/$libfile.sl
+set lib_sl  [standard_output_file $libfile.sl]
 
 set lib_opts  debug
 set exec_opts [list debug shlib=$lib_sl]
diff --git a/gdb/testsuite/gdb.base/permissions.exp b/gdb/testsuite/gdb.base/permissions.exp
index ed0e7e7..00d71d4 100644
--- a/gdb/testsuite/gdb.base/permissions.exp
+++ b/gdb/testsuite/gdb.base/permissions.exp
@@ -18,14 +18,13 @@
 # The permissions flags are only fully functional with stubs or targets
 # that can run asynchronously.
 
-set testfile permission
-set srcfile start.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
-     untested permissions.exp
-     return -1
-    }
+standard_testfile start.c
+
+if {[build_executable $testfile.exp $testfile \
+	 $srcfile {debug nowarnings}] == -1} {
+    untested $testfile.exp
+    return -1
+}
 
 if [get_compiler_info] {
     return -1
diff --git a/gdb/testsuite/gdb.base/pie-execl.exp b/gdb/testsuite/gdb.base/pie-execl.exp
index f8e5e33..2bdccc1 100644
--- a/gdb/testsuite/gdb.base/pie-execl.exp
+++ b/gdb/testsuite/gdb.base/pie-execl.exp
@@ -26,12 +26,11 @@ if [is_remote target] {
     continue
 }
 
-set testfile "pie-execl"
-set srcfile ${testfile}.c
+standard_testfile .c
 set executable1 ${testfile}1
 set executable2 ${testfile}2
-set binfile1 ${objdir}/${subdir}/${executable1}
-set binfile2 ${objdir}/${subdir}/${executable2}
+set binfile1 ${binfile}1
+set binfile2 ${binfile}2
 set binfile2_test_msg OBJDIR/${subdir}/${executable2}
 
 # Use conditional compilation according to `BIN' as GDB remembers the source
diff --git a/gdb/testsuite/gdb.base/pointers.exp b/gdb/testsuite/gdb.base/pointers.exp
index 6b9c52d..192b139 100644
--- a/gdb/testsuite/gdb.base/pointers.exp
+++ b/gdb/testsuite/gdb.base/pointers.exp
@@ -25,9 +25,7 @@
 # test running programs
 #
 
-set testfile "pointers"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
      untested pointers.exp
@@ -38,10 +36,7 @@ if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 
 #
diff --git a/gdb/testsuite/gdb.base/pr11022.exp b/gdb/testsuite/gdb.base/pr11022.exp
index 3465b74..86d7f04 100644
--- a/gdb/testsuite/gdb.base/pr11022.exp
+++ b/gdb/testsuite/gdb.base/pr11022.exp
@@ -17,9 +17,8 @@ if {[skip_hw_watchpoint_tests]} {
     return 0
 }
 
-set testfile "pr11022"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested pr11022.exp
      return -1
@@ -27,10 +26,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto_main] then {
     fail "Can't run to main"
diff --git a/gdb/testsuite/gdb.base/print-file-var.exp b/gdb/testsuite/gdb.base/print-file-var.exp
index fce4571..41f00f6 100644
--- a/gdb/testsuite/gdb.base/print-file-var.exp
+++ b/gdb/testsuite/gdb.base/print-file-var.exp
@@ -22,8 +22,8 @@ set executable print-file-var-main
 set lib1 "print-file-var-lib1"
 set lib2 "print-file-var-lib2"
 
-set libobj1 "${objdir}/${subdir}/${lib1}.so"
-set libobj2 "${objdir}/${subdir}/${lib2}.so"
+set libobj1 [standard_output_file ${lib1}.so]
+set libobj2 [standard_output_file ${lib2}.so]
 
 set lib_opts { debug additional_flags=-fPIC }
 
@@ -38,7 +38,7 @@ if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib2}.c \
     return -1
 }
 if { [gdb_compile "${srcdir}/${subdir}/${executable}.c" \
-                  "${objdir}/${subdir}/${executable}" \
+                  [standard_output_file ${executable}] \
                   executable \
                   [list debug shlib=${libobj1} shlib=${libobj2}]]
      != ""} {
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 316461a..0597ab0 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -20,9 +20,8 @@
 
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
-set testfile "printcmds"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested printcmds.exp
      return -1
diff --git a/gdb/testsuite/gdb.base/prologue.exp b/gdb/testsuite/gdb.base/prologue.exp
index 409c80e..ebc1adf 100644
--- a/gdb/testsuite/gdb.base/prologue.exp
+++ b/gdb/testsuite/gdb.base/prologue.exp
@@ -16,19 +16,14 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "prologue"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested prologue.exp
      return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
diff --git a/gdb/testsuite/gdb.base/psymtab.exp b/gdb/testsuite/gdb.base/psymtab.exp
index 9c96536..854455e 100644
--- a/gdb/testsuite/gdb.base/psymtab.exp
+++ b/gdb/testsuite/gdb.base/psymtab.exp
@@ -26,23 +26,7 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "psymtab"
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${testfile}1.c" "${testfile}1.o" object {debug}] != "" } {
-     untested psymtab.exp
-     return -1
-}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${testfile}2.c" "${testfile}2.o" object {debug}] != "" } {
-     untested psymtab.exp
-     return -1
-}
-
-if  { [gdb_compile "${testfile}1.o ${testfile}2.o" ${binfile} executable {debug}] != "" } {
-     untested psymtab.exp
-     return -1
-}
+standard_testfile psymtab1.c psymtab2.c
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
@@ -50,10 +34,11 @@ if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile \
+	 [list $srcfile $srcfile2] debug]} {
+    untested $testfile.exp
+    return -1
+}
 
 # Disable the prompt for whether to set pending breakpoints.
 # We don't want a breakpoint, we just want to verify the symbol
diff --git a/gdb/testsuite/gdb.base/ptr-typedef.exp b/gdb/testsuite/gdb.base/ptr-typedef.exp
index f0ef97a..d0d2628 100644
--- a/gdb/testsuite/gdb.base/ptr-typedef.exp
+++ b/gdb/testsuite/gdb.base/ptr-typedef.exp
@@ -13,9 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile ptr-typedef
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested "Couldn't compile test program"
     return -1
@@ -23,10 +22,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 # Get things started.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 if ![runto marker1] {
     untested "Couldn't run to marker1"
diff --git a/gdb/testsuite/gdb.base/ptype.exp b/gdb/testsuite/gdb.base/ptype.exp
index bb186d3..fdc04fe 100644
--- a/gdb/testsuite/gdb.base/ptype.exp
+++ b/gdb/testsuite/gdb.base/ptype.exp
@@ -19,22 +19,11 @@
 # test running programs
 #
 
-set testfile "ptype"
-set srcfile0 ${testfile}.c
-set srcfile1 ${testfile}1.c
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile0}" "${binfile}0.o" object {debug}] != "" } {
-     untested ptype.exp
-     return -1
-}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug}] != "" } {
-     untested ptype.exp
-     return -1
-}
-if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug}] != "" } {
-     untested ptype.exp
-     return -1
+standard_testfile .c ptype1.c
+
+if {[prepare_for_testing ${testfile}.exp ${testfile} \
+	 [list $srcfile $srcfile2] {debug nowarnings}]} {
+    return -1
 }
 
 # Create and source the file that provides information about the compiler
@@ -43,11 +32,6 @@ if [get_compiler_info] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # Test ptype of unnamed enumeration members before any action causes
 # the partial symbol table to be expanded to full symbols.  This fails
 # with stabs compilers which fail to use a nameless stab (such as
diff --git a/gdb/testsuite/gdb.base/randomize.exp b/gdb/testsuite/gdb.base/randomize.exp
index e84b493..7859906 100644
--- a/gdb/testsuite/gdb.base/randomize.exp
+++ b/gdb/testsuite/gdb.base/randomize.exp
@@ -13,21 +13,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile randomize
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested "Couldn't compile test program"
+standard_testfile
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 proc address_get { testname } {
     global gdb_prompt
 
diff --git a/gdb/testsuite/gdb.base/readline-ask.exp b/gdb/testsuite/gdb.base/readline-ask.exp
index b71bd0a..33f3b25 100644
--- a/gdb/testsuite/gdb.base/readline-ask.exp
+++ b/gdb/testsuite/gdb.base/readline-ask.exp
@@ -13,10 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile readline-ask
-set executable ${testfile}.x
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${executable}
+standard_testfile .c
 set inputrc ${srcdir}/${subdir}/${testfile}.inputrc
 
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}] != "" } {
@@ -26,7 +23,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}]
 
 # INPUTRC gets reset for the next testfile.
 setenv INPUTRC $inputrc
-clean_restart ${executable}
+clean_restart ${binfile}
 
 gdb_test_no_output "set width 50"
 gdb_test_no_output "set height 3"
diff --git a/gdb/testsuite/gdb.base/recpar.exp b/gdb/testsuite/gdb.base/recpar.exp
index fabd131..699d8a6 100644
--- a/gdb/testsuite/gdb.base/recpar.exp
+++ b/gdb/testsuite/gdb.base/recpar.exp
@@ -13,8 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-set testfile recpar
-set srcfile ${testfile}.c
+standard_testfile .c
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
     return -1
 }
diff --git a/gdb/testsuite/gdb.base/recurse.exp b/gdb/testsuite/gdb.base/recurse.exp
index da635bf..7155808 100644
--- a/gdb/testsuite/gdb.base/recurse.exp
+++ b/gdb/testsuite/gdb.base/recurse.exp
@@ -16,20 +16,12 @@
 # This file was written by Jeff Law. (law@cs.utah.edu)
 
 
-set testfile "recurse"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-     untested recurse.exp
-     return -1
-}
-
-# Start with a fresh gdb.
+standard_testfile
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
+}
 
 proc recurse_tests {} {
 
diff --git a/gdb/testsuite/gdb.base/relativedebug.exp b/gdb/testsuite/gdb.base/relativedebug.exp
index 90808f3..954401c 100644
--- a/gdb/testsuite/gdb.base/relativedebug.exp
+++ b/gdb/testsuite/gdb.base/relativedebug.exp
@@ -18,9 +18,8 @@ if [target_info exists gdb,nosignals] {
     continue
 }
 
-set testfile relativedebug
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested "Couldn't compile test program"
     return -1
@@ -28,10 +27,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 # Get things started.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 runto_main
 
diff --git a/gdb/testsuite/gdb.base/relocate.exp b/gdb/testsuite/gdb.base/relocate.exp
index 9bb76aa..d69bca1 100644
--- a/gdb/testsuite/gdb.base/relocate.exp
+++ b/gdb/testsuite/gdb.base/relocate.exp
@@ -16,9 +16,8 @@
 # relocate.exp -- Expect script to test loading symbols from unrelocated
 #		  object files.
 
-set testfile relocate
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}.o
+standard_testfile .c
+append binfile .o
 
 remote_exec build "rm -f ${binfile}"
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}] != "" } {
diff --git a/gdb/testsuite/gdb.base/remote.exp b/gdb/testsuite/gdb.base/remote.exp
index dfaf646..2738e47 100644
--- a/gdb/testsuite/gdb.base/remote.exp
+++ b/gdb/testsuite/gdb.base/remote.exp
@@ -20,9 +20,7 @@ if {! [is_remote target]} {
     return
 }
 
-set testfile "remote"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 
 gdb_start
 
diff --git a/gdb/testsuite/gdb.base/reread.exp b/gdb/testsuite/gdb.base/reread.exp
index b0a2fc6..cee8b69 100644
--- a/gdb/testsuite/gdb.base/reread.exp
+++ b/gdb/testsuite/gdb.base/reread.exp
@@ -20,7 +20,7 @@ set prototypes 1
 set testfile1 "reread1"
 set srcfile1 ${testfile1}.c
 # Cygwin needs $EXEEXT.
-set binfile1 ${objdir}/${subdir}/${testfile1}$EXEEXT
+set binfile1 [standard_output_file ${testfile1}$EXEEXT]
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug nowarnings}] != "" } {
     untested reread.exp
@@ -31,7 +31,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {d
 
 set testfile2 "reread2"
 set srcfile2 ${testfile2}.c
-set binfile2 ${objdir}/${subdir}/${testfile2}$EXEEXT
+set binfile2 [standard_output_file ${testfile2}$EXEEXT]
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug nowarnings}] != ""
       && [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug nowarnings additional_flags=-DNO_SECTIONS}] != ""} {
@@ -42,7 +42,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {d
 # Start with a fresh gdb.
 
 set testfile "reread"
-set binfile ${objdir}/${subdir}/${testfile}$EXEEXT
+set binfile [standard_output_file ${testfile}$EXEEXT]
 
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
diff --git a/gdb/testsuite/gdb.base/return-nodebug.exp b/gdb/testsuite/gdb.base/return-nodebug.exp
index 76be853..66c0a29 100644
--- a/gdb/testsuite/gdb.base/return-nodebug.exp
+++ b/gdb/testsuite/gdb.base/return-nodebug.exp
@@ -45,30 +45,16 @@ foreach type {{signed char} {short} {int} {long} {long long} {float} {double}} {
     set typeesc [string map {{ } {\ }} $type]
     set typenospace [string map {{ } -} $type]
 
-    set testfile "return-nodebug"
-    set srcfile ${testfile}.c
-    set srcfile1 ${testfile}1.c
-    set binfile ${objdir}/${subdir}/${testfile}-${typenospace}
+    standard_testfile .c return-nodebug1.c
 
     set additional_flags "additional_flags=-DTYPE=$typeesc"
 
-    if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object [list debug $additional_flags]] != "" } {
+    if {[prepare_for_testing_full $testfile.exp \
+	     [list ${testfile}-${typenospace} debug \
+		  $srcfile [list debug $additional_flags] \
+		  $srcfile2 [list $additional_flags]]]} {
 	continue
     }
 
-    # This one is compiled without debug info.
-    if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object [list $additional_flags]] != "" } {
-	continue
-    }
-
-    if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug}] != "" } {
-	continue
-    }
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load ${binfile}
-
     do_test $type
 }
diff --git a/gdb/testsuite/gdb.base/return2.exp b/gdb/testsuite/gdb.base/return2.exp
index 1bfad18..3b44415 100644
--- a/gdb/testsuite/gdb.base/return2.exp
+++ b/gdb/testsuite/gdb.base/return2.exp
@@ -16,9 +16,8 @@
 # This file was written by Michael Snyder (msnyder@redhat.com)
 
 
-set testfile "return2"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested return2.exp
      return -1
@@ -103,10 +102,7 @@ proc return2_tests { } {
 
 # Start with a fresh gdb.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 set timeout 30
 return2_tests
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/7] first batch of test suite updates
  2013-06-19 21:04 [PATCH 0/7] first batch of test suite updates Tom Tromey
                   ` (6 preceding siblings ...)
  2013-06-19 21:14 ` [PATCH 5/7] test suite update - gdb.base/[nopqr] Tom Tromey
@ 2013-06-20 14:27 ` Joel Brobecker
  2013-06-20 16:19 ` Pedro Alves
  2013-06-27 17:38 ` Tom Tromey
  9 siblings, 0 replies; 15+ messages in thread
From: Joel Brobecker @ 2013-06-20 14:27 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Hi Tom,

> I've been working on a long-term project to fully parallelize the gdb
> test suite.  The end goal is that it should be possible to run each
> .exp file in parallel.

Thanks for doing this. I think this is going to be a welcome time
accelerator...

> This project has many parts; and the full patch is not quite finished
> (and is also very large).  I wanted to start sending out some of the
> more straightforward changes, mostly so that I wouldn't have to
> constantly rebase them.  I think these changes are reasonable in their
> own right.

I agree that they are useful on their own. If anything, the'll prevent
people from copy-pasting the old style...

-- 
Joel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/7] first batch of test suite updates
  2013-06-19 21:04 [PATCH 0/7] first batch of test suite updates Tom Tromey
                   ` (7 preceding siblings ...)
  2013-06-20 14:27 ` [PATCH 0/7] first batch of test suite updates Joel Brobecker
@ 2013-06-20 16:19 ` Pedro Alves
  2013-06-20 17:28   ` Tom Tromey
  2013-06-27 17:38 ` Tom Tromey
  9 siblings, 1 reply; 15+ messages in thread
From: Pedro Alves @ 2013-06-20 16:19 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 06/19/2013 10:03 PM, Tom Tromey wrote:
> I've been working on a long-term project to fully parallelize the gdb
> test suite.  The end goal is that it should be possible to run each
> .exp file in parallel.

Looking forward.

> This project has many parts; and the full patch is not quite finished
> (and is also very large).  I wanted to start sending out some of the
> more straightforward changes, mostly so that I wouldn't have to
> constantly rebase them.  I think these changes are reasonable in their
> own right.

Agreed.

> 
> This series holds all the "easy" conversions from gdb.base.  This is
> just straightforward changes to use standard_testfile and
> standard_output_file, plus also prepare_for_testing or clean_restart
> as well.
> 
> This series fixes a few spots where .exp files did not interact well.
> For example, cases where the tests used the same executable name.
> 
> This regression tests cleanly; however since some file names changed
> there are a few minor output changes:
> 
>     Missing tests:
>     gdb.base/corefile.exp: args: -core=coremaker.core: PASS
>     gdb.base/corefile.exp: args: execfile -core=coremaker.core: PASS
>     gdb.base/info-proc.exp: core break.gcore: PASS
> 
>     New tests:
>     gdb.base/corefile.exp: args: -core=corefile.core: PASS
>     gdb.base/corefile.exp: args: execfile -core=corefile.core: PASS
>     gdb.base/default.exp: set the history filename: PASS
>     gdb.base/info-proc.exp: core info-proc.gcore: PASS
> 
> I don't consider this to be a problem.

Agreed.

> 
> I split the patch up into 7 roughly equal-sized pieces based on file
> name.
> 
> After this series, gdb.base is still not parallel-clean.  There are
> some lurking "trickier" cases I omitted from this series, as they
> depend on new testsuite/lib infrastructure.  I plan to work through
> all the easy/obvious bits first, before starting to upstream that
> stuff.

I think I saw places in the context of the patches that could be
made to use build_executable instead of gdb_compile, and didn't look
tricky, but, this is all good forward progress as is!

Thanks a lot for doing this.

I tried skimming the series, but got extremely bored after
patch #1.  :-)

I'm all for this.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/7] first batch of test suite updates
  2013-06-20 16:19 ` Pedro Alves
@ 2013-06-20 17:28   ` Tom Tromey
  0 siblings, 0 replies; 15+ messages in thread
From: Tom Tromey @ 2013-06-20 17:28 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro> I think I saw places in the context of the patches that could be
Pedro> made to use build_executable instead of gdb_compile, and didn't look
Pedro> tricky, but, this is all good forward progress as is!

Yeah, not all spots are easy to convert in this way, and after
processing many of them it is easy to miss a few.

Pedro> I tried skimming the series, but got extremely bored after
Pedro> patch #1.  :-)

Later parts of the series are more exciting, though not by much.

I do have some fun numbers about the timings though :)

Tom


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/7] first batch of test suite updates
  2013-06-19 21:04 [PATCH 0/7] first batch of test suite updates Tom Tromey
                   ` (8 preceding siblings ...)
  2013-06-20 16:19 ` Pedro Alves
@ 2013-06-27 17:38 ` Tom Tromey
  2013-06-27 18:45   ` Tom Tromey
  9 siblings, 1 reply; 15+ messages in thread
From: Tom Tromey @ 2013-06-27 17:38 UTC (permalink / raw)
  To: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> This series holds all the "easy" conversions from gdb.base.  This is
Tom> just straightforward changes to use standard_testfile and
Tom> standard_output_file, plus also prepare_for_testing or clean_restart
Tom> as well.

I'm going to check this series in now.

Tom


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/7] first batch of test suite updates
  2013-06-27 17:38 ` Tom Tromey
@ 2013-06-27 18:45   ` Tom Tromey
  0 siblings, 0 replies; 15+ messages in thread
From: Tom Tromey @ 2013-06-27 18:45 UTC (permalink / raw)
  To: gdb-patches

Tom> I'm going to check this series in now.

FWIW I rebased this onto master, then regression tested it again using
both native and native-gdbserver.

Tom


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [patch] testsuite build regression on CentOS-5  [Re: [PATCH 1/7] test suite update - gdb.base/[ab]]
  2013-06-19 21:04 ` [PATCH 1/7] test suite update - gdb.base/[ab] Tom Tromey
@ 2013-07-01  8:19   ` Jan Kratochvil
  2013-07-02 20:08     ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 15+ messages in thread
From: Jan Kratochvil @ 2013-07-01  8:19 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Wed, 19 Jun 2013 23:03:35 +0200, Tom Tromey wrote:
> --- a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
> +++ b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
[...]
>  set additional_flags {-ffunction-sections -Wl,--gc-sections}
> -if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
> -	   [list debug c++ additional_flags=$additional_flags]] != "" } {
> -    untested $srcfile
> +if {[prepare_for_testing $testfile.exp $testfile $srcfile \
> +	 [list debug c++ additional_flags=$additional_flags]]} {
> +    untested $testfile.exp
>      return -1
>  }

 Running gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp ...
-PASS: gdb.base/break-on-linker-gcd-function.exp: b 24
+gdb compile failed, g++: --gc-sections: linker input file unused because linking not done
+UNTESTED: gdb.base/break-on-linker-gcd-function.exp: break-on-linker-gcd-function.exp
+UNTESTED: gdb.base/break-on-linker-gcd-function.exp: break-on-linker-gcd-function.exp

Retested it still FAILs with the unfixed GDB.

I will check it in.


Jan


gdb/testsuite/
2013-07-01  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.base/break-on-linker-gcd-function.exp: Replace
	prepare_for_testing by build_executable_from_specs and clean_restart.

diff --git a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
index 7a4ef83..f9b844f 100644
--- a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
+++ b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp
@@ -32,12 +32,15 @@ if [get_compiler_info "c++"] {
 }
 
 set additional_flags {-ffunction-sections -Wl,--gc-sections}
-if {[prepare_for_testing $testfile.exp $testfile $srcfile \
-	 [list debug c++ additional_flags=$additional_flags]]} {
+if {[build_executable_from_specs $testfile.exp $testfile \
+       {c++ additional_flags=-Wl,--gc-sections} \
+       $srcfile {debug c++ additional_flags=-ffunction-sections}]} {
     untested $testfile.exp
     return -1
 }
 
+clean_restart $testfile
+
 # Single hex digit
 set xd {[0-9a-f]}
 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [commit] [patch] testsuite build regression on CentOS-5  [Re: [PATCH 1/7] test suite update - gdb.base/[ab]]
  2013-07-01  8:19   ` [patch] testsuite build regression on CentOS-5 [Re: [PATCH 1/7] test suite update - gdb.base/[ab]] Jan Kratochvil
@ 2013-07-02 20:08     ` Jan Kratochvil
  0 siblings, 0 replies; 15+ messages in thread
From: Jan Kratochvil @ 2013-07-02 20:08 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Mon, 01 Jul 2013 10:19:22 +0200, Jan Kratochvil wrote:
> gdb/testsuite/
> 2013-07-01  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* gdb.base/break-on-linker-gcd-function.exp: Replace
> 	prepare_for_testing by build_executable_from_specs and clean_restart.

Checked in:
	http://sourceware.org/ml/gdb-cvs/2013-07/msg00022.html


Jan


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-07-02 20:08 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-19 21:04 [PATCH 0/7] first batch of test suite updates Tom Tromey
2013-06-19 21:04 ` [PATCH 6/7] test suite update - gdb.base/s* Tom Tromey
2013-06-19 21:04 ` [PATCH 1/7] test suite update - gdb.base/[ab] Tom Tromey
2013-07-01  8:19   ` [patch] testsuite build regression on CentOS-5 [Re: [PATCH 1/7] test suite update - gdb.base/[ab]] Jan Kratochvil
2013-07-02 20:08     ` [commit] " Jan Kratochvil
2013-06-19 21:04 ` [PATCH 7/7] test suite update - gdb.base/[t-z] Tom Tromey
2013-06-19 21:04 ` [PATCH 3/7] test suite update - gdb.base/[efg] Tom Tromey
2013-06-19 21:04 ` [PATCH 4/7] test suite update - gdb.base/[hijklm] Tom Tromey
2013-06-19 21:04 ` [PATCH 2/7] test suite update - gdb.base/[cd] Tom Tromey
2013-06-19 21:14 ` [PATCH 5/7] test suite update - gdb.base/[nopqr] Tom Tromey
2013-06-20 14:27 ` [PATCH 0/7] first batch of test suite updates Joel Brobecker
2013-06-20 16:19 ` Pedro Alves
2013-06-20 17:28   ` Tom Tromey
2013-06-27 17:38 ` Tom Tromey
2013-06-27 18:45   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox