Convert files gdb.base/s*.exp to use standard_output_file et al.
	* gdb.base/save-bp.exp, gdb.base/savedregs.exp,
	gdb.base/scope.exp, gdb.base/sep.exp, gdb.base/sepsymtab.exp,
	gdb.base/set-lang-auto.exp, gdb.base/setshow.exp,
	gdb.base/setvar.exp, gdb.base/shlib-call.exp,
	gdb.base/shreloc.exp, gdb.base/sigall.exp,
	gdb.base/sigaltstack.exp, gdb.base/sigbpt.exp,
	gdb.base/sigchld.exp, gdb.base/siginfo-addr.exp,
	gdb.base/siginfo-infcall.exp, gdb.base/siginfo-obj.exp,
	gdb.base/siginfo.exp, gdb.base/signals.exp, gdb.base/signest.exp,
	gdb.base/signull.exp, gdb.base/sigrepeat.exp,
	gdb.base/sigstep.exp, gdb.base/sizeof.exp,
	gdb.base/skip-solib.exp, gdb.base/so-impl-ld.exp,
	gdb.base/solib-display.exp, gdb.base/solib-nodir.exp,
	gdb.base/solib-overlap.exp, gdb.base/solib-symbol.exp,
	gdb.base/solib-weak.exp, gdb.base/source.exp,
	gdb.base/stack-checking.exp, gdb.base/stale-infcall.exp,
	gdb.base/stap-probe.exp, gdb.base/start.exp,
	gdb.base/step-break.exp, gdb.base/step-bt.exp,
	gdb.base/step-line.exp, gdb.base/step-resume-infcall.exp,
	gdb.base/step-test.exp, gdb.base/structs.exp,
	gdb.base/structs2.exp, gdb.base/structs3.exp,
	gdb.base/symbol-without-target_section.exp: Use standard_testfile,
	standard_output_file, prepare_for_testing, clean_restart.
+2013-06-27  Tom Tromey  <tromey@redhat.com>
+
+       * gdb.base/save-bp.exp, gdb.base/savedregs.exp,
+       gdb.base/scope.exp, gdb.base/sep.exp, gdb.base/sepsymtab.exp,
+       gdb.base/set-lang-auto.exp, gdb.base/setshow.exp,
+       gdb.base/setvar.exp, gdb.base/shlib-call.exp,
+       gdb.base/shreloc.exp, gdb.base/sigall.exp,
+       gdb.base/sigaltstack.exp, gdb.base/sigbpt.exp,
+       gdb.base/sigchld.exp, gdb.base/siginfo-addr.exp,
+       gdb.base/siginfo-infcall.exp, gdb.base/siginfo-obj.exp,
+       gdb.base/siginfo.exp, gdb.base/signals.exp, gdb.base/signest.exp,
+       gdb.base/signull.exp, gdb.base/sigrepeat.exp,
+       gdb.base/sigstep.exp, gdb.base/sizeof.exp,
+       gdb.base/skip-solib.exp, gdb.base/so-impl-ld.exp,
+       gdb.base/solib-display.exp, gdb.base/solib-nodir.exp,
+       gdb.base/solib-overlap.exp, gdb.base/solib-symbol.exp,
+       gdb.base/solib-weak.exp, gdb.base/source.exp,
+       gdb.base/stack-checking.exp, gdb.base/stale-infcall.exp,
+       gdb.base/stap-probe.exp, gdb.base/start.exp,
+       gdb.base/step-break.exp, gdb.base/step-bt.exp,
+       gdb.base/step-line.exp, gdb.base/step-resume-infcall.exp,
+       gdb.base/step-test.exp, gdb.base/structs.exp,
+       gdb.base/structs2.exp, gdb.base/structs3.exp,
+       gdb.base/symbol-without-target_section.exp: Use standard_testfile,
+       standard_output_file, prepare_for_testing, clean_restart.
+
 2013-06-27  Tom Tromey  <tromey@redhat.com>
 
        * gdb.base/nextoverexit.exp, gdb.base/nextoverexit.exp,
 
 # 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
 }
 
 
 }
 
 
-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] } {
 
 # 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
     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
 
 # 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
 
 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
 
 # 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}] != "" } {
     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]
 
 # 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.
 
 
 # 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
 
 # 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] } {
 
 # 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.
     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
 
     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}]
 
 # 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"
 
 #
 
 
-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
 
 # 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
     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}"]} {
 
     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} {
     set thissig $nextsig
 }
 
-gdb_load $binfile
-
 # The list of signals that the program generates, in the order they
 # are generated.
 set signals {
 
 }
 
 
-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"
 
 }
 
 
-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.
 #
 
     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
 
 
 }
 
 
-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
 
     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
 }
 
 
 }
 
 
-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
 
 }
 
 
-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
 
 }
 
 
-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
 }
 test_handle_all_print
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+clean_restart $binfile
 
 if [runto_main] then {
 
 
 # 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."
 
 }
 
 
-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.
 
 }
 
 
-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 {
 
 }
 
 
-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
 
 # 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
 
 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
     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
 }
 
 
     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]
 }
 
 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.
 
 # 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] {
 
 # 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]
 
     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}]
 
 # 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] {
 
 }
 
 proc do_test { lib1opts lib2opts lib1first } {
-    global objdir srcdir subdir
+    global srcdir subdir
 
     set testfile "solib-weak"
     set srcfile ${testfile}.c
        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}]
 
 
 
 
-set testfile "structs"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile structs.c
 
 gdb_start
 
 
 # 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"
 
 # 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
 }
 
 # 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
     }
 
 # 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.
 
 
 # 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
 
 # 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()"
 
 # 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
 
 # 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
 }
 
 
 # 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}] != "" } {
      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"
 
     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]|\\|'))'}
     global testfile
     global srcfile
     global binfile
-    global objdir
     global subdir
     global srcdir
     global gdb_prompt
        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"
 
 # 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.
 
 # 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"
 
 
 # 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
 
 # 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"