FYI: clean up gdb.cp

Tom Tromey tromey@redhat.com
Tue Jul 10 15:18:00 GMT 2012


I'm checking this in.

This applies the standard_testfile cleanup to gdb.cp.

Regtested on x86-64 Fedora 16.

Tom

2012-07-10  Tom Tromey  <tromey@redhat.com>

	* gdb.cp/abstract-origin.exp: Use standard_testfile.
	* gdb.cp/ambiguous.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/annota2.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/annota3.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/anon-ns.exp: Use standard_testfile.
	* gdb.cp/anon-struct.exp: Use standard_testfile.
	* gdb.cp/anon-union.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/arg-reference.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/bool.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/breakpoint.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/bs15503.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/call-c.exp: Use standard_testfile, clean_restart,
	standard_output_file.
	* gdb.cp/casts.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/class2.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/classes.exp: Use standard_testfile, prepare_for_testing.
	(test_static_members): Update.
	* gdb.cp/cmpd-minsyms.exp: Use standard_testfile.
	* gdb.cp/converts.exp: Use standard_testfile.
	* gdb.cp/cp-relocate.exp: Use standard_testfile.
	* gdb.cp/cpcompletion.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/cpexprs.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/cplabel.exp: Use standard_testfile.
	* gdb.cp/cplusfuncs.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/ctti.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/derivation.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/destrprint.exp: Use standard_testfile.
	* gdb.cp/dispcxx.exp: Use standard_testfile.
	* gdb.cp/exception.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/expand-psymtabs-cxx.exp: Use standard_testfile.
	* gdb.cp/extern-c.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/formatted-ref.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/fpointer.exp: Use standard_testfile.
	* gdb.cp/gdb1355.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/gdb2384.exp: Use standard_testfile, clean_restart,
	standard_output_file.
	* gdb.cp/gdb2495.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/hang.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/infcall-dlopen.exp: Use standard_testfile,
	standard_output_file.
	* gdb.cp/inherit.exp: Use standard_testfile, prepare_for_testing.
	(do_tests): Update.
	* gdb.cp/koenig.exp: Use standard_testfile.
	* gdb.cp/local.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/m-data.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/m-static.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/mb-ctor.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/mb-inline.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/mb-templates.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/member-ptr.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/meth-typedefs.exp: Use standard_testfile.
	* gdb.cp/method.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/method2.exp: Use standard_testfile.
	* gdb.cp/minsym-fallback.exp: Use standard_testfile,
	standard_output_file.
	* gdb.cp/misc.exp: Use standard_testfile, prepare_for_testing.
	(do_tests): Update.
	* gdb.cp/namespace-enum.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/namespace-nested-import.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/namespace.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/nextoverthrow.exp: Use standard_testfile.
	* gdb.cp/no-dmgl-verbose.exp: Use standard_testfile.
	* gdb.cp/nsdecl.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/nsimport.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/nsnested.exp: Use standard_testfile.
	* gdb.cp/nsnoimports.exp: Use standard_testfile.
	* gdb.cp/nsrecurs.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/nsstress.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/nsusing.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/operator.exp: Use standard_testfile.
	* gdb.cp/oranking.exp: Use standard_testfile.
	* gdb.cp/overload-const.exp: Use standard_testfile.
	* gdb.cp/overload.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/ovldbreak.exp: Use standard_testfile.
	* gdb.cp/ovsrch.exp: Use standard_testfile.
	* gdb.cp/paren-type.exp: Use standard_testfile.
	* gdb.cp/pass-by-ref.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/pr-1023.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/pr-1210.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/pr-574.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/pr10687.exp: Use standard_testfile, clean_restart.
	* gdb.cp/pr10728.exp: Use standard_testfile,
	standard_output_file.
	* gdb.cp/pr12028.exp: Use standard_testfile.
	* gdb.cp/pr9067.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/pr9167.exp: Use standard_testfile.
	* gdb.cp/pr9631.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/printmethod.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/psmang.exp: Use standard_testfile, clean_restart.
	* gdb.cp/psymtab-parameter.exp: Use standard_testfile.
	* gdb.cp/ptype-cv-cp.exp: Use standard_testfile.
	* gdb.cp/re-set-overloaded.exp: Use standard_testfile,
	standard_output_file.
	* gdb.cp/readnow-language.exp: Use standard_testfile.
	* gdb.cp/ref-params.exp: Use standard_testfile, build_executable.
	(gdb_start_again): Use clean_restart.
	* gdb.cp/ref-types.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/rtti.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/shadow.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/smartp.exp: Use standard_testfile.
	* gdb.cp/static-method.exp: Use standard_testfile.
	* gdb.cp/static-print-quit.exp: Use standard_testfile.
	* gdb.cp/temargs.exp: Use standard_testfile.
	* gdb.cp/templates.exp: Use standard_testfile,
	prepare_for_testing.
	(do_tests): Update.
	* gdb.cp/try_catch.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/typedef-operator.exp: Use standard_testfile.
	* gdb.cp/userdef.exp: Use standard_testfile, prepare_for_testing.
	* gdb.cp/virtbase.exp: Use standard_testfile,
	prepare_for_testing.
	* gdb.cp/virtfunc.exp: Use standard_testfile,
	prepare_for_testing.
	(do_tests): Update.
	* gdb.cp/virtfunc2.exp: Use standard_testfile,
	prepare_for_testing.

Index: gdb.cp/abstract-origin.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/abstract-origin.exp,v
retrieving revision 1.4
diff -u -r1.4 abstract-origin.exp
--- gdb.cp/abstract-origin.exp	4 Jan 2012 08:17:46 -0000	1.4
+++ gdb.cp/abstract-origin.exp	10 Jul 2012 15:12:03 -0000
@@ -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 abstract-origin
-set srcfile ${testfile}.cc
-if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] {
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     return -1
 }
 
Index: gdb.cp/ambiguous.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/ambiguous.exp,v
retrieving revision 1.14
diff -u -r1.14 ambiguous.exp
--- gdb.cp/ambiguous.exp	21 Jun 2012 20:46:22 -0000	1.14
+++ gdb.cp/ambiguous.exp	10 Jul 2012 15:12:03 -0000
@@ -28,9 +28,7 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "ambiguous"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1;
@@ -38,18 +36,10 @@
 
 if { [test_compiler_info gcc-*] } then { continue }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested ambiguous.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
-
 #
 # set it up at a breakpoint so we can play with the variable values
 #
Index: gdb.cp/annota2.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/annota2.exp,v
retrieving revision 1.26
diff -u -r1.26 annota2.exp
--- gdb.cp/annota2.exp	16 Jan 2012 16:21:45 -0000	1.26
+++ gdb.cp/annota2.exp	10 Jul 2012 15:12:03 -0000
@@ -22,12 +22,10 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "annota2"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ nowarnings}] != "" } {
-    untested annota2.exp
+if {[prepare_for_testing $testfile.exp $testfile $srcfile \
+	 {debug c++ nowarnings}]} {
     return -1
 }
 
@@ -40,12 +38,6 @@
     return 0
 }
 
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 #
 # line number where we need to stop in main
 #
Index: gdb.cp/annota3.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/annota3.exp,v
retrieving revision 1.24
diff -u -r1.24 annota3.exp
--- gdb.cp/annota3.exp	16 Jan 2012 16:21:45 -0000	1.24
+++ gdb.cp/annota3.exp	10 Jul 2012 15:12:03 -0000
@@ -22,12 +22,10 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "annota3"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ nowarnings}] != "" } {
-    untested annota3.exp
+if {[prepare_for_testing $testfile.exp $testfile $srcfile \
+	 {debug c++ nowarnings}]} {
     return -1
 }
 
@@ -40,12 +38,6 @@
     return 0
 }
 
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 #
 # line number where we need to stop in main
 #
Index: gdb.cp/anon-ns.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/anon-ns.exp,v
retrieving revision 1.2
diff -u -r1.2 anon-ns.exp
--- gdb.cp/anon-ns.exp	4 Jan 2012 08:17:46 -0000	1.2
+++ gdb.cp/anon-ns.exp	10 Jul 2012 15:12:03 -0000
@@ -19,9 +19,7 @@
 
 if {[skip_cplus_tests]} { continue }
 
-# Tests for c++/12750/12704
-set testfile "anon-ns"
-set srcfile $testfile.cc
+standard_testfile .cc
 
 if {[prepare_for_testing $testfile $testfile $srcfile {c++ debug}]} {
     return -1
Index: gdb.cp/anon-struct.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/anon-struct.exp,v
retrieving revision 1.3
diff -u -r1.3 anon-struct.exp
--- gdb.cp/anon-struct.exp	4 Jan 2012 08:17:46 -0000	1.3
+++ gdb.cp/anon-struct.exp	10 Jul 2012 15:12:03 -0000
@@ -14,9 +14,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 anon-struct
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
      return -1
 }
Index: gdb.cp/anon-union.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/anon-union.exp,v
retrieving revision 1.14
diff -u -r1.14 anon-union.exp
--- gdb.cp/anon-union.exp	16 Jan 2012 16:21:45 -0000	1.14
+++ gdb.cp/anon-union.exp	10 Jul 2012 15:12:03 -0000
@@ -26,21 +26,11 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "anon-union"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     perror "Testcase compile failed" 0
-     continue
-}
-
-# Start with a fresh gdb
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+standard_testfile .cc
 
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
Index: gdb.cp/arg-reference.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/arg-reference.exp,v
retrieving revision 1.8
diff -u -r1.8 arg-reference.exp
--- gdb.cp/arg-reference.exp	16 Jan 2012 16:21:45 -0000	1.8
+++ gdb.cp/arg-reference.exp	10 Jul 2012 15:12:03 -0000
@@ -24,18 +24,10 @@
 if { [skip_cplus_tests] } { continue }
 
 
-set testfile "arg-reference"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-    untested ${testfile}.exp
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test "ptype foo" "type = int \\\(Obj\\\)" "No false reference"
Index: gdb.cp/bool.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/bool.exp,v
retrieving revision 1.11
diff -u -r1.11 bool.exp
--- gdb.cp/bool.exp	16 Jan 2012 16:21:45 -0000	1.11
+++ gdb.cp/bool.exp	10 Jul 2012 15:12:03 -0000
@@ -23,20 +23,12 @@
 if { [skip_cplus_tests] } { continue }
 
 
-set testfile "bool"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-    untested bool.exp
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 runto_main
 
 # Testcases for tdep/2075.
Index: gdb.cp/breakpoint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/breakpoint.exp,v
retrieving revision 1.15
diff -u -r1.15 breakpoint.exp
--- gdb.cp/breakpoint.exp	21 Jun 2012 20:46:22 -0000	1.15
+++ gdb.cp/breakpoint.exp	10 Jul 2012 15:12:03 -0000
@@ -23,23 +23,15 @@
 # test running programs
 #
 
-set testfile "breakpoint"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested breakpoint.exp
-     return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 proc test_breakpoint {name} {
     # Restart the program every time, so that a single failure doesn't
Index: gdb.cp/bs15503.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/bs15503.exp,v
retrieving revision 1.17
diff -u -r1.17 bs15503.exp
--- gdb.cp/bs15503.exp	21 Jun 2012 20:46:22 -0000	1.17
+++ gdb.cp/bs15503.exp	10 Jul 2012 15:12:03 -0000
@@ -24,24 +24,16 @@
         return 0
 }
 
-set testfile "bs15503"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
 if [get_compiler_info] {
     return -1
 }
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug c++"] != "" } {
-    untested bs15503.exp
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     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
Index: gdb.cp/call-c.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/call-c.exp,v
retrieving revision 1.13
diff -u -r1.13 call-c.exp
--- gdb.cp/call-c.exp	16 Jan 2012 16:21:45 -0000	1.13
+++ gdb.cp/call-c.exp	10 Jul 2012 15:12:03 -0000
@@ -16,24 +16,18 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile call-c
-set binfile ${objdir}/${subdir}/${testfile}
-set srcfilec ${srcdir}/${subdir}/${testfile}-1.c
-set srcfilecpp ${srcdir}/${subdir}/${testfile}.cc
-set objfilec ${objdir}/${subdir}/${testfile}-1.o
-set objfilecpp ${objdir}/${subdir}/${testfile}.o
+standard_testfile .cc call-c-1.c
+set objfilec [standard_output_file ${testfile}-1.o]
+set objfilecpp [standard_output_file ${testfile}.o]
 
-if {[gdb_compile "${srcfilec}" "${objfilec}" object {debug}] != ""
-    || [gdb_compile "${srcfilecpp}" "${objfilecpp}" object {c++ debug}] != ""
+if {[gdb_compile "$srcdir/$subdir/${srcfile2}" "${objfilec}" object {debug}] != ""
+    || [gdb_compile "$srcdir/$subdir/${srcfile}" "${objfilecpp}" object {c++ debug}] != ""
     || [gdb_compile "${objfilecpp} ${objfilec}" "${binfile}" executable {c++ debug}] != ""} {
     untested ${testfile}.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 runto_main
 
Index: gdb.cp/casts.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/casts.exp,v
retrieving revision 1.17
diff -u -r1.17 casts.exp
--- gdb.cp/casts.exp	21 Jun 2012 20:46:22 -0000	1.17
+++ gdb.cp/casts.exp	10 Jul 2012 15:12:03 -0000
@@ -27,25 +27,16 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "casts"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1;
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested casts.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    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
Index: gdb.cp/class2.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/class2.exp,v
retrieving revision 1.16
diff -u -r1.16 class2.exp
--- gdb.cp/class2.exp	21 Jun 2012 20:46:22 -0000	1.16
+++ gdb.cp/class2.exp	10 Jul 2012 15:12:03 -0000
@@ -16,9 +16,7 @@
 if { [skip_cplus_tests] } { continue }
 
 
-set testfile "class2"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
@@ -26,16 +24,10 @@
     return -1
 }
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-    untested class2.exp
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # Start with "set print object off".
 
 gdb_test_no_output "set print object off"
Index: gdb.cp/classes.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/classes.exp,v
retrieving revision 1.33
diff -u -r1.33 classes.exp
--- gdb.cp/classes.exp	18 May 2012 15:31:41 -0000	1.33
+++ gdb.cp/classes.exp	10 Jul 2012 15:12:03 -0000
@@ -22,13 +22,10 @@
 
 load_lib "cp-support.exp"
 
-set testfile "classes"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested classes.exp
-     return -1
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
 # Test ptype of class objects.
@@ -541,21 +538,10 @@
 }
 
 proc do_tests {} {
-    global subdir
-    global objdir
-    global srcdir
-    global binfile
     global gdb_prompt
     global nl
 
 
-    # Start with a fresh gdb.
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load $binfile
-
     gdb_test_no_output "set language c++" ""
     gdb_test_no_output "set width 0" ""
 
Index: gdb.cp/cmpd-minsyms.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/cmpd-minsyms.exp,v
retrieving revision 1.3
diff -u -r1.3 cmpd-minsyms.exp
--- gdb.cp/cmpd-minsyms.exp	4 Jan 2012 08:17:46 -0000	1.3
+++ gdb.cp/cmpd-minsyms.exp	10 Jul 2012 15:12:03 -0000
@@ -20,9 +20,10 @@
 if {[skip_cplus_tests]} { continue }
 
 # Tests for c++/12273, breakpoint/12803
-set testfile "cmpd-minsyms"
+standard_testfile .cc
+
 # Do NOT compile with debug flag.
-if {[prepare_for_testing $testfile $testfile $testfile.cc {c++}]} {
+if {[prepare_for_testing $testfile $testfile $srcfile {c++}]} {
     return -1
 }
 
Index: gdb.cp/converts.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/converts.exp,v
retrieving revision 1.5
diff -u -r1.5 converts.exp
--- gdb.cp/converts.exp	4 Jan 2012 08:17:46 -0000	1.5
+++ gdb.cp/converts.exp	10 Jul 2012 15:12:03 -0000
@@ -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 converts
-set srcfile ${testfile}.cc
+standard_testfile .cc
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
      return -1
 }
Index: gdb.cp/cp-relocate.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/cp-relocate.exp,v
retrieving revision 1.11
diff -u -r1.11 cp-relocate.exp
--- gdb.cp/cp-relocate.exp	18 May 2012 15:28:24 -0000	1.11
+++ gdb.cp/cp-relocate.exp	10 Jul 2012 15:12:03 -0000
@@ -15,9 +15,8 @@
 
 # Test loading symbols from unrelocated C++ object files.
 
-set testfile cp-relocate
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}.o
+standard_testfile .cc
+append binfile .o
 
 if { [skip_cplus_tests] } { continue }
 
Index: gdb.cp/cpcompletion.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/cpcompletion.exp,v
retrieving revision 1.10
diff -u -r1.10 cpcompletion.exp
--- gdb.cp/cpcompletion.exp	16 Jan 2012 16:21:45 -0000	1.10
+++ gdb.cp/cpcompletion.exp	10 Jul 2012 15:12:03 -0000
@@ -51,25 +51,12 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile pr9594
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile pr9594.cc
 
-if {[gdb_compile "${srcdir}/${subdir}/${testfile}.cc" "${testfile}.o" object {c++ debug}] != ""} {
-    untested cpcompletion.exp
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-if {[gdb_compile "${testfile}.o" ${binfile} executable {c++ debug}] != "" } {
-     untested cpcompletion.exp
-     return -1
-}
-
-gdb_exit
-
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # Test that completion is restricted by class name (all methods)
 test_class_complete Foo "" "complete class methods" \
     [list Foo Foofoo get_foo set_foo ~Foo]
@@ -79,9 +66,9 @@
 
 # The tests below depend on the current code scope.
 
-set bp_location [gdb_get_line_number "Set breakpoint here" ${testfile}.cc]
+set bp_location [gdb_get_line_number "Set breakpoint here" ${srcfile}]
 
-if {![runto "${testfile}.cc:$bp_location"]} {
+if {![runto "${srcfile}:$bp_location"]} {
     perror "test suppressed"
     return
 }
Index: gdb.cp/cpexprs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/cpexprs.exp,v
retrieving revision 1.10
diff -u -r1.10 cpexprs.exp
--- gdb.cp/cpexprs.exp	21 Jun 2012 20:46:22 -0000	1.10
+++ gdb.cp/cpexprs.exp	10 Jul 2012 15:12:03 -0000
@@ -674,24 +674,15 @@
 # test running programs
 #
 
-set testfile "cpexprs"
-set srcfile "${testfile}.cc"
-set binfile [file join $objdir $subdir $testfile]
-
-if  {[gdb_compile [file join $srcdir $subdir $srcfile] $binfile \
-	  executable {debug c++}] != "" } {
-    untested "$testfile.exp"
-    return -1
-}
+standard_testfile .cc
 
 if {[get_compiler_info "c++"]} {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir [file join $srcdir $subdir]
-gdb_load $binfile
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if {![runto_main]} {
     perror "couldn't run to breakpoint"
Index: gdb.cp/cplabel.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/cplabel.exp,v
retrieving revision 1.1
diff -u -r1.1 cplabel.exp
--- gdb.cp/cplabel.exp	5 Apr 2012 18:50:28 -0000	1.1
+++ gdb.cp/cplabel.exp	10 Jul 2012 15:12:03 -0000
@@ -17,8 +17,8 @@
 
 if {[skip_cplus_tests]} { continue }
 
-set testfile cplabel
-set srcfile "$testfile.cc"
+standard_testfile .cc
+
 if {[prepare_for_testing "$testfile.exp" $testfile $srcfile {c++ debug}]} {
     return -1
 }
Index: gdb.cp/cplusfuncs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/cplusfuncs.exp,v
retrieving revision 1.20
diff -u -r1.20 cplusfuncs.exp
--- gdb.cp/cplusfuncs.exp	21 Jun 2012 20:46:22 -0000	1.20
+++ gdb.cp/cplusfuncs.exp	10 Jul 2012 15:12:03 -0000
@@ -19,17 +19,14 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "cplusfuncs"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
 if { [get_compiler_info "c++"] } {
     return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested cplusfuncs.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
 #
@@ -584,20 +581,10 @@
 }
 
 proc do_tests {} {
-    global subdir
-    global objdir
-    global srcdir
     global binfile
-    global gdb_prompt
     global dm_type_int_star
 
-
-    # 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 width 0"
 
Index: gdb.cp/ctti.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/ctti.exp,v
retrieving revision 1.18
diff -u -r1.18 ctti.exp
--- gdb.cp/ctti.exp	21 Jun 2012 20:46:22 -0000	1.18
+++ gdb.cp/ctti.exp	10 Jul 2012 15:12:03 -0000
@@ -24,50 +24,16 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "cttiadd"
-set srcfile  "${testfile}.cc"
-set srcfile1 "${testfile}1.cc"
-set srcfile2 "${testfile}2.cc"
-set srcfile3 "${testfile}3.cc"
-set objfile  "${testfile}.o"
-set objfile1 "${testfile}1.o"
-set objfile2 "${testfile}2.o"
-set objfile3 "${testfile}3.o"
-set binfile  "${objdir}/${subdir}/${testfile}"
-
-if { [gdb_compile "$srcdir/$subdir/$srcfile" "$objdir/$subdir/$objfile" object {debug c++}] != "" } {
-     untested ctti.exp
-     return -1
-}
-
-if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
-     untested ctti.exp
-     return -1
-}
-
-if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } {
-     untested ctti.exp
-     return -1
-}
-
-if { [gdb_compile "$srcdir/$subdir/$srcfile3" "$objdir/$subdir/$objfile3" object {debug c++}] != "" } {
-     untested ctti.exp
-     return -1
-}
-
-if { [gdb_compile "$objdir/$subdir/$objfile $objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2 $objdir/$subdir/$objfile3" "${binfile}" executable {debug c++}] != "" } {
-     untested ctti.exp
-     return -1
-}
+standard_testfile cttiadd.cc cttiadd1.cc cttiadd2.cc cttiadd3.cc
 
 if [get_compiler_info "c++"] {
     return -1;
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile \
+	 [list $srcfile $srcfile2 $srcfile3 $srcfile4] {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
Index: gdb.cp/derivation.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/derivation.exp,v
retrieving revision 1.18
diff -u -r1.18 derivation.exp
--- gdb.cp/derivation.exp	16 Jan 2012 16:21:45 -0000	1.18
+++ gdb.cp/derivation.exp	10 Jul 2012 15:12:03 -0000
@@ -32,19 +32,11 @@
 
 load_lib "cp-support.exp"
 
-set testfile "derivation"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested derivation.exp
-     return -1
-}
+standard_testfile .cc
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 # Set it up at a breakpoint so we can play with the variable values.
 
Index: gdb.cp/destrprint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/destrprint.exp,v
retrieving revision 1.2
diff -u -r1.2 destrprint.exp
--- gdb.cp/destrprint.exp	4 Jan 2012 08:17:47 -0000	1.2
+++ gdb.cp/destrprint.exp	10 Jul 2012 15:12:03 -0000
@@ -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 destrprint
-set srcfile ${testfile}.cc
-if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] {
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     return -1
 }
 
Index: gdb.cp/dispcxx.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/dispcxx.exp,v
retrieving revision 1.2
diff -u -r1.2 dispcxx.exp
--- gdb.cp/dispcxx.exp	21 Jun 2012 20:46:22 -0000	1.2
+++ gdb.cp/dispcxx.exp	10 Jul 2012 15:12:03 -0000
@@ -15,9 +15,7 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile dispcxx
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     untested dispcxx.exp
Index: gdb.cp/exception.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/exception.exp,v
retrieving revision 1.23
diff -u -r1.23 exception.exp
--- gdb.cp/exception.exp	16 Jan 2012 16:21:45 -0000	1.23
+++ gdb.cp/exception.exp	10 Jul 2012 15:12:03 -0000
@@ -41,23 +41,12 @@
         return 0
 }
 
-set testfile "exception"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
  
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested exception.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
-# Start with a fresh gdb
-
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 # Set a catch catchpoint
 
 gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)" \
Index: gdb.cp/expand-psymtabs-cxx.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/expand-psymtabs-cxx.exp,v
retrieving revision 1.3
diff -u -r1.3 expand-psymtabs-cxx.exp
--- gdb.cp/expand-psymtabs-cxx.exp	18 May 2012 15:28:24 -0000	1.3
+++ gdb.cp/expand-psymtabs-cxx.exp	10 Jul 2012 15:12:03 -0000
@@ -16,10 +16,8 @@
 #
 # This file is part of the gdb testsuite.
 
-set testfile expand-psymtabs-cxx
-set srcfile ${testfile}.cc
-set executable ${testfile}.x
-set binfile ${objdir}/${subdir}/${executable}
+standard_testfile .cc
+set executable ${testfile}
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug c++} ] != "" } {
      untested ${testfile}.exp
Index: gdb.cp/extern-c.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/extern-c.exp,v
retrieving revision 1.7
diff -u -r1.7 extern-c.exp
--- gdb.cp/extern-c.exp	4 Jan 2012 08:17:47 -0000	1.7
+++ gdb.cp/extern-c.exp	10 Jul 2012 15:12:03 -0000
@@ -17,21 +17,11 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "extern-c"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested extern-c.exp
-     return -1
-}
-
-# Start with a fresh gdb
+standard_testfile .cc
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 runto_main
 
Index: gdb.cp/formatted-ref.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/formatted-ref.exp,v
retrieving revision 1.10
diff -u -r1.10 formatted-ref.exp
--- gdb.cp/formatted-ref.exp	16 Jan 2012 16:21:45 -0000	1.10
+++ gdb.cp/formatted-ref.exp	10 Jul 2012 15:12:03 -0000
@@ -30,13 +30,10 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "formatted-ref"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested formatted-ref.exp
-     return -1
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
 proc get_address { var } {
@@ -113,11 +110,6 @@
     gdb_test $test "\\$\[0-9\]+ = true"
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 runto ${srcfile}:[gdb_get_line_number "marker here"]
 
 set s1_address  [get_address "s1"]
Index: gdb.cp/fpointer.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/fpointer.exp,v
retrieving revision 1.3
diff -u -r1.3 fpointer.exp
--- gdb.cp/fpointer.exp	4 Jan 2012 08:17:47 -0000	1.3
+++ gdb.cp/fpointer.exp	10 Jul 2012 15:12:03 -0000
@@ -16,8 +16,8 @@
 # This tests for evaluation of functions in the form of
 # complex expressions.
 
-set testfile fpointer
-set srcfile ${testfile}.cc
+standard_testfile .cc
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
      return -1
 }
Index: gdb.cp/gdb1355.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/gdb1355.exp,v
retrieving revision 1.13
diff -u -r1.13 gdb1355.exp
--- gdb.cp/gdb1355.exp	21 Jun 2012 20:46:22 -0000	1.13
+++ gdb.cp/gdb1355.exp	10 Jul 2012 15:12:03 -0000
@@ -27,23 +27,15 @@
 # test running programs
 #
 
-set testfile "gdb1355"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested gdb1355.exp
-     return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to main"
Index: gdb.cp/gdb2384.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/gdb2384.exp,v
retrieving revision 1.9
diff -u -r1.9 gdb2384.exp
--- gdb.cp/gdb2384.exp	21 Jun 2012 20:46:22 -0000	1.9
+++ gdb.cp/gdb2384.exp	10 Jul 2012 15:12:03 -0000
@@ -24,13 +24,9 @@
 if { [skip_cplus_tests] } { continue }
 if { [skip_shlib_tests] } { continue }
 
-set testfile "gdb2384"
-set srcfile ${testfile}.cc
-set binfile $objdir/$subdir/$testfile
-
-set libfile "gdb2384-base"
-set libsrcfile ${libfile}.cc
-set sofile $objdir/$subdir/${libfile}.so
+standard_testfile .cc gdb2384-base.cc
+
+set sofile [standard_output_file gdb2384-base.so]
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
@@ -38,16 +34,13 @@
     return -1
 }
 
-if { [gdb_compile_shlib $srcdir/$subdir/$libsrcfile $sofile {debug c++}] != ""
+if { [gdb_compile_shlib $srcdir/$subdir/$srcfile2 $sofile {debug c++}] != ""
      || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug "c++" shlib=${sofile}]] != ""} {
     untested gdb2384.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 gdb_load_shlibs ${sofile}
 
 
Index: gdb.cp/gdb2495.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/gdb2495.exp,v
retrieving revision 1.10
diff -u -r1.10 gdb2495.exp
--- gdb.cp/gdb2495.exp	21 Jun 2012 20:46:22 -0000	1.10
+++ gdb.cp/gdb2495.exp	10 Jul 2012 15:12:03 -0000
@@ -43,9 +43,7 @@
         return 0
 }
 
-set testfile "gdb2495"
-set srcfile ${testfile}.cc
-set binfile $objdir/$subdir/$testfile
+standard_testfile .cc
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
@@ -53,11 +51,6 @@
     return -1
 }
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested gdb2495.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] {
@@ -66,10 +59,9 @@
     continue
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to main"
Index: gdb.cp/hang.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/hang.exp,v
retrieving revision 1.13
diff -u -r1.13 hang.exp
--- gdb.cp/hang.exp	16 Jan 2012 16:21:45 -0000	1.13
+++ gdb.cp/hang.exp	10 Jul 2012 15:12:03 -0000
@@ -16,28 +16,13 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile hang
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile hang1.cc hang2.cc hang3.cc
 
-foreach file {hang1 hang2 hang3} {
-    if {[gdb_compile "${srcdir}/${subdir}/${file}.cc" "${file}.o" object {c++ debug}] != ""} {
-        untested hang.exp
-        return -1
-    }
+if {[prepare_for_testing $testfile.exp $testfile \
+	 [list $srcfile $srcfile2 $srcfile3] {debug c++}]} {
+    return -1
 }
 
-if {[gdb_compile "hang1.o hang2.o hang3.o" ${binfile} executable {c++ debug}] != "" } {
-     untested hang.exp
-     return -1
-}
-
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
-
 # As of May 1, 2002, GDB hangs trying to read the debug info for the
 # `hang2.o' compilation unit from the executable `hang', when compiled
 # by g++ 2.96 with STABS debugging info.  Here's what's going on, as
Index: gdb.cp/infcall-dlopen.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/infcall-dlopen.exp,v
retrieving revision 1.5
diff -u -r1.5 infcall-dlopen.exp
--- gdb.cp/infcall-dlopen.exp	21 Jun 2012 20:46:22 -0000	1.5
+++ gdb.cp/infcall-dlopen.exp	10 Jul 2012 15:12:03 -0000
@@ -21,17 +21,13 @@
     return -1
 }
 
-set testfile "infcall-dlopen"
-set srcmainfile ${testfile}.cc
-set srclibfile ${testfile}-lib.cc
-set executable ${testfile}
-set libfile ${objdir}/${subdir}/${executable}.so
-set binfile ${objdir}/${subdir}/${executable}
-set lib_dlopen [shlib_target_file ${executable}.so]
+standard_testfile .cc infcall-dlopen-lib.cc
+set libfile [standard_output_file ${testfile}.so]
+set lib_dlopen [shlib_target_file ${testfile}.so]
 
 # Use completely arbitrary file for $libfile source.
-if { [gdb_compile_shlib ${srcdir}/${subdir}/${srclibfile} ${libfile} {debug c++}] != ""
-     || [prepare_for_testing ${testfile}.exp ${executable} ${srcmainfile} {debug c++ shlib_load}] } {
+if { [gdb_compile_shlib ${srcdir}/${subdir}/${srcfile2} ${libfile} {debug c++}] != ""
+     || [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++ shlib_load}] } {
     return -1
 }
 
Index: gdb.cp/inherit.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/inherit.exp,v
retrieving revision 1.25
diff -u -r1.25 inherit.exp
--- gdb.cp/inherit.exp	21 May 2012 19:47:54 -0000	1.25
+++ gdb.cp/inherit.exp	10 Jul 2012 15:12:03 -0000
@@ -25,13 +25,10 @@
 
 load_lib "cp-support.exp"
 
-set testfile "inherit"
-set srcfile misc.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested inherit.exp
-     return -1
+standard_testfile misc.cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
 # Single inheritance, print type definitions.
@@ -658,19 +655,6 @@
 }
 
 proc do_tests { } {
-    global subdir
-    global objdir
-    global srcdir
-    global binfile
-
-
-    # Start with a fresh gdb.
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load $binfile
-
     gdb_test_no_output "set width 0"
 
     if { ![runto_main] } then {
Index: gdb.cp/koenig.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/koenig.exp,v
retrieving revision 1.8
diff -u -r1.8 koenig.exp
--- gdb.cp/koenig.exp	4 Jan 2012 08:17:47 -0000	1.8
+++ gdb.cp/koenig.exp	10 Jul 2012 15:12:03 -0000
@@ -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 koenig
-set srcfile ${testfile}.cc
+standard_testfile .cc
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
      return -1
 }
Index: gdb.cp/local.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/local.exp,v
retrieving revision 1.18
diff -u -r1.18 local.exp
--- gdb.cp/local.exp	21 Jun 2012 20:46:22 -0000	1.18
+++ gdb.cp/local.exp	10 Jul 2012 15:12:03 -0000
@@ -29,24 +29,15 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "local"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested local.exp
-     return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
   return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 #
 # set it up at a breakpoint so we can play with the variable values
Index: gdb.cp/m-data.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/m-data.exp,v
retrieving revision 1.12
diff -u -r1.12 m-data.exp
--- gdb.cp/m-data.exp	21 Jun 2012 20:46:22 -0000	1.12
+++ gdb.cp/m-data.exp	10 Jul 2012 15:12:03 -0000
@@ -24,24 +24,15 @@
 # test running programs
 #
 
-set testfile "m-data"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested m-data.exp
-     return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
Index: gdb.cp/m-static.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/m-static.exp,v
retrieving revision 1.18
diff -u -r1.18 m-static.exp
--- gdb.cp/m-static.exp	21 Jun 2012 20:46:22 -0000	1.18
+++ gdb.cp/m-static.exp	10 Jul 2012 15:12:03 -0000
@@ -25,36 +25,16 @@
 # test running programs
 #
 
-set testfile "m-static"
-set srcfile  "${testfile}.cc"
-set srcfile1 "${testfile}1.cc"
-set objfile  "${testfile}.o"
-set objfile1 "${testfile}1.o"
-set binfile  "${objdir}/${subdir}/${testfile}"
-
-if  { [gdb_compile "$srcdir/$subdir/$srcfile" "$objdir/$subdir/$objfile" object {debug c++}] != "" } {
-     untested m-static.exp
-     return -1
-}
-
-if  { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
-     untested m-static.exp
-     return -1
-}
-
-if { [gdb_compile "$objdir/$subdir/$objfile $objdir/$subdir/$objfile1" "${binfile}" executable {debug c++}] != "" } {
-     untested m-static.exp
-     return -1
-}
+standard_testfile .cc m-static1.cc
 
 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 c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
Index: gdb.cp/mb-ctor.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/mb-ctor.exp,v
retrieving revision 1.13
diff -u -r1.13 mb-ctor.exp
--- gdb.cp/mb-ctor.exp	21 Jun 2012 20:46:22 -0000	1.13
+++ gdb.cp/mb-ctor.exp	10 Jul 2012 15:12:03 -0000
@@ -19,24 +19,16 @@
 if { [skip_cplus_tests] } { continue }
 
 
-set testfile "mb-ctor"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested mb-ctor.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    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
Index: gdb.cp/mb-inline.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/mb-inline.exp,v
retrieving revision 1.13
diff -u -r1.13 mb-inline.exp
--- gdb.cp/mb-inline.exp	21 Jun 2012 20:46:22 -0000	1.13
+++ gdb.cp/mb-inline.exp	10 Jul 2012 15:12:03 -0000
@@ -20,38 +20,17 @@
 
 if { [skip_cplus_tests] } { continue }
 
-
-set testfile "mb-inline"
+standard_testfile mb-inline1.cc mb-inline2.cc
 set hdrfile "${testfile}.h"
-set srcfile1 "${testfile}1.cc"
-set objfile1 "${testfile}1.o"
-set srcfile2 "${testfile}2.cc"
-set objfile2 "${testfile}2.o"
-set binfile  "${objdir}/${subdir}/${testfile}"
-
-if  { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
-     untested mb-inline.exp
-     return -1
-}
-
-if  { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } {
-     untested mb-inline.exp
-     return -1
-}
-
-if  { [gdb_compile "$objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2" "${binfile}" executable {debug c++}] != "" } {
-     untested mb-inline.exp
-     return -1
-}
 
 if [get_compiler_info "c++"] {
     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 c++}]} {
+    return -1
+}
 
 set bp_location [gdb_get_line_number "set breakpoint here" $hdrfile]
 
Index: gdb.cp/mb-templates.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/mb-templates.exp,v
retrieving revision 1.19
diff -u -r1.19 mb-templates.exp
--- gdb.cp/mb-templates.exp	21 Jun 2012 20:46:22 -0000	1.19
+++ gdb.cp/mb-templates.exp	10 Jul 2012 15:12:03 -0000
@@ -24,22 +24,16 @@
 }
 
 
-set testfile "mb-templates"
-set srcfile ${testfile}.cc
-set executable ${testfile}
-set binfile ${objdir}/${subdir}/${executable}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested mb-templates.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
-clean_restart ${executable}
-
 set bp_location [gdb_get_line_number "set breakpoint here"]
 
 # Set a breakpoint with multiple locations
Index: gdb.cp/member-ptr.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/member-ptr.exp,v
retrieving revision 1.19
diff -u -r1.19 member-ptr.exp
--- gdb.cp/member-ptr.exp	21 Jun 2012 20:46:22 -0000	1.19
+++ gdb.cp/member-ptr.exp	10 Jul 2012 15:12:03 -0000
@@ -25,24 +25,16 @@
 if { [skip_cplus_tests] } { continue }
 
 
-set testfile "member-ptr"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested member-ptr.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    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
Index: gdb.cp/meth-typedefs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/meth-typedefs.exp,v
retrieving revision 1.2
diff -u -r1.2 meth-typedefs.exp
--- gdb.cp/meth-typedefs.exp	4 Jan 2012 08:17:47 -0000	1.2
+++ gdb.cp/meth-typedefs.exp	10 Jul 2012 15:12:03 -0000
@@ -33,8 +33,7 @@
 if {[skip_cplus_tests]} { continue }
 
 # Tests for c++/12266 et al
-set testfile "meth-typedefs"
-set srcfile $testfile.cc
+standard_testfile .cc
 
 if {[prepare_for_testing $testfile $testfile $srcfile {c++ debug}]} {
     return -1
Index: gdb.cp/method.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/method.exp,v
retrieving revision 1.17
diff -u -r1.17 method.exp
--- gdb.cp/method.exp	21 Jun 2012 20:46:22 -0000	1.17
+++ gdb.cp/method.exp	10 Jul 2012 15:12:03 -0000
@@ -35,24 +35,15 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "method"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested method.exp
-     return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
   return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 #
 # set it up at a breakpoint so we can play with the variable values
Index: gdb.cp/method2.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/method2.exp,v
retrieving revision 1.12
diff -u -r1.12 method2.exp
--- gdb.cp/method2.exp	1 Mar 2012 20:34:13 -0000	1.12
+++ gdb.cp/method2.exp	10 Jul 2012 15:12:03 -0000
@@ -20,9 +20,7 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "method2"
-set srcfile $testfile.cc
-set binfile $objdir/$subdir/$testfile
+standard_testfile .cc
 
 if  {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
      untested method2.exp
Index: gdb.cp/minsym-fallback.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/minsym-fallback.exp,v
retrieving revision 1.4
diff -u -r1.4 minsym-fallback.exp
--- gdb.cp/minsym-fallback.exp	4 Jan 2012 08:17:47 -0000	1.4
+++ gdb.cp/minsym-fallback.exp	10 Jul 2012 15:12:03 -0000
@@ -17,15 +17,13 @@
 # only a declaration there for the method.  The method is then defined in
 # a different file providing only ELF symbols.
 
-set testfile minsym-fallback
-set srcfile ${testfile}.cc
-set srcmainfile ${testfile}-main.cc
+standard_testfile .cc minsym-fallback-main.cc
 set executable $testfile
-set objfile $objdir/$subdir/${testfile}.o
-set objmainfile $objdir/$subdir/${testfile}-main.o
-set binfile $objdir/$subdir/$executable
+set objfile [standard_output_file ${testfile}.o]
+set objmainfile [standard_output_file ${testfile}-main.o]
+
 if {[gdb_compile $srcdir/$subdir/$srcfile $objfile object {}] != ""
-    || [gdb_compile $srcdir/$subdir/$srcmainfile $objmainfile object {debug}] != ""
+    || [gdb_compile $srcdir/$subdir/$srcfile2 $objmainfile object {debug}] != ""
     || [gdb_compile "$objfile $objmainfile" $binfile executable {c++}] != ""} {
     untested ${testfile}.exp
     return -1
Index: gdb.cp/misc.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/misc.exp,v
retrieving revision 1.14
diff -u -r1.14 misc.exp
--- gdb.cp/misc.exp	16 Jan 2012 16:21:45 -0000	1.14
+++ gdb.cp/misc.exp	10 Jul 2012 15:12:03 -0000
@@ -18,12 +18,10 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "misc"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested misc.exp
-     return -1
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
 #
@@ -66,20 +64,6 @@
 }
 
 proc do_tests {} {
-    global subdir
-    global objdir
-    global srcdir
-    global binfile
-    global gdb_prompt
-
-
-    # Start with a fresh gdb.
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load $binfile
-
     deduce_language_of_main
     # Check for fixes for PRs 8916 and 8630
     gdb_test "print s.a" ".* = 0" "print s.a for foo struct (known gcc 2.7.2 and earlier bug)"
Index: gdb.cp/namespace-enum.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/namespace-enum.exp,v
retrieving revision 1.3
diff -u -r1.3 namespace-enum.exp
--- gdb.cp/namespace-enum.exp	4 Jan 2012 08:17:47 -0000	1.3
+++ gdb.cp/namespace-enum.exp	10 Jul 2012 15:12:03 -0000
@@ -13,30 +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 namespace-enum
-set srcfile0 ${testfile}.cc
-set objfile0 ${testfile}.o
-set srcfile1 ${testfile}-main.cc
-set objfile1 ${testfile}-main.o
-set executable ${testfile}
-set binfile ${objdir}/${subdir}/${executable}
+standard_testfile .cc namespace-enum-main.cc
 
-if  { [gdb_compile "$srcdir/$subdir/$srcfile0" "$objdir/$subdir/$objfile0" object {debug c++}] != "" } {
-     untested namespace-enum.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile \
+	 [list $srcfile $srcfile2] {debug c++}]} {
+    return -1
 }
 
-if  { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
-     untested namespace-enum.exp
-     return -1
-}
-
-if  { [gdb_compile "$objdir/$subdir/$objfile0 $objdir/$subdir/$objfile1" "${binfile}" executable {debug c++}] != "" } {
-     untested namespace-enum.exp
-     return -1
-}
-
-clean_restart ${executable}
 gdb_test "print foo::B::B_B" "`foo::B' is not defined as an aggregate type."
 gdb_test "print foo::B_B" "foo::B_B"
 gdb_test "print A_A" "A_A"
Index: gdb.cp/namespace-nested-import.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/namespace-nested-import.exp,v
retrieving revision 1.6
diff -u -r1.6 namespace-nested-import.exp
--- gdb.cp/namespace-nested-import.exp	16 Jan 2012 16:21:45 -0000	1.6
+++ gdb.cp/namespace-nested-import.exp	10 Jul 2012 15:12:03 -0000
@@ -14,21 +14,12 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile namespace-nested-import
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-    untested "Couldn't compile test program"
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 ############################################
 # Test printing of a variable from a nested
 # in a namespace inner to the one which has
Index: gdb.cp/namespace.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/namespace.exp,v
retrieving revision 1.31
diff -u -r1.31 namespace.exp
--- gdb.cp/namespace.exp	21 Jun 2012 20:46:22 -0000	1.31
+++ gdb.cp/namespace.exp	10 Jul 2012 15:12:03 -0000
@@ -28,12 +28,7 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "namespace"
-set srcfile ${testfile}.cc
-set objfile ${objdir}/${subdir}/${testfile}.o
-set srcfile1 ${testfile}1.cc
-set objfile1 ${objdir}/${subdir}/${testfile}1.o
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc namespace1.cc
 
 if [get_compiler_info c++] {
     return -1;
@@ -46,26 +41,11 @@
     set xfail_class_types 1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug c++}] != "" } {
-     untested namespace.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile \
+	 [list $srcfile $srcfile2] {debug c++}]} {
+    return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${objfile1}" object {debug c++}] != "" } {
-     untested namespace.exp
-     return -1
-}
-
-if  { [gdb_compile "${objfile} ${objfile1}" "${binfile}" executable {debug c++}] != "" } {
-     untested namespace.exp
-     return -1
-}
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test "show lang" "auto; currently c\\+\\+.*"
 
 #
@@ -142,7 +122,7 @@
 # Break on a function in the global namespace.
 
 gdb_test "break ::ensureOtherRefs" \
-    "Breakpoint.*at $hex: file.*$srcfile1, line $decimal\\."
+    "Breakpoint.*at $hex: file.*$srcfile2, line $decimal\\."
 
 # Call a function in a nested namespace
 
Index: gdb.cp/nextoverthrow.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/nextoverthrow.exp,v
retrieving revision 1.8
diff -u -r1.8 nextoverthrow.exp
--- gdb.cp/nextoverthrow.exp	21 Jun 2012 20:46:22 -0000	1.8
+++ gdb.cp/nextoverthrow.exp	10 Jul 2012 15:12:03 -0000
@@ -16,9 +16,7 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "nextoverthrow"
-set srcfile ${testfile}.cc
-set binfile $objdir/$subdir/$testfile
+standard_testfile .cc
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
Index: gdb.cp/no-dmgl-verbose.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/no-dmgl-verbose.exp,v
retrieving revision 1.2
diff -u -r1.2 no-dmgl-verbose.exp
--- gdb.cp/no-dmgl-verbose.exp	4 Jan 2012 08:17:47 -0000	1.2
+++ gdb.cp/no-dmgl-verbose.exp	10 Jul 2012 15:12:03 -0000
@@ -15,19 +15,16 @@
 
 # Test loading symbols from unrelocated C++ object files.
 
-set testfile no-dmgl-verbose
-set srcfile ${testfile}.cc
-set executable ${testfile}.o
-set binfile ${objdir}/${subdir}/${executable}
+standard_testfile .cc
 
 if { [skip_cplus_tests] } { continue }
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {c++ debug}] != "" } {
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {c++ debug}] != "" } {
      untested ${testfile}.exp
      return -1
 }
 
-clean_restart ${executable}
+clean_restart ${testfile}.o
 
 gdb_test_no_output "set breakpoint pending off"
 
Index: gdb.cp/nsdecl.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/nsdecl.exp,v
retrieving revision 1.6
diff -u -r1.6 nsdecl.exp
--- gdb.cp/nsdecl.exp	21 Jun 2012 20:46:22 -0000	1.6
+++ gdb.cp/nsdecl.exp	10 Jul 2012 15:12:03 -0000
@@ -16,24 +16,15 @@
 # Stress test the lookup of declarations
 
 
-set testfile nsdecl
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-    untested "Couldn't compile test program"
-    return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info] {
     return -1;
 }
 
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint main"
Index: gdb.cp/nsimport.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/nsimport.exp,v
retrieving revision 1.5
diff -u -r1.5 nsimport.exp
--- gdb.cp/nsimport.exp	16 Jan 2012 16:21:45 -0000	1.5
+++ gdb.cp/nsimport.exp	10 Jul 2012 15:12:03 -0000
@@ -17,21 +17,12 @@
 # imported into the same scope.
 
 
-set testfile nsimport
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-    untested "Couldn't compile test program"
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 ############################################
 # test printing of namespace imported within
 # the function.
Index: gdb.cp/nsnested.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/nsnested.exp,v
retrieving revision 1.2
diff -u -r1.2 nsnested.exp
--- gdb.cp/nsnested.exp	4 Jan 2012 08:17:47 -0000	1.2
+++ gdb.cp/nsnested.exp	10 Jul 2012 15:12:03 -0000
@@ -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 nsnested
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
      return -1
 }
Index: gdb.cp/nsnoimports.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/nsnoimports.exp,v
retrieving revision 1.2
diff -u -r1.2 nsnoimports.exp
--- gdb.cp/nsnoimports.exp	4 Jan 2012 08:17:47 -0000	1.2
+++ gdb.cp/nsnoimports.exp	10 Jul 2012 15:12:03 -0000
@@ -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 nsnoimports
-set srcfile ${testfile}.cc
+standard_testfile .cc
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
      return -1
 }
Index: gdb.cp/nsrecurs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/nsrecurs.exp,v
retrieving revision 1.7
diff -u -r1.7 nsrecurs.exp
--- gdb.cp/nsrecurs.exp	21 Jun 2012 20:46:22 -0000	1.7
+++ gdb.cp/nsrecurs.exp	10 Jul 2012 15:12:03 -0000
@@ -14,26 +14,15 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile nsrecurs
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" \
-      "${binfile}" executable {debug c++}] != "" } {
-    untested "Couldn't compile test program"
-    return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info] {
     return -1
 }
 
-
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint main"
Index: gdb.cp/nsstress.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/nsstress.exp,v
retrieving revision 1.6
diff -u -r1.6 nsstress.exp
--- gdb.cp/nsstress.exp	21 Jun 2012 20:46:22 -0000	1.6
+++ gdb.cp/nsstress.exp	10 Jul 2012 15:12:03 -0000
@@ -16,24 +16,15 @@
 # Stress test namespace lookup
 
 
-set testfile nsstress
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-    untested "Couldn't compile test program"
-    return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info] {
     return -1
 }
 
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint main"
Index: gdb.cp/nsusing.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/nsusing.exp,v
retrieving revision 1.10
diff -u -r1.10 nsusing.exp
--- gdb.cp/nsusing.exp	21 Jun 2012 20:46:22 -0000	1.10
+++ gdb.cp/nsusing.exp	10 Jul 2012 15:12:03 -0000
@@ -14,26 +14,15 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-set testfile nsusing
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
-      {debug c++}] != "" } {
-    untested "Couldn't compile test program"
-    return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info] {
     return -1
 }
 
-
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 ############################################
 # test printing of namespace imported within
Index: gdb.cp/operator.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/operator.exp,v
retrieving revision 1.4
diff -u -r1.4 operator.exp
--- gdb.cp/operator.exp	4 Jan 2012 08:17:47 -0000	1.4
+++ gdb.cp/operator.exp	10 Jul 2012 15:12:03 -0000
@@ -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 operator
-set srcfile ${testfile}.cc
+standard_testfile .cc
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
     return -1
 }
Index: gdb.cp/oranking.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/oranking.exp,v
retrieving revision 1.6
diff -u -r1.6 oranking.exp
--- gdb.cp/oranking.exp	4 Jan 2012 08:17:47 -0000	1.6
+++ gdb.cp/oranking.exp	10 Jul 2012 15:12:03 -0000
@@ -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 oranking
-set srcfile ${testfile}.cc
+standard_testfile .cc
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
      return -1
 }
Index: gdb.cp/overload-const.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/overload-const.exp,v
retrieving revision 1.2
diff -u -r1.2 overload-const.exp
--- gdb.cp/overload-const.exp	4 Jan 2012 08:17:47 -0000	1.2
+++ gdb.cp/overload-const.exp	10 Jul 2012 15:12:03 -0000
@@ -17,8 +17,9 @@
 
 if {[skip_cplus_tests]} { continue }
 
-set testfile "overload-const"
-if [prepare_for_testing $testfile $testfile $testfile.cc {c++ debug}] {
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile $testfile $testfile.cc {c++ debug}]} {
     return -1
 }
 
Index: gdb.cp/overload.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/overload.exp,v
retrieving revision 1.27
diff -u -r1.27 overload.exp
--- gdb.cp/overload.exp	16 Jan 2012 16:21:45 -0000	1.27
+++ gdb.cp/overload.exp	10 Jul 2012 15:12:04 -0000
@@ -26,19 +26,11 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "overload"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested overload.exp
-     return -1
-}
+standard_testfile .cc
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 # Set it up at a breakpoint so we can play with the variable values.
 
Index: gdb.cp/ovldbreak.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/ovldbreak.exp,v
retrieving revision 1.23
diff -u -r1.23 ovldbreak.exp
--- gdb.cp/ovldbreak.exp	5 Apr 2012 18:50:28 -0000	1.23
+++ gdb.cp/ovldbreak.exp	10 Jul 2012 15:12:04 -0000
@@ -31,12 +31,9 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "ovldbreak"
-set srcfile $testfile.cc
-set binfile $objdir/$subdir/$testfile
+standard_testfile .cc
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
-    untested ovldbreak.exp
     return -1
 }
 
Index: gdb.cp/ovsrch.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/ovsrch.exp,v
retrieving revision 1.4
diff -u -r1.4 ovsrch.exp
--- gdb.cp/ovsrch.exp	4 Jan 2012 08:17:47 -0000	1.4
+++ gdb.cp/ovsrch.exp	10 Jul 2012 15:12:04 -0000
@@ -55,15 +55,10 @@
 if { [skip_cplus_tests] } { continue }
 
 # Test for c++/11734
-set testfile "ovsrch"
-set binfile [file join $objdir $subdir $testfile]
+standard_testfile ovsrch1.cc ovsrch2.cc ovsrch3.cc ovsrch4.cc
 
-set srcfiles {}
-for {set i 1} {$i < 5} {incr i} {
-    lappend srcfiles $testfile$i.cc
-}
-
-if {[prepare_for_testing $testfile $testfile $srcfiles {c++ debug}]} {
+if {[prepare_for_testing $testfile $testfile \
+	 [list $srcfile $srcfile2 $srcfile3 $srcfile4] {c++ debug}]} {
     return -1
 }
 
Index: gdb.cp/paren-type.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/paren-type.exp,v
retrieving revision 1.2
diff -u -r1.2 paren-type.exp
--- gdb.cp/paren-type.exp	4 Jan 2012 08:17:47 -0000	1.2
+++ gdb.cp/paren-type.exp	10 Jul 2012 15:12:04 -0000
@@ -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 paren-type
+standard_testfile .cc
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.cc {c++ debug}] } {
     return -1
 }
Index: gdb.cp/pass-by-ref.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/pass-by-ref.exp,v
retrieving revision 1.6
diff -u -r1.6 pass-by-ref.exp
--- gdb.cp/pass-by-ref.exp	4 Jan 2012 08:17:47 -0000	1.6
+++ gdb.cp/pass-by-ref.exp	10 Jul 2012 15:12:04 -0000
@@ -18,20 +18,12 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "pass-by-ref"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
-	  executable {debug c++}] != "" } {
-    untested pass-by-ref.exp
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 if ![runto_main] then {
     return -1
 }
Index: gdb.cp/pr-1023.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/pr-1023.exp,v
retrieving revision 1.13
diff -u -r1.13 pr-1023.exp
--- gdb.cp/pr-1023.exp	21 Jun 2012 20:46:22 -0000	1.13
+++ gdb.cp/pr-1023.exp	10 Jul 2012 15:12:04 -0000
@@ -24,23 +24,15 @@
 # test running programs
 #
 
-set testfile "pr-1023"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested pr-1023.exp
-     return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
Index: gdb.cp/pr-1210.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/pr-1210.exp,v
retrieving revision 1.13
diff -u -r1.13 pr-1210.exp
--- gdb.cp/pr-1210.exp	21 Jun 2012 20:46:22 -0000	1.13
+++ gdb.cp/pr-1210.exp	10 Jul 2012 15:12:04 -0000
@@ -23,24 +23,16 @@
 # test running programs
 #
 
-set testfile "pr-1210"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-    untested pr-1210.exp
+if [get_compiler_info "c++"] {
     return -1
 }
 
-if [get_compiler_info "c++"] {
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     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
Index: gdb.cp/pr-574.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/pr-574.exp,v
retrieving revision 1.12
diff -u -r1.12 pr-574.exp
--- gdb.cp/pr-574.exp	21 Jun 2012 20:46:22 -0000	1.12
+++ gdb.cp/pr-574.exp	10 Jul 2012 15:12:04 -0000
@@ -26,24 +26,15 @@
 # test running programs
 #
 
-set testfile "pr-574"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested pr-574.exp
-     return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
Index: gdb.cp/pr10687.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/pr10687.exp,v
retrieving revision 1.3
diff -u -r1.3 pr10687.exp
--- gdb.cp/pr10687.exp	4 Jan 2012 08:17:47 -0000	1.3
+++ gdb.cp/pr10687.exp	10 Jul 2012 15:12:04 -0000
@@ -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 pr10687
-set srcfile ${testfile}.cc
-if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] {
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     return -1
 }
 
Index: gdb.cp/pr10728.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/pr10728.exp,v
retrieving revision 1.3
diff -u -r1.3 pr10728.exp
--- gdb.cp/pr10728.exp	4 Jan 2012 08:17:47 -0000	1.3
+++ gdb.cp/pr10728.exp	10 Jul 2012 15:12:04 -0000
@@ -21,18 +21,16 @@
 
 load_lib "cp-support.exp"
 
-set testfile "pr10728"
-set srcfile ${testfile}-x.cc
-set tfx ${testfile}-x
-set tfy ${testfile}-y
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile pr10728-x.cc pr10728-y.cc
+set tfx [standard_output_file pr10728-x.o]
+set tfy [standard_output_file pr10728-y.o]
 
-if  { [gdb_compile "${srcdir}/${subdir}/${tfy}.cc" "${tfy}.o" object {c++}] != "" } {
+if  { [gdb_compile "${srcdir}/${subdir}/$srcfile2" "${tfy}.o" object {c++}] != "" } {
      untested pr10728.exp
      return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${tfx}.cc" "${tfx}.o" object {debug c++}] != "" } {
+if  { [gdb_compile "${srcdir}/${subdir}/$srcfile" "${tfx}.o" object {debug c++}] != "" } {
      untested pr10728.exp
      return -1
 }
@@ -42,11 +40,7 @@
      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"
Index: gdb.cp/pr12028.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/pr12028.exp,v
retrieving revision 1.3
diff -u -r1.3 pr12028.exp
--- gdb.cp/pr12028.exp	4 Jan 2012 08:17:47 -0000	1.3
+++ gdb.cp/pr12028.exp	10 Jul 2012 15:12:04 -0000
@@ -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 pr12028
-set srcfile ${testfile}.cc
+standard_testfile .cc
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
     return -1
 }
Index: gdb.cp/pr9067.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/pr9067.exp,v
retrieving revision 1.3
diff -u -r1.3 pr9067.exp
--- gdb.cp/pr9067.exp	4 Jan 2012 08:17:47 -0000	1.3
+++ gdb.cp/pr9067.exp	10 Jul 2012 15:12:04 -0000
@@ -19,19 +19,11 @@
 
 load_lib "cp-support.exp"
 
-set testfile "pr9067"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } {
-     untested pr9067.exp
-     return -1
-}
+standard_testfile .cc
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
Index: gdb.cp/pr9167.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/pr9167.exp,v
retrieving revision 1.5
diff -u -r1.5 pr9167.exp
--- gdb.cp/pr9167.exp	4 Jan 2012 08:17:47 -0000	1.5
+++ gdb.cp/pr9167.exp	10 Jul 2012 15:12:04 -0000
@@ -18,9 +18,9 @@
         return 0
 }
 
-set testfile pr9167
-set srcfile ${testfile}.cc
-if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] {
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     return -1
 }
 
Index: gdb.cp/pr9631.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/pr9631.exp,v
retrieving revision 1.6
diff -u -r1.6 pr9631.exp
--- gdb.cp/pr9631.exp	21 Jun 2012 20:46:22 -0000	1.6
+++ gdb.cp/pr9631.exp	10 Jul 2012 15:12:04 -0000
@@ -17,23 +17,15 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "pr9631"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested pr9631.exp
-     return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
Index: gdb.cp/printmethod.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/printmethod.exp,v
retrieving revision 1.15
diff -u -r1.15 printmethod.exp
--- gdb.cp/printmethod.exp	21 Jun 2012 20:46:22 -0000	1.15
+++ gdb.cp/printmethod.exp	10 Jul 2012 15:12:04 -0000
@@ -25,24 +25,15 @@
 # test running programs
 #
 
-set testfile "printmethod"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested printmethod.exp
-     return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
Index: gdb.cp/psmang.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/psmang.exp,v
retrieving revision 1.13
diff -u -r1.13 psmang.exp
--- gdb.cp/psmang.exp	21 Jun 2012 20:46:22 -0000	1.13
+++ gdb.cp/psmang.exp	10 Jul 2012 15:12:04 -0000
@@ -178,42 +178,22 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "psmang"
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile psmang1.cc psmang2.cc
 
 if [get_compiler_info "c++"] {
     return -1;
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${testfile}1.cc" "${testfile}1.o" object {debug c++}] != "" } {
-     untested psmang.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile \
+	 [list $srcfile $srcfile2] {debug c++}]} {
+    return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${testfile}2.cc" "${testfile}2.o" object {debug c++}] != "" } {
-     untested psmang.exp
-     return -1
-}
-
-if  { [gdb_compile "${testfile}1.o ${testfile}2.o" ${binfile} executable {debug c++}] != "" } {
-     untested psmang.exp
-     return -1
-}
-
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 gdb_test "break s::method1" "Breakpoint .* at .*: file .*psmang1.cc.*"
 
 # We have to exit and restart GDB here, to make sure that all the
 # compilation units are psymtabs again.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
 gdb_test "break s::method2" "Breakpoint .* at .*: file .*psmang2.cc.*"
Index: gdb.cp/psymtab-parameter.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/psymtab-parameter.exp,v
retrieving revision 1.3
diff -u -r1.3 psymtab-parameter.exp
--- gdb.cp/psymtab-parameter.exp	4 Jan 2012 08:17:47 -0000	1.3
+++ gdb.cp/psymtab-parameter.exp	10 Jul 2012 15:12:04 -0000
@@ -15,18 +15,14 @@
 
 if { [skip_cplus_tests] } { continue }
 
+standard_testfile .cc
 
-set testfile psymtab-parameter
-set executable ${testfile}.x
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${executable}
-
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug c++}] != "" } {
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.x" object {debug c++}] != "" } {
     untested ${testfile}.exp
     return -1
 }
 
-clean_restart $executable
+clean_restart $testfile.x
 
 # As `main' is not present GDB fails to find the proper inferior language.
 gdb_test_no_output "set language c++"
Index: gdb.cp/ptype-cv-cp.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/ptype-cv-cp.exp,v
retrieving revision 1.5
diff -u -r1.5 ptype-cv-cp.exp
--- gdb.cp/ptype-cv-cp.exp	4 Jan 2012 08:17:47 -0000	1.5
+++ gdb.cp/ptype-cv-cp.exp	10 Jul 2012 15:12:04 -0000
@@ -17,8 +17,7 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "ptype-cv-cp"
-set srcfile ${testfile}.cc
+standard_testfile .cc
 
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
     return -1
Index: gdb.cp/re-set-overloaded.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/re-set-overloaded.exp,v
retrieving revision 1.5
diff -u -r1.5 re-set-overloaded.exp
--- gdb.cp/re-set-overloaded.exp	21 Jun 2012 20:46:22 -0000	1.5
+++ gdb.cp/re-set-overloaded.exp	10 Jul 2012 15:12:04 -0000
@@ -16,13 +16,9 @@
 if { [skip_cplus_tests] } { continue }
 if { [skip_shlib_tests] } { continue }
 
-set testfile re-set-overloaded
-set srcfile bool.cc
-set executable $testfile
-set binfile $objdir/$subdir/$executable
+standard_testfile bool.cc .cc
 
-set libsrcfile ${testfile}.cc
-set sofile $objdir/$subdir/${testfile}.so
+set sofile [standard_output_file ${testfile}.so]
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
@@ -30,13 +26,13 @@
     return -1
 }
 
-if { [gdb_compile_shlib $srcdir/$subdir/$libsrcfile $sofile {debug c++}] != ""
+if { [gdb_compile_shlib $srcdir/$subdir/$srcfile2 $sofile {debug c++}] != ""
      || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug "c++" shlib=${sofile}]] != ""} {
     untested ${testfile}.exp
     return -1
 }
 
-clean_restart $executable
+clean_restart $testfile
 gdb_load_shlibs ${sofile}
 
 gdb_test_no_output "set breakpoint pending yes"
Index: gdb.cp/readnow-language.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/readnow-language.exp,v
retrieving revision 1.2
diff -u -r1.2 readnow-language.exp
--- gdb.cp/readnow-language.exp	4 Jan 2012 08:17:47 -0000	1.2
+++ gdb.cp/readnow-language.exp	10 Jul 2012 15:12:04 -0000
@@ -13,16 +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 readnow-language
-set srcfile ${testfile}.cc
-set executable ${testfile}
-if {[build_executable ${testfile}.exp $executable ${testfile}.cc {c++ debug}] == -1} {
+standard_testfile .cc
+
+if {[build_executable ${testfile}.exp $testfile ${testfile}.cc {c++ debug}] == -1} {
     return -1
 }
 
 set old_gdbflags $GDBFLAGS
 set GDBFLAGS "$GDBFLAGS -readnow"
-clean_restart $executable
+clean_restart $testfile
 set GDBFLAGS $old_gdbflags
 
 gdb_test "show language" {The current source language is "auto; currently c\+\+"\.}
Index: gdb.cp/ref-params.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/ref-params.exp,v
retrieving revision 1.12
diff -u -r1.12 ref-params.exp
--- gdb.cp/ref-params.exp	16 Jan 2012 16:21:45 -0000	1.12
+++ gdb.cp/ref-params.exp	10 Jul 2012 15:12:04 -0000
@@ -22,27 +22,19 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "ref-params"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested ref-params.exp
-     return -1
+standard_testfile .cc
+
+if {[build_executable $testfile.exp $testfile $srcfile {debug c++}] == 1} {
+    return -1
 }
 
 gdb_exit
 
 proc gdb_start_again { text } {
-    global srcdir
-    global subdir
     global binfile
     global srcfile
 
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load ${binfile}
+    clean_restart $binfile
 
     runto ${srcfile}:[gdb_get_line_number $text]
 }
Index: gdb.cp/ref-types.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/ref-types.exp,v
retrieving revision 1.20
diff -u -r1.20 ref-types.exp
--- gdb.cp/ref-types.exp	16 Jan 2012 16:21:45 -0000	1.20
+++ gdb.cp/ref-types.exp	10 Jul 2012 15:12:04 -0000
@@ -22,20 +22,11 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "ref-types"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested ref-types.exp
-     return -1
-}
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+standard_testfile .cc
 
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 #
 # set it up at a breakpoint so we can play with the variable values
Index: gdb.cp/rtti.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti.exp,v
retrieving revision 1.17
diff -u -r1.17 rtti.exp
--- gdb.cp/rtti.exp	21 Jun 2012 20:46:22 -0000	1.17
+++ gdb.cp/rtti.exp	10 Jul 2012 15:12:04 -0000
@@ -32,37 +32,16 @@
 # test running programs
 #
 
-set testfile "rtti"
-set srcfile1 "${testfile}1.cc"
-set objfile1 "${testfile}1.o"
-set srcfile2 "${testfile}2.cc"
-set objfile2 "${testfile}2.o"
-set binfile  "${objdir}/${subdir}/${testfile}"
-
-if  { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
-     untested rtti.exp
-     return -1
-}
-
-if  { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } {
-     untested rtti.exp
-     return -1
-}
-
-if  { [gdb_compile "$objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2" "${binfile}" executable {debug c++}] != "" } {
-     untested rtti.exp
-     return -1
-}
+standard_testfile rtti1.cc rtti2.cc
 
 if [get_compiler_info "c++"] {
     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 c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
@@ -71,7 +50,7 @@
 
 # First, run to after we've constructed the object:
 
-gdb_breakpoint [gdb_get_line_number "main-constructs-done" "$srcfile1"]
+gdb_breakpoint [gdb_get_line_number "main-constructs-done" "$srcfile"]
 gdb_continue_to_breakpoint "end of constructors in main"
 
 gdb_test_multiple "print *e1" "print *e1" {
@@ -127,12 +106,12 @@
 # Now we test the hack that's been implemented to get around some
 # instances of PR gdb/1511.
 
-gdb_breakpoint [gdb_get_line_number "func-constructs-done" "$srcfile1"]
+gdb_breakpoint [gdb_get_line_number "func-constructs-done" "$srcfile"]
 gdb_continue_to_breakpoint "end of constructors in func"
 
 gdb_test "print *obj" "\\$\[0-9\]* = {<n2::Base2> = .*}"
 
-gdb_breakpoint [gdb_get_line_number "func3-constructs-done" "$srcfile1"]
+gdb_breakpoint [gdb_get_line_number "func3-constructs-done" "$srcfile"]
 gdb_continue_to_breakpoint "end of constructors in func3"
 
 gdb_test "print *obj3" "\\$\[0-9\]* = {<n2::C2> = .*}"
Index: gdb.cp/shadow.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/shadow.exp,v
retrieving revision 1.8
diff -u -r1.8 shadow.exp
--- gdb.cp/shadow.exp	21 Jun 2012 20:46:22 -0000	1.8
+++ gdb.cp/shadow.exp	10 Jul 2012 15:12:04 -0000
@@ -17,24 +17,15 @@
 # name the one from the correct scope is printed.
 
 
-set testfile shadow
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-    untested "Couldn't compile test program"
-    return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info] {
     return -1
 }
 
-# Get things started.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint main"
Index: gdb.cp/smartp.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/smartp.exp,v
retrieving revision 1.3
diff -u -r1.3 smartp.exp
--- gdb.cp/smartp.exp	4 Jan 2012 08:17:47 -0000	1.3
+++ gdb.cp/smartp.exp	10 Jul 2012 15:12:04 -0000
@@ -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 smartp
-set srcfile ${testfile}.cc
+standard_testfile .cc
+
 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
      return -1
 }
Index: gdb.cp/static-method.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/static-method.exp,v
retrieving revision 1.5
diff -u -r1.5 static-method.exp
--- gdb.cp/static-method.exp	4 Jan 2012 08:17:47 -0000	1.5
+++ gdb.cp/static-method.exp	10 Jul 2012 15:12:04 -0000
@@ -41,8 +41,7 @@
 if {[skip_cplus_tests]} { continue }
 
 # Tests for c++/12750
-set testfile "static-method"
-set srcfile $testfile.cc
+standard_testfile .cc
 
 if {[prepare_for_testing $testfile $testfile $srcfile {c++ debug}]} {
     return -1
Index: gdb.cp/static-print-quit.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/static-print-quit.exp,v
retrieving revision 1.4
diff -u -r1.4 static-print-quit.exp
--- gdb.cp/static-print-quit.exp	4 Jan 2012 08:17:47 -0000	1.4
+++ gdb.cp/static-print-quit.exp	10 Jul 2012 15:12:04 -0000
@@ -15,17 +15,14 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile static-print-quit
-set srcfile ${testfile}.cc
-set executable $testfile.o
-set objfile ${objdir}/${subdir}/${executable}
+standard_testfile .cc
 
-if { [gdb_compile $srcdir/$subdir/$srcfile $objfile object {debug c++}] != ""} {
+if { [gdb_compile $srcdir/$subdir/$srcfile $binfile.o object {debug c++}] != ""} {
     untested ${testfile}.exp
     return -1
 }
 
-clean_restart $executable
+clean_restart $testfile.o
 
 gdb_test_no_output "set width 80"
 gdb_test_no_output "set height 2"
Index: gdb.cp/temargs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/temargs.exp,v
retrieving revision 1.10
diff -u -r1.10 temargs.exp
--- gdb.cp/temargs.exp	16 Jan 2012 16:21:45 -0000	1.10
+++ gdb.cp/temargs.exp	10 Jul 2012 15:12:04 -0000
@@ -21,8 +21,7 @@
     continue
 }
 
-set testfile "temargs"
-set srcfile "${testfile}.cc"
+standard_testfile .cc
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
     return -1
Index: gdb.cp/templates.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/templates.exp,v
retrieving revision 1.35
diff -u -r1.35 templates.exp
--- gdb.cp/templates.exp	21 Jun 2012 20:46:22 -0000	1.35
+++ gdb.cp/templates.exp	10 Jul 2012 15:12:04 -0000
@@ -20,9 +20,7 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "templates"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
@@ -30,9 +28,8 @@
     return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested templates.exp
-     return -1
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
 #
@@ -237,20 +234,6 @@
 }
 
 proc do_tests {} {
-    global subdir
-    global objdir
-    global srcdir
-    global binfile
-    global gdb_prompt
-
-
-    # Start with a fresh gdb.
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load $binfile
-
     # Change multiple-symbols to "ask" in order to get the multiple-choice
     # menu when breaking on overloaded methods.
     gdb_test_no_output "set multiple-symbols ask"
Index: gdb.cp/try_catch.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/try_catch.exp,v
retrieving revision 1.13
diff -u -r1.13 try_catch.exp
--- gdb.cp/try_catch.exp	21 Jun 2012 20:46:22 -0000	1.13
+++ gdb.cp/try_catch.exp	10 Jul 2012 15:12:04 -0000
@@ -24,24 +24,15 @@
 # test running programs
 #
 
-set testfile "try_catch"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested try_catch.exp
-     return -1
-}
+standard_testfile .cc
 
 if [get_compiler_info "c++"] {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
Index: gdb.cp/typedef-operator.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/typedef-operator.exp,v
retrieving revision 1.2
diff -u -r1.2 typedef-operator.exp
--- gdb.cp/typedef-operator.exp	4 Jan 2012 08:17:47 -0000	1.2
+++ gdb.cp/typedef-operator.exp	10 Jul 2012 15:12:04 -0000
@@ -17,8 +17,9 @@
 
 if {[skip_cplus_tests]} { continue }
 
-set testfile "typedef-operator"
-if [prepare_for_testing $testfile $testfile $testfile.cc {c++ debug}] {
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile $testfile $srcfile {c++ debug}]} {
     return -1
 }
 
Index: gdb.cp/userdef.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/userdef.exp,v
retrieving revision 1.21
diff -u -r1.21 userdef.exp
--- gdb.cp/userdef.exp	5 Apr 2012 18:50:28 -0000	1.21
+++ gdb.cp/userdef.exp	10 Jul 2012 15:12:04 -0000
@@ -26,21 +26,11 @@
         return 0
 }
 
-set testfile "userdef"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested userdef.exp
-     return -1
-}
-
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+standard_testfile .cc
 
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
Index: gdb.cp/virtbase.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/virtbase.exp,v
retrieving revision 1.10
diff -u -r1.10 virtbase.exp
--- gdb.cp/virtbase.exp	18 May 2012 15:31:41 -0000	1.10
+++ gdb.cp/virtbase.exp	10 Jul 2012 15:12:04 -0000
@@ -17,19 +17,11 @@
 
 if { [skip_cplus_tests] } { continue }
 
-set testfile "virtbase"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-     untested virtbase.exp
-     return -1
-}
+standard_testfile .cc
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if {![runto_main]} then {
     perror "couldn't run to breakpoint"
Index: gdb.cp/virtfunc.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/virtfunc.exp,v
retrieving revision 1.26
diff -u -r1.26 virtfunc.exp
--- gdb.cp/virtfunc.exp	15 Mar 2012 15:43:18 -0000	1.26
+++ gdb.cp/virtfunc.exp	10 Jul 2012 15:12:04 -0000
@@ -23,13 +23,10 @@
 
 load_lib "cp-support.exp"
 
-set testfile "virtfunc"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } {
-     untested virtfunc.exp
-     return -1
+standard_testfile .cc
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
 proc test_ptype_of_classes {} {
@@ -275,15 +272,6 @@
 }
 
 proc do_tests {} {
-    global srcdir subdir binfile
-    global gdb_prompt
-
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load $binfile
-
     gdb_test_no_output "set language c++" ""
     gdb_test_no_output "set width 0" ""
 
Index: gdb.cp/virtfunc2.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/virtfunc2.exp,v
retrieving revision 1.5
diff -u -r1.5 virtfunc2.exp
--- gdb.cp/virtfunc2.exp	15 Mar 2012 15:49:42 -0000	1.5
+++ gdb.cp/virtfunc2.exp	10 Jul 2012 15:12:04 -0000
@@ -22,19 +22,11 @@
 
 load_lib "cp-support.exp"
 
-set testfile "virtfunc2"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
-
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } {
-     untested virtfunc2.exp
-     return -1
-}
+standard_testfile .cc
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+    return -1
+}
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"



More information about the Gdb-patches mailing list