public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 08/17] simple changes in gdb.base
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (5 preceding siblings ...)
  2013-10-18 20:49 ` [PATCH v2 01/17] fix up log-file toggling Tom Tromey
@ 2013-10-18 20:49 ` Tom Tromey
  2013-10-18 20:49 ` [PATCH v2 15/17] fix some "exec" tests Tom Tromey
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 20:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This makes more changes in gdb.base to make it parallel-safe.  I think
the changes in this particular patch are relatively straightforward,
so I've grouped them all together.

	* gdb.base/advance.exp: Use standard_testfile and
	prepare_for_testing.
	* gdb.base/bigcore.exp: Use standard_output_file.  "cd" to
	appropriate directory when local.
	* gdb.base/dump.exp: Use standard_output_file.  Update all
	"dump" and "restore" filenames.
	* gdb.base/interact.exp: Use standard_output_file.
	* gdb.base/jit-so.exp: Don't download file when local.
	* gdb.base/jit.exp (compile_jit_test): Don't download file
	when local.
	* gdb.base/list.exp: Use gdb_remote_download.
	* gdb.base/maint.exp: Use standard_output_file.
	* gdb.base/prelink.exp: Use standard_output_file.
	* gdb.base/save-bp.exp: Use standard_output_file.
	* gdb.base/sepdebug.exp: Use standard_testfile,
	standard_output_file.
	(test_different_dir): Don't declare objdir.
	* gdb.base/solib-search.exp: Use standard_output_file.
	* gdb.base/step-line.exp: Use gdb_remote_download.
	* gdb.base/trace-commands.exp: Use standard_output_file.
---
 gdb/testsuite/gdb.base/advance.exp        |  14 +--
 gdb/testsuite/gdb.base/bigcore.exp        |  14 ++-
 gdb/testsuite/gdb.base/dump.exp           | 157 ++++++++++++++++++------------
 gdb/testsuite/gdb.base/interact.exp       |   9 +-
 gdb/testsuite/gdb.base/jit-so.exp         |   6 +-
 gdb/testsuite/gdb.base/jit.exp            |   6 +-
 gdb/testsuite/gdb.base/list.exp           |   2 +-
 gdb/testsuite/gdb.base/maint.exp          |   6 +-
 gdb/testsuite/gdb.base/prelink.exp        |  12 +--
 gdb/testsuite/gdb.base/save-bp.exp        |  11 ++-
 gdb/testsuite/gdb.base/sepdebug.exp       |  41 ++++----
 gdb/testsuite/gdb.base/solib-search.exp   |  35 ++++---
 gdb/testsuite/gdb.base/step-line.exp      |   2 +-
 gdb/testsuite/gdb.base/trace-commands.exp |   9 +-
 14 files changed, 185 insertions(+), 139 deletions(-)

diff --git a/gdb/testsuite/gdb.base/advance.exp b/gdb/testsuite/gdb.base/advance.exp
index a4bcfe6..bd59387 100644
--- a/gdb/testsuite/gdb.base/advance.exp
+++ b/gdb/testsuite/gdb.base/advance.exp
@@ -15,21 +15,13 @@
 
 # advance.exp -- Expect script to test 'advance' in gdb
 
-set testfile advance
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
-remote_exec build "rm -f ${binfile}"
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-    untested advance.exp
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
 if ![runto_main] then {
     fail "Can't run to main"
     return 0
diff --git a/gdb/testsuite/gdb.base/bigcore.exp b/gdb/testsuite/gdb.base/bigcore.exp
index ac3c5fb..8464195 100644
--- a/gdb/testsuite/gdb.base/bigcore.exp
+++ b/gdb/testsuite/gdb.base/bigcore.exp
@@ -47,7 +47,7 @@ if { [istarget "*-*-*irix*"] } {
 }
 
 standard_testfile .c
-set corefile ${binfile}.corefile
+set corefile [standard_output_file ${binfile}.corefile]
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested bigcore.exp
@@ -60,6 +60,12 @@ clean_restart ${binfile}
 gdb_test_no_output "set print sevenbit-strings"
 gdb_test_no_output "set width 0"
 
+# Get the core into the output directory.
+if {![is_remote host]} {
+    gdb_test "cd [file dirname $corefile]" "Working directory .*" \
+	"cd to test directory"
+}
+
 if { ![runto_main] } then {
     gdb_suppress_tests
 }
@@ -139,7 +145,7 @@ set timeout $oldtimeout
 # Find the corefile
 set file ""
 foreach pat [list core.${inferior_pid} ${testfile}.core core] {
-    set names [glob -nocomplain $pat]
+    set names [glob -nocomplain [standard_output_file $pat]]
     if {[llength $names] == 1} {
 	set file [lindex $names 0]
 	remote_exec build "mv $file $corefile"
@@ -188,7 +194,9 @@ if {! $core_ok} {
 # Now load up that core file
 
 set test "load corefile"
-gdb_test_multiple "core $corefile" "$test" {
+# We use [file tail] because gdb is still "cd"d to the
+# output directory.
+gdb_test_multiple "core [file tail $corefile]" "$test" {
     -re "A program is being debugged already.  Kill it. .y or n. " {
 	send_gdb "y\n"
 	exp_continue
diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
index eb9be90..ccdf82b 100644
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -63,7 +63,28 @@ if {${data_address} > ${max_32bit_address}} then {
 
 # Clean up any stale output files from previous test runs
 
-remote_exec build "rm -f intarr1.bin intarr1b.bin intarr1.ihex intarr1.srec intarr1.tekhex intarr2.bin intarr2b.bin intarr2.ihex intarr2.srec intarr2.tekhex intstr1.bin intstr1b.bin intstr1.ihex intstr1.srec intstr1.tekhex intstr2.bin intstr2b.bin intstr2.ihex intstr2.srec intstr2.tekhex intarr3.srec"
+set filenames {}
+set all_files {
+    intarr1.bin intarr1b.bin intarr1.ihex
+    intarr1.srec intarr1.tekhex intarr2.bin intarr2b.bin intarr2.ihex
+    intarr2.srec intarr2.tekhex intstr1.bin intstr1b.bin intstr1.ihex
+    intstr1.srec intstr1.tekhex intstr2.bin intstr2b.bin intstr2.ihex
+    intstr2.srec intstr2.tekhex intarr3.srec
+}
+
+# This loop sets variables dynamically -- each name listed in
+# $ALL_FILES is both a file name and a variable name.
+foreach file $all_files {
+    if {[is_remote host]} {
+	set this_name $file
+    } else {
+	set this_name [standard_output_file $file]
+    }
+
+    lappend filenames [set ${file} $this_name]
+}
+
+remote_exec host "rm -f $filenames"
 
 # Test help (FIXME:)
 
@@ -96,34 +117,34 @@ proc make_dump_file { command msg } {
     }
 }
 
-make_dump_file "dump val intarr1.bin intarray" \
+make_dump_file "dump val [set intarr1.bin] intarray" \
 	"dump array as value, default"
 
-make_dump_file "dump val intstr1.bin intstruct" \
+make_dump_file "dump val [set intstr1.bin] intstruct" \
 	"dump struct as value, default"
 
-make_dump_file "dump bin val intarr1b.bin intarray" \
+make_dump_file "dump bin val [set intarr1b.bin] intarray" \
 	"dump array as value, binary"
 
-make_dump_file "dump bin val intstr1b.bin intstruct" \
+make_dump_file "dump bin val [set intstr1b.bin] intstruct" \
 	"dump struct as value, binary"
 
-make_dump_file "dump srec val intarr1.srec intarray" \
+make_dump_file "dump srec val [set intarr1.srec] intarray" \
 	"dump array as value, srec"
 
-make_dump_file "dump srec val intstr1.srec intstruct" \
+make_dump_file "dump srec val [set intstr1.srec] intstruct" \
 	"dump struct as value, srec"
 
-make_dump_file "dump ihex val intarr1.ihex intarray" \
+make_dump_file "dump ihex val [set intarr1.ihex] intarray" \
 	"dump array as value, intel hex"
 
-make_dump_file "dump ihex val intstr1.ihex intstruct" \
+make_dump_file "dump ihex val [set intstr1.ihex] intstruct" \
 	"dump struct as value, intel hex"
 
-make_dump_file "dump tekhex val intarr1.tekhex intarray" \
+make_dump_file "dump tekhex val [set intarr1.tekhex] intarray" \
 	"dump array as value, tekhex"
 
-make_dump_file "dump tekhex val intstr1.tekhex intstruct" \
+make_dump_file "dump tekhex val [set intstr1.tekhex] intstruct" \
 	"dump struct as value, tekhex"
 
 proc capture_value { expression args } {
@@ -191,39 +212,39 @@ set struct_val   [capture_value "intstruct"]
 set array_ptr_type [capture_pointer_with_type "&intarray"]
 set struct_ptr_type [capture_pointer_with_type "&intstruct"]
 
-make_dump_file "dump mem intarr2.bin $array_start $array_end" \
+make_dump_file "dump mem [set intarr2.bin] $array_start $array_end" \
 	"dump array as memory, default"
 
-make_dump_file "dump  mem intstr2.bin $struct_start $struct_end" \
+make_dump_file "dump  mem [set intstr2.bin] $struct_start $struct_end" \
 	"dump struct as memory, default"
 
-make_dump_file "dump bin mem intarr2b.bin $array_start $array_end" \
+make_dump_file "dump bin mem [set intarr2b.bin] $array_start $array_end" \
 	"dump array as memory, binary"
 
-make_dump_file "dump bin mem intstr2b.bin $struct_start $struct_end" \
+make_dump_file "dump bin mem [set intstr2b.bin] $struct_start $struct_end" \
 	"dump struct as memory, binary"
 
-make_dump_file "dump srec mem intarr2.srec $array_start $array_end" \
+make_dump_file "dump srec mem [set intarr2.srec] $array_start $array_end" \
 	"dump array as memory, srec"
 
-make_dump_file "dump srec mem intstr2.srec $struct_start $struct_end" \
+make_dump_file "dump srec mem [set intstr2.srec] $struct_start $struct_end" \
 	"dump struct as memory, srec"
 
-make_dump_file "dump ihex mem intarr2.ihex $array_start $array_end" \
+make_dump_file "dump ihex mem [set intarr2.ihex] $array_start $array_end" \
 	"dump array as memory, ihex"
 
-make_dump_file "dump ihex mem intstr2.ihex $struct_start $struct_end" \
+make_dump_file "dump ihex mem [set intstr2.ihex] $struct_start $struct_end" \
 	"dump struct as memory, ihex"
 
-make_dump_file "dump tekhex mem intarr2.tekhex $array_start $array_end" \
+make_dump_file "dump tekhex mem [set intarr2.tekhex] $array_start $array_end" \
 	"dump array as memory, tekhex"
 
-make_dump_file "dump tekhex mem intstr2.tekhex $struct_start $struct_end" \
+make_dump_file "dump tekhex mem [set intstr2.tekhex] $struct_start $struct_end" \
 	"dump struct as memory, tekhex"
 
 # test complex expressions
 make_dump_file \
-	"dump srec mem intarr3.srec &intarray \(char *\) &intarray + sizeof intarray" \
+    "dump srec mem [set intarr3.srec] &intarray \(char *\) &intarray + sizeof intarray" \
 	"dump array as mem, srec, expressions"
 
 proc test_restore_saved_value { restore_args msg oldval newval } {
@@ -244,70 +265,70 @@ if ![string compare $is64bitonly "no"] then {
 
   gdb_test "print zero_all ()" ".*"
 
-  test_restore_saved_value "intarr1.srec" "array as value, srec" \
+  test_restore_saved_value "[set intarr1.srec]" "array as value, srec" \
 	$array_val "intarray"
 
-  test_restore_saved_value "intstr1.srec" "struct as value, srec" \
+  test_restore_saved_value "[set intstr1.srec]" "struct as value, srec" \
 	$struct_val "intstruct"
 
   gdb_test "print zero_all ()" "void" "zero all"
 
-  test_restore_saved_value "intarr2.srec" "array as memory, srec" \
+  test_restore_saved_value "[set intarr2.srec]" "array as memory, srec" \
 	$array_val "intarray"
 
-  test_restore_saved_value "intstr2.srec" "struct as memory, srec" \
+  test_restore_saved_value "[set intstr2.srec]" "struct as memory, srec" \
 	$struct_val "intstruct"
 
   gdb_test "print zero_all ()" ".*"
 
-  test_restore_saved_value "intarr1.ihex" "array as value, ihex" \
+  test_restore_saved_value "[set intarr1.ihex]" "array as value, ihex" \
 	$array_val "intarray"
 
-  test_restore_saved_value "intstr1.ihex" "struct as value, ihex" \
+  test_restore_saved_value "[set intstr1.ihex]" "struct as value, ihex" \
 	$struct_val "intstruct"
 
   gdb_test "print zero_all ()" ".*"
 
-  test_restore_saved_value "intarr2.ihex" "array as memory, ihex" \
+  test_restore_saved_value "[set intarr2.ihex]" "array as memory, ihex" \
 	$array_val "intarray"
 
-  test_restore_saved_value "intstr2.ihex" "struct as memory, ihex" \
+  test_restore_saved_value "[set intstr2.ihex]" "struct as memory, ihex" \
 	$struct_val "intstruct"
 
   gdb_test "print zero_all ()" ".*"
 
-  test_restore_saved_value "intarr1.tekhex" "array as value, tekhex" \
+  test_restore_saved_value "[set intarr1.tekhex]" "array as value, tekhex" \
 	$array_val "intarray"
 
-  test_restore_saved_value "intstr1.tekhex" "struct as value, tekhex" \
+  test_restore_saved_value "[set intstr1.tekhex]" "struct as value, tekhex" \
 	$struct_val "intstruct"
 
   gdb_test "print zero_all ()" ".*"
 
-  test_restore_saved_value "intarr2.tekhex" "array as memory, tekhex" \
+  test_restore_saved_value "[set intarr2.tekhex]" "array as memory, tekhex" \
 	$array_val "intarray"
 
-  test_restore_saved_value "intstr2.tekhex" "struct as memory, tekhex" \
+  test_restore_saved_value "[set intstr2.tekhex]" "struct as memory, tekhex" \
 	$struct_val "intstruct"
 }
 
 gdb_test "print zero_all ()" ".*"
 
-test_restore_saved_value "intarr1.bin binary $array_start" \
+test_restore_saved_value "[set intarr1.bin] binary $array_start" \
 	"array as value, binary" \
 	$array_val "intarray"
 
-test_restore_saved_value "intstr1.bin binary $struct_start" \
+test_restore_saved_value "[set intstr1.bin] binary $struct_start" \
 	"struct as value, binary" \
 	$struct_val "intstruct"
 
 gdb_test "print zero_all ()" ".*"
 
-test_restore_saved_value "intarr2.bin binary $array_start" \
+test_restore_saved_value "[set intarr2.bin] binary $array_start" \
 	"array as memory, binary" \
 	$array_val "intarray"
 
-test_restore_saved_value "intstr2.bin binary $struct_start" \
+test_restore_saved_value "[set intstr2.bin] binary $struct_start" \
 	"struct as memory, binary" \
 	$struct_val "intstruct"
 
@@ -324,42 +345,42 @@ gdb_test "print zero_all ()" ".*"
 
 
 if ![string compare $is64bitonly "no"] then {
-  test_restore_saved_value "intarr1.srec $array2_offset" \
+  test_restore_saved_value "[set intarr1.srec] $array2_offset" \
 	"array copy, srec" \
 	$array_val "intarray2"
 
-  test_restore_saved_value "intstr1.srec $struct2_offset" \
+  test_restore_saved_value "[set intstr1.srec] $struct2_offset" \
 	"struct copy, srec" \
 	$struct_val "intstruct2"
 
   gdb_test "print zero_all ()" ".*"
 
-  test_restore_saved_value "intarr1.ihex $array2_offset" \
+  test_restore_saved_value "[set intarr1.ihex] $array2_offset" \
 	"array copy, ihex" \
 	$array_val "intarray2"
 
-  test_restore_saved_value "intstr1.ihex $struct2_offset" \
+  test_restore_saved_value "[set intstr1.ihex] $struct2_offset" \
 	"struct copy, ihex" \
 	$struct_val "intstruct2"
 
   gdb_test "print zero_all ()" ".*"
 
-  test_restore_saved_value "intarr1.tekhex $array2_offset" \
+  test_restore_saved_value "[set intarr1.tekhex] $array2_offset" \
 	"array copy, tekhex" \
 	$array_val "intarray2"
 
-  test_restore_saved_value "intstr1.tekhex $struct2_offset" \
+  test_restore_saved_value "[set intstr1.tekhex] $struct2_offset" \
 	"struct copy, tekhex" \
 	$struct_val "intstruct2"
 }
 
 gdb_test "print zero_all ()" ".*"
 
-test_restore_saved_value "intarr1.bin binary $array2_start" \
+test_restore_saved_value "[set intarr1.bin] binary $array2_start" \
 	"array copy, binary" \
 	$array_val "intarray2"
 
-test_restore_saved_value "intstr1.bin binary $struct2_start" \
+test_restore_saved_value "[set intstr1.bin] binary $struct2_start" \
 	"struct copy, binary" \
 	$struct_val "intstruct2"
 
@@ -382,7 +403,7 @@ set element4_offset \
 if ![string compare $is64bitonly "no"] then {
   gdb_test "print zero_all ()" ".*"
 
-  test_restore_saved_value "intarr1.srec 0 $element3_start $element4_start" \
+  test_restore_saved_value "[set intarr1.srec] 0 $element3_start $element4_start" \
 	"array partial, srec" 4 "intarray\[3\]"
 
   gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 1"
@@ -390,7 +411,7 @@ if ![string compare $is64bitonly "no"] then {
 
   gdb_test "print zero_all ()" ".*"
 
-  test_restore_saved_value "intarr1.ihex 0 $element3_start $element4_start" \
+  test_restore_saved_value "[set intarr1.ihex] 0 $element3_start $element4_start" \
 	"array partial, ihex" 4 "intarray\[3\]"
 
   gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 2"
@@ -398,7 +419,7 @@ if ![string compare $is64bitonly "no"] then {
 
   gdb_test "print zero_all ()" ".*"
 
-  test_restore_saved_value "intarr1.tekhex 0 $element3_start $element4_start" \
+  test_restore_saved_value "[set intarr1.tekhex] 0 $element3_start $element4_start" \
 	"array partial, tekhex" 4 "intarray\[3\]"
 
   gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 3"
@@ -408,7 +429,7 @@ if ![string compare $is64bitonly "no"] then {
 gdb_test "print zero_all ()" ".*"
 
 test_restore_saved_value \
-    "intarr1.bin binary $array_start $element3_offset $element4_offset" \
+    "[set intarr1.bin] binary $array_start $element3_offset $element4_offset" \
     "array partial, binary" 4 "intarray\[3\]"
 
 gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 4"
@@ -419,7 +440,7 @@ if ![string compare $is64bitonly "no"] then {
 
   # restore with expressions 
   test_restore_saved_value \
-	"intarr3.srec (char*)${array2_start}-(char*)${array_start} &intarray\[3\] &intarray\[4\]" \
+	"[set intarr3.srec] (char*)${array2_start}-(char*)${array_start} &intarray\[3\] &intarray\[4\]" \
 	"array partial with expressions" 4 "intarray2\[3\]"
 
   gdb_test "print intarray2\[2\] == 0" " = 1" "element 2 not changed, == 4"
@@ -471,41 +492,49 @@ proc test_reload_saved_value { filename msg oldval newval } {
 
 # srec format can not be loaded for 64-bit-only platforms
 if ![string compare $is64bitonly "no"] then {
-  test_reload_saved_value "intarr1.srec" "reload array as value, srec" \
+  test_reload_saved_value "[set intarr1.srec]" "reload array as value, srec" \
 	$array_val "\*$array_ptr_type"
-  test_reload_saved_value "intstr1.srec" "reload struct as value, srec" \
+  test_reload_saved_value "[set intstr1.srec]" "reload struct as value, srec" \
 	$struct_val "\*$struct_ptr_type"
-  test_reload_saved_value "intarr2.srec" "reload array as memory, srec" \
+  test_reload_saved_value "[set intarr2.srec]" "reload array as memory, srec" \
 	$array_val "\*$array_ptr_type"
-  test_reload_saved_value "intstr2.srec" "reload struct as memory, srec" \
+  test_reload_saved_value "[set intstr2.srec]" "reload struct as memory, srec" \
 	$struct_val "\*$struct_ptr_type"
 }
 
 # ihex format can not be loaded for 64-bit-only platforms
 if ![string compare $is64bitonly "no"] then {
 
-  test_reload_saved_value "intarr1.ihex" "reload array as value, intel hex" \
+  test_reload_saved_value "[set intarr1.ihex]" \
+      "reload array as value, intel hex" \
 	$array_val "\*$array_ptr_type"
-  test_reload_saved_value "intstr1.ihex" "reload struct as value, intel hex" \
+  test_reload_saved_value "[set intstr1.ihex]" \
+      "reload struct as value, intel hex" \
 	$struct_val "\*$struct_ptr_type"
-  test_reload_saved_value "intarr2.ihex" "reload array as memory, intel hex" \
+  test_reload_saved_value "[set intarr2.ihex]" \
+      "reload array as memory, intel hex" \
 	$array_val "\*$array_ptr_type"
-  test_reload_saved_value "intstr2.ihex" "reload struct as memory, intel hex" \
+  test_reload_saved_value "[set intstr2.ihex]" \
+      "reload struct as memory, intel hex" \
 	$struct_val "\*$struct_ptr_type"
 }
 
 # tekhex format can not be loaded for 64-bit-only platforms
 if ![string compare $is64bitonly "no"] then {
-  test_reload_saved_value "intarr1.tekhex" "reload array as value, tekhex" \
+  test_reload_saved_value "[set intarr1.tekhex]" \
+      "reload array as value, tekhex" \
 	$array_val "\*$array_ptr_type"
-  test_reload_saved_value "intstr1.tekhex" "reload struct as value, tekhex" \
+  test_reload_saved_value "[set intstr1.tekhex]" \
+      "reload struct as value, tekhex" \
 	$struct_val "\*$struct_ptr_type"
-  test_reload_saved_value "intarr2.tekhex" "reload array as memory, tekhex" \
+  test_reload_saved_value "[set intarr2.tekhex]" \
+      "reload array as memory, tekhex" \
 	$array_val "\*$array_ptr_type"
-  test_reload_saved_value "intstr2.tekhex" "reload struct as memory, tekhex" \
+  test_reload_saved_value "[set intstr2.tekhex]" \
+      "reload struct as memory, tekhex" \
 	$struct_val "\*$struct_ptr_type"
 }
 
 # clean up files
 
-remote_exec build "rm -f intarr1.bin intarr1b.bin intarr1.ihex intarr1.srec intarr1.tekhex intarr2.bin intarr2b.bin intarr2.ihex intarr2.srec intarr2.tekhex intstr1.bin intstr1b.bin intstr1.ihex intstr1.srec intstr1.tekhex intstr2.bin intstr2b.bin intstr2.ihex intstr2.srec intstr2.tekhex intarr3.srec"
+remote_exec host "rm -f $filenames"
diff --git a/gdb/testsuite/gdb.base/interact.exp b/gdb/testsuite/gdb.base/interact.exp
index eb0d999..f0f0354 100644
--- a/gdb/testsuite/gdb.base/interact.exp
+++ b/gdb/testsuite/gdb.base/interact.exp
@@ -15,7 +15,8 @@
 
 # Create a GDB script that we can source.  The script needs to generate
 # some output, to allow us to verify that it is executed properly.
-set fd [open "zzz-gdbscript" "w"]
+set script [standard_output_file zzz-gdbscript]
+set fd [open $script "w"]
 puts $fd "print 1"
 puts $fd "print 2"
 close $fd
@@ -32,7 +33,7 @@ gdb_start
 # Verify that evaluating the script does not cause an unexpected
 # change of the interactive-mode setting.
 gdb_test_no_output "set interactive-mode auto"
-gdb_test "source zzz-gdbscript" "$script_output" \
+gdb_test "source $script" "$script_output" \
          "source script with interactive-mode auto"
 gdb_test "print 3" "= 3" "sanity check with interactive-mode auto"
 gdb_test "show interactive-mode" \
@@ -43,7 +44,7 @@ gdb_test "show interactive-mode" \
 # Verify that evaluating the script does not cause an unexpected
 # change of the interactive-mode setting.
 gdb_test_no_output "set interactive-mode on"
-gdb_test "source zzz-gdbscript" "$script_output" \
+gdb_test "source $script" "$script_output" \
          "source script with interactive-mode on"
 gdb_test "print 4" "= 4" "sanity check with interactive-mode on"
 gdb_test "show interactive-mode" \
@@ -54,7 +55,7 @@ gdb_test "show interactive-mode" \
 # Verify that evaluating the script does not cause an unexpected
 # change of the interactive-mode setting.
 gdb_test_no_output "set interactive-mode off"
-gdb_test "source zzz-gdbscript" "$script_output" \
+gdb_test "source $script" "$script_output" \
          "source script with interactive-mode off"
 gdb_test "print 5" "= 5" "sanity check with interactive-mode off"
 gdb_test "show interactive-mode" \
diff --git a/gdb/testsuite/gdb.base/jit-so.exp b/gdb/testsuite/gdb.base/jit-so.exp
index 70f2a7d..67682cf 100644
--- a/gdb/testsuite/gdb.base/jit-so.exp
+++ b/gdb/testsuite/gdb.base/jit-so.exp
@@ -61,7 +61,11 @@ if { [gdb_compile_shlib ${solib_srcfile} ${solib_binfile} {}] != "" } {
     return -1
 }
 
-set solib_binfile_target [gdb_download ${solib_binfile}]
+if {[is_remote target]} {
+    set solib_binfile_target [gdb_download ${solib_binfile}]
+} else {
+    set solib_binfile_target $solib_binfile
+}
 
 proc one_jit_test {count match_str} {
     with_test_prefix "one_jit_test-$count" {
diff --git a/gdb/testsuite/gdb.base/jit.exp b/gdb/testsuite/gdb.base/jit.exp
index e5151c6..d04f176 100644
--- a/gdb/testsuite/gdb.base/jit.exp
+++ b/gdb/testsuite/gdb.base/jit.exp
@@ -56,7 +56,11 @@ proc compile_jit_test {testname options} {
 	return -1
     }
 
-    set solib_binfile_target [gdb_download ${solib_binfile}]
+    if {[is_remote target]} {
+	set solib_binfile_target [gdb_download ${solib_binfile}]
+    } else {
+	set solib_binfile_target $solib_binfile
+    }
 
     return 0
 }
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 62504d1..c3cdc6b 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -19,7 +19,7 @@
 standard_testfile list0.c list1.c
 
 # Need to download the header to the host.
-remote_download host ${srcdir}/${subdir}/list0.h list0.h
+gdb_remote_download host ${srcdir}/${subdir}/list0.h
 
 if {[prepare_for_testing $testfile.exp $testfile [list $srcfile $srcfile2] \
 	 {debug}]} {
diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 3093aae..9425f2b 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -278,11 +278,11 @@ gdb_expect  {
 
 # Check that maint print msymbols allows relative pathnames
 set mydir [pwd]
-gdb_test "cd ${objdir}" \
-    "Working directory [string_to_regexp ${objdir}]\..*" \
+gdb_test "cd [standard_output_file {}]" \
+    "Working directory .*\..*" \
     "cd to objdir"
 
-gdb_test_multiple "maint print msymbols msymbols_output2 ${subdir}/${testfile}" "maint print msymbols" {
+gdb_test_multiple "maint print msymbols msymbols_output2 ${testfile}" "maint print msymbols" {
     -re "^maint print msymbols msymbols_output2 \[^\n\]*\r\n$gdb_prompt $" {
     	gdb_test_multiple "shell ls msymbols_output2" "maint print msymbols" {
 	    -re "msymbols_output2\r\n$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.base/prelink.exp b/gdb/testsuite/gdb.base/prelink.exp
index ac70726..0043e3a 100644
--- a/gdb/testsuite/gdb.base/prelink.exp
+++ b/gdb/testsuite/gdb.base/prelink.exp
@@ -36,7 +36,7 @@ load_lib prelink-support.exp
 set testfile "prelink"
 
 set libsrcfile ${testfile}-lib.c
-set libfile ${objdir}/${subdir}/${testfile}.so
+set libfile [standard_output_file ${testfile}.so]
 
 # Use -soname so that the new library gets copied by build_executable_own_libs.
 
@@ -47,7 +47,7 @@ if { [gdb_compile_shlib "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" [list d
 
 set srcfile ${testfile}.c
 set executable ${testfile}t
-set binfile ${objdir}/${subdir}/${executable}
+set binfile [standard_output_file ${executable}]
 set prelink_args [build_executable_own_libs ${testfile}.exp $executable $srcfile [list debug "ldflags=-Wl,${libfile},-rpath,[file dirname ${libfile}]"]]
 if {$prelink_args == ""} {
     return -1
@@ -66,13 +66,13 @@ if ![prelink_yes $prelink_args] {
 }
 
 set found 0
-set coredir "${objdir}/${subdir}/coredir.[getpid]"
+set coredir "[standard_output_file coredir.[getpid]]"
 file mkdir $coredir
 catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
 
 foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
     if [remote_file build exists $i] {
-	remote_exec build "mv $i ${objdir}/${subdir}/prelink.core"
+	remote_exec build "mv $i [standard_output_file prelink.core]"
 	set found 1
     }
 }
@@ -81,7 +81,7 @@ if { $found == 0 } {
     set names [glob -nocomplain -directory $coredir core.*]
     if {[llength $names] == 1} {
         set corefile [file join $coredir [lindex $names 0]]
-        remote_exec build "mv $corefile ${objdir}/${subdir}/prelink.core"
+        remote_exec build "mv $corefile [standard_output_file prelink.core]"
         set found 1
     }
 }
@@ -107,6 +107,6 @@ clean_restart $executable
 # Print the "adjusting expectations" message.
 gdb_test_no_output "set verbose on"
 
-gdb_test "core-file $objdir/$subdir/prelink.core" "Using PIC \\(Position Independent Code\\) prelink displacement 0x\[^0\]\[0-9a-f\]* for \[^\r\n\]*[file tail ${libfile}].*" "seen displacement message"
+gdb_test "core-file [standard_output_file prelink.core]" "Using PIC \\(Position Independent Code\\) prelink displacement 0x\[^0\]\[0-9a-f\]* for \[^\r\n\]*[file tail ${libfile}].*" "seen displacement message"
 
 gdb_test "p &bssvar == bssvarp" " = 1" ".dynbss vs. .bss address shift"
diff --git a/gdb/testsuite/gdb.base/save-bp.exp b/gdb/testsuite/gdb.base/save-bp.exp
index 64df0f7..9afe127 100644
--- a/gdb/testsuite/gdb.base/save-bp.exp
+++ b/gdb/testsuite/gdb.base/save-bp.exp
@@ -48,8 +48,13 @@ gdb_test "commands\nsilent\nend" "End with.*" "add breakpoint commands"
 gdb_test "dprintf ${srcfile}:${loc_bp5},\"At foo entry\\n\"" "Dprintf .*"
 
 # Now, save the breakpoints into a file...
-remote_file host delete "bps"
-gdb_test "save breakpoint bps"
+if {[is_remote host]} {
+    set bps bps
+} else {
+    set bps [standard_output_file bps]
+}
+remote_file host delete "$bps"
+gdb_test "save breakpoint $bps" "" "save breakpoint bps"
 
 # Now start a new debugger session...
 clean_restart $testfile
@@ -62,7 +67,7 @@ if ![runto_main] {
 delete_breakpoints
 
 # ... and restore the breakpoints.
-gdb_test "source bps"
+gdb_test "source $bps" "" "source bps"
 
 # Now, verify that all breakpoints have been created correctly...
 set bp_row_start "\[0-9\]+ +breakpoint +keep +y +0x\[0-9a-f\]+ +in"
diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp
index 9e956c7..632a43e 100644
--- a/gdb/testsuite/gdb.base/sepdebug.exp
+++ b/gdb/testsuite/gdb.base/sepdebug.exp
@@ -29,9 +29,7 @@
 # test running programs
 #
 
-set testfile "sepdebug"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}${EXEEXT}
+standard_testfile .c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
     untested sepdebug.exp
@@ -54,14 +52,15 @@ if [gdb_gnu_strip_debug $binfile] {
 # PR gdb/9538.  Verify that symlinked executable still finds the separate
 # debuginfo.
 #
-set old_subdir ${subdir}
-set subdir ${subdir}/pr9538
+set old_subdir $subdir
+set subdir [file join ${old_subdir} pr9538]
 
 # Cleanup any stale state.
-remote_exec build "rm -rf ${subdir}"
+set new_name [standard_output_file ${testfile}${EXEEXT}]
+remote_exec build "rm -rf [file dirname $new_name]"
 
-remote_exec build "mkdir ${subdir}"
-remote_exec build "ln -s ${binfile} ${subdir}"
+remote_exec build "mkdir [file dirname $new_name]"
+remote_exec build "ln -s ${binfile} $new_name"
 clean_restart ${testfile}${EXEEXT}
 if { $gdb_file_cmd_debug_info != "debug" } then {
     fail "No debug information found."
@@ -650,7 +649,7 @@ test_next_with_recursion
 
 proc test_different_dir {type test_different_dir xfail} {
     with_test_prefix "$type" {
-	global srcdir subdir objdir binfile srcfile timeout gdb_prompt
+	global srcdir subdir binfile srcfile timeout gdb_prompt
 	global bp_location6 decimal hex
 
 	gdb_exit
@@ -750,11 +749,11 @@ proc test_different_dir {type test_different_dir xfail} {
 # now move the .debug file to a different location so that we can test
 # the "set debug-file-directory" command.
 
-set different_dir "${objdir}/${subdir}/${testfile}.dir"
-set debugfile "${different_dir}/${objdir}/${subdir}/${testfile}.debug"
+set different_dir [standard_output_file ${testfile}.dir]
+set debugfile "${different_dir}/[standard_output_file ${testfile}.debug]"
 remote_exec build "rm -rf $different_dir"
 remote_exec build "mkdir -p [file dirname $debugfile]"
-remote_exec build "mv -f ${objdir}/${subdir}/${testfile}.debug $debugfile"
+remote_exec build "mv -f [standard_output_file ${testfile}.debug] $debugfile"
 
 test_different_dir debuglink $different_dir 0
 
@@ -762,17 +761,17 @@ test_different_dir debuglink $different_dir 0
 # Test CRC mismatch is reported.
 
 if {[build_executable sepdebug.exp sepdebug2 sepdebug2.c debug] != -1
-    && ![gdb_gnu_strip_debug ${objdir}/${subdir}/sepdebug2]} {
+    && ![gdb_gnu_strip_debug [standard_output_file sepdebug2]]} {
 
-    remote_exec build "cp ${debugfile} ${objdir}/${subdir}/sepdebug2.debug"
+    remote_exec build "cp ${debugfile} [standard_output_file sepdebug2.debug]"
 
     gdb_exit
     gdb_start
     gdb_reinitialize_dir $srcdir/$subdir
 
-    set escapedobjdirsubdir [string_to_regexp ${objdir}/${subdir}]
+    set escapedobjdirsubdir [string_to_regexp [standard_output_file {}]]
 
-    gdb_test "file ${objdir}/${subdir}/sepdebug2" "warning: the debug information found in \"${escapedobjdirsubdir}/sepdebug2\\.debug\" does not match \"${escapedobjdirsubdir}/sepdebug2\" \\(CRC mismatch\\)\\..*\\(no debugging symbols found\\).*" "CRC mismatch is reported"
+    gdb_test "file [standard_output_file sepdebug2]" "warning: the debug information found in \"${escapedobjdirsubdir}/sepdebug2\\.debug\" does not match \"${escapedobjdirsubdir}/sepdebug2\" \\(CRC mismatch\\)\\..*\\(no debugging symbols found\\).*" "CRC mismatch is reported"
 }
 
 
@@ -797,17 +796,17 @@ if ![string compare $build_id_debug_filename ""] then {
 	pass $test
     }
 
-    file mkdir [file dirname ${objdir}/${subdir}/${build_id_debug_filename}]
-    remote_exec build "mv $debugfile ${objdir}/${subdir}/${build_id_debug_filename}"
+    file mkdir [file dirname [standard_output_file ${build_id_debug_filename}]]
+    remote_exec build "mv $debugfile [standard_output_file ${build_id_debug_filename}]"
 
-    test_different_dir build-id "${objdir}/${subdir}" $xfail
+    test_different_dir build-id [standard_output_file {}] $xfail
 
     # Test also multiple directories can be specified.  Without the build-id
     # reference GDB would find the separate debug info just at the same
     # location as the executable file.
 
-    test_different_dir multiple-dirs "/doesnotexist:${objdir}/${subdir}" $xfail
+    test_different_dir multiple-dirs "/doesnotexist:[standard_output_file {}]" $xfail
 
     # Spare debug files may confuse testsuite runs in the future.
-    remote_exec build "rm -f ${objdir}/${subdir}/${build_id_debug_filename}"
+    remote_exec build "rm -f [standard_output_file ${build_id_debug_filename}]"
 }
diff --git a/gdb/testsuite/gdb.base/solib-search.exp b/gdb/testsuite/gdb.base/solib-search.exp
index 9b10664..c3298d8 100644
--- a/gdb/testsuite/gdb.base/solib-search.exp
+++ b/gdb/testsuite/gdb.base/solib-search.exp
@@ -35,33 +35,35 @@ set right_lib_subdir "solib-search-right"
 # First library file.
 set libname1 "solib-search-lib1"
 set srcfile1_lib ${srcdir}/${subdir}/${libname1}.c
-set wrong_binfile1_lib ${objdir}/${subdir}/${wrong_lib_subdir}/${libname1}.so
-set right_binfile1_lib ${objdir}/${subdir}/${right_lib_subdir}/${libname1}.so
+set wrong_binfile1_lib \
+    [standard_output_file ${wrong_lib_subdir}/${libname1}.so]
+set right_binfile1_lib \
+    [standard_output_file ${right_lib_subdir}/${libname1}.so]
 # Second library file.
 set libname2 "solib-search-lib2"
 set srcfile2_lib ${srcdir}/${subdir}/${libname2}.c
-set wrong_binfile2_lib ${objdir}/${subdir}/${wrong_lib_subdir}/${libname2}.so
-set right_binfile2_lib ${objdir}/${subdir}/${right_lib_subdir}/${libname2}.so
+set wrong_binfile2_lib \
+    [standard_output_file ${wrong_lib_subdir}/${libname2}.so]
+set right_binfile2_lib \
+    [standard_output_file ${right_lib_subdir}/${libname2}.so]
 # Link with the library that lives here.
 # This is so that we can replace what gdb sees with the wrong copy,
 # and then tell gdb to use the right copy that lives someplace else.
-set binfile1_lib ${objdir}/${subdir}/${libname1}.so
-set binfile2_lib ${objdir}/${subdir}/${libname2}.so
+set binfile1_lib [standard_output_file ${libname1}.so]
+set binfile2_lib [standard_output_file ${libname2}.so]
 
 set lib_flags [list debug ldflags=-Wl,-Bsymbolic]
 set wrong_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=1"
 set right_lib_flags "$lib_flags additional_flags=-DARRAY_SIZE=8192 -DRIGHT"
 
 # Binary file.
-set testfile "solib-search"
-set srcfile ${srcdir}/${subdir}/${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .c
 set bin_flags [list debug shlib=${binfile1_lib} shlib=${binfile2_lib}]
 
-remote_exec build "rm -rf ${subdir}/${wrong_lib_subdir}"
-remote_exec build "rm -rf ${subdir}/${right_lib_subdir}"
-remote_exec build "mkdir ${subdir}/${wrong_lib_subdir}"
-remote_exec build "mkdir ${subdir}/${right_lib_subdir}"
+remote_exec build "rm -rf [standard_output_file ${wrong_lib_subdir}]"
+remote_exec build "rm -rf [standard_output_file ${right_lib_subdir}]"
+remote_exec build "mkdir [standard_output_file ${wrong_lib_subdir}]"
+remote_exec build "mkdir [standard_output_file ${right_lib_subdir}]"
 
 if { [gdb_compile_shlib ${srcfile1_lib} ${wrong_binfile1_lib} $wrong_lib_flags] != ""
      || [gdb_compile_shlib ${srcfile2_lib} ${wrong_binfile2_lib} $wrong_lib_flags] != ""
@@ -74,7 +76,8 @@ if { [gdb_compile_shlib ${srcfile1_lib} ${wrong_binfile1_lib} $wrong_lib_flags]
 # Build the test binary using the right copies of the libraries.
 remote_exec build "ln -sf ${right_lib_subdir}/${libname1}.so ${binfile1_lib}"
 remote_exec build "ln -sf ${right_lib_subdir}/${libname2}.so ${binfile2_lib}"
-if { [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } {
+if { [gdb_compile $srcdir/$subdir/${srcfile} ${binfile} \
+	  executable $bin_flags] != "" } {
     untested "Could not compile $binfile."
     return -1
 }
@@ -89,7 +92,7 @@ if { ![runto_main] } {
 gdb_breakpoint "break_here"
 gdb_continue "break_here"
 
-set corefile "${objdir}/${subdir}/solib-search.core"
+set corefile [standard_output_file solib-search.core]
 set core_supported [gdb_gcore_cmd "$corefile" "save a corefile"]
 
 if {!$core_supported} {
@@ -175,7 +178,7 @@ test_backtrace 1
 remote_exec build "rm -f ${binfile1_lib}"
 remote_exec build "rm -f ${binfile2_lib}"
 # Set solib-search-path to use the correct copies of libraries.
-gdb_test "set solib-search-path ${objdir}/${subdir}/${right_lib_subdir}" \
+gdb_test "set solib-search-path [standard_output_file ${right_lib_subdir}]" \
     "" \
     "set solib-search-path"
 
diff --git a/gdb/testsuite/gdb.base/step-line.exp b/gdb/testsuite/gdb.base/step-line.exp
index bc8f2bc..73113c7 100644
--- a/gdb/testsuite/gdb.base/step-line.exp
+++ b/gdb/testsuite/gdb.base/step-line.exp
@@ -33,7 +33,7 @@ if ![runto_main] then {
    return 0
 }
 
-set remote_linefile [remote_download host ${srcdir}/${subdir}/${linefile}]
+set remote_linefile [gdb_remote_download host ${srcdir}/${subdir}/${linefile}]
 
 gdb_test "break f1" ".*Breakpoint 2 at .* file .*step-line.c.*" "break f1"
 gdb_test "continue" \
diff --git a/gdb/testsuite/gdb.base/trace-commands.exp b/gdb/testsuite/gdb.base/trace-commands.exp
index ed49049..0ec77a0 100644
--- a/gdb/testsuite/gdb.base/trace-commands.exp
+++ b/gdb/testsuite/gdb.base/trace-commands.exp
@@ -20,7 +20,8 @@ gdb_exit
 gdb_start
 
 # Create a file to source
-set fd [open "tracecommandsscript" w]
+set tracecommandsscript [standard_output_file tracecommandsscript]
+set fd [open "$tracecommandsscript" w]
 puts $fd "\
 echo in tracecommandsscript\\n
 define func
@@ -44,7 +45,7 @@ gdb_test "show trace-commands" "State of GDB CLI command tracing is off\\." \
 	 "show trace-commands says off"
 
 # Source the script with verbose mode.
-gdb_test_sequence "source -v tracecommandsscript" "source -v" {
+gdb_test_sequence "source -v $tracecommandsscript" "source -v" {
   {[\r\n]\+echo in tracecommandsscript\\n}
   {[\r\n]\+define func}
   {[\r\n]\+if 1}
@@ -91,13 +92,13 @@ gdb_test_sequence "if 1\nset \$i = 0\nwhile \$i < 5\nfunc \$i\nset \$i += 1\nend
 }
 
 # Function with source works
-gdb_test_sequence "define topfunc\nsource tracecommandsscript\nend" \
+gdb_test_sequence "define topfunc\nsource $tracecommandsscript\nend" \
     "define user command" {
   {[\r\n]\+define topfunc}
 }
 gdb_test_sequence "topfunc" "nested trace-commands test with source" {
   {[\r\n]\+topfunc}
-  {[\r\n]\+\+source tracecommandsscript}
+  {[\r\n]\+\+source .*/tracecommandsscript}
   {[\r\n]\+\+echo in tracecommandsscript\\n}
   {[\r\n]\+\+define func}
   {[\r\n]\+\+if 1}
-- 
1.8.1.4

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

* [PATCH v2 01/17] fix up log-file toggling
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (4 preceding siblings ...)
  2013-10-18 20:49 ` [PATCH v2 02/17] fix some simple thinkos in the test suite Tom Tromey
@ 2013-10-18 20:49 ` Tom Tromey
  2013-10-18 20:49 ` [PATCH v2 08/17] simple changes in gdb.base Tom Tromey
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 20:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Currently a proc in gdb.exp toggles the expect (and thus dejagnu)
logging.  This is not a super idea, but it is there to avoid putting
some preprocessor output into the log.

In the right circumstances, this can result in the log file being
mysteriously truncated.  I think this happens because it doesn't
necessarily write to the correct log file again.

The fix is to use "log_file -info" to save the previous log file.

	* lib/gdb.exp (get_compiler_info): Use log_file -info and
	restore from that.
---
 gdb/testsuite/lib/gdb.exp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 44786ec..fbb9f71 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2406,6 +2406,7 @@ proc get_compiler_info {{arg ""}} {
 
     # Run $ifile through the right preprocessor.
     # Toggle gdb.log to keep the compiler output out of the log.
+    set saved_log [log_file -info]
     log_file
     if [is_remote host] {
 	# We have to use -E and -o together, despite the comments
@@ -2418,7 +2419,7 @@ proc get_compiler_info {{arg ""}} {
     } else {
 	set cppout [ gdb_compile "${ifile}" "" preprocess [list "$arg" quiet] ]
     }
-    log_file -a "$outdir/$tool.log" 
+    eval log_file $saved_log
 
     # Eval the output.
     set unknown 0
-- 
1.8.1.4

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

* [PATCH v2 06/17] fix up gdb.mi
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
@ 2013-10-18 20:49 ` Tom Tromey
  2013-10-18 20:49 ` [PATCH v2 12/17] fix up gdb.server Tom Tromey
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 20:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes gdb.mi to be parallel-safe.

	* gdb.mi/mi-cmd-param-changed.exp (test_command_param_changed):
	Use "dwarf2 always-disassemble" for the "maint set" test.
	* gdb.mi/mi-file-transfer.exp (test_file_transfer): Use
	standard_output_file.
	* gdb.mi/mi-logging.exp: Use standard_output_file.
---
 gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp |  6 +++---
 gdb/testsuite/gdb.mi/mi-file-transfer.exp     | 26 +++++++++++++++++++-------
 gdb/testsuite/gdb.mi/mi-logging.exp           |  2 +-
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
index 1791c97..7ba8724 100644
--- a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
@@ -85,9 +85,9 @@ proc test_command_param_changed { } {
 
 	# No notification is emitted for 'maint set' commands.
 	foreach boolean_opt { "on" "off" } {
-	    mi_gdb_test "maint set profile ${boolean_opt}" \
-		"\\&\"maint set profile ${boolean_opt}\\\\n\"\r\n\\^done" \
-		"\"maint set profile ${boolean_opt}\""
+	    mi_gdb_test "maint set dwarf2 always-disassemble ${boolean_opt}" \
+		"\\&\"maint set dwarf2 always-disassemble ${boolean_opt}\\\\n\"\r\n\\^done" \
+		"\"maint dwarf2 always-disassemble ${boolean_opt}\""
 	}
 
 	# Full command parameters are included in the notification when a
diff --git a/gdb/testsuite/gdb.mi/mi-file-transfer.exp b/gdb/testsuite/gdb.mi/mi-file-transfer.exp
index 9229fde..dbf0d66 100644
--- a/gdb/testsuite/gdb.mi/mi-file-transfer.exp
+++ b/gdb/testsuite/gdb.mi/mi-file-transfer.exp
@@ -54,15 +54,27 @@ proc mi_gdbserver_run { } {
 }
 
 proc test_file_transfer { filename description } {
-    mi_gdb_test "-target-file-put \"$filename\" \"down-server\"" \
+    # If we are running everything locally, then we want to be sure to
+    # put the files into the test's standard output location.  On the
+    # other hand, if the host or target is remote, then we need to
+    # continue with the "old-style" directory-less approach.
+    if {![is_remote host] && ![is_remote target]} {
+	set up_server [standard_output_file up-server]
+	set down_server [standard_output_file down-server]
+    } else {
+	set up_server up-server
+	set down_server down-server
+    }
+
+    mi_gdb_test "-target-file-put \"$filename\" \"${down_server}\"" \
 	"\\^done" "put $description"
-    mi_gdb_test "-target-file-get \"down-server\" \"up-server\"" \
+    mi_gdb_test "-target-file-get \"${down_server}\" \"${up_server}\"" \
 	"\\^done" "get $description"
 
     if { ![is_remote target] } {
 	# If we can check the target copy of the file, do that too.
 	# This should catch symmetric errors in upload and download.
-	set result [remote_exec host "cmp -s $filename down-server"]
+	set result [remote_exec host "cmp -s $filename ${down_server}"]
 	if { [lindex $result 0] == 0 } {
 	    pass "compare intermediate $description"
 	} else {
@@ -70,25 +82,25 @@ proc test_file_transfer { filename description } {
 	}
     }
 
-    set result [remote_exec host "cmp -s $filename up-server"]
+    set result [remote_exec host "cmp -s $filename ${up_server}"]
     if { [lindex $result 0] == 0 } {
 	pass "compare $description"
     } else {
 	fail "compare $description"
     }
 
-    mi_gdb_test "-target-file-delete \"down-server\"" \
+    mi_gdb_test "-target-file-delete \"${down_server}\"" \
 	"\\^done" "deleted $description"
 
     if { ![is_remote target] } {
-	if { ! [remote_file target exists down-server] } {
+	if { ! [remote_file target exists ${down_server}] } {
 	    pass "verified deleted $description"
 	} else {
 	    fail "verified deleted $description"
 	}
     }
 
-    catch { file delete up-server }
+    catch { file delete ${up_server} }
 }
 
 mi_gdbserver_run
diff --git a/gdb/testsuite/gdb.mi/mi-logging.exp b/gdb/testsuite/gdb.mi/mi-logging.exp
index 87f3e1b..b38c036 100644
--- a/gdb/testsuite/gdb.mi/mi-logging.exp
+++ b/gdb/testsuite/gdb.mi/mi-logging.exp
@@ -33,7 +33,7 @@ if {[mi_run_to_main] < 0} {
     return -1
 }
 
-set milogfile "milog.txt"
+set milogfile [standard_output_file "milog.txt"]
 
 mi_gdb_test "-gdb-set logging file $milogfile" ".*"
 
-- 
1.8.1.4

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

* [PATCH v2 15/17] fix some "exec" tests
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (6 preceding siblings ...)
  2013-10-18 20:49 ` [PATCH v2 08/17] simple changes in gdb.base Tom Tromey
@ 2013-10-18 20:49 ` Tom Tromey
  2013-10-25 16:21   ` Pedro Alves
  2013-10-18 20:49 ` [PATCH v2 09/17] update checkpoint test Tom Tromey
                   ` (9 subsequent siblings)
  17 siblings, 1 reply; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 20:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A few tests run an inferior that execs some other inferior.  These
tests have the correct file name compiled in.  These tests assume the
current test suite directory layout, but fail in parallel mode.

This patch fixes these tests by letting the .exp files pass in the
directory names at compile time.

	* gdb.base/foll-exec.c (main): Use BASEDIR.
	* gdb.base/foll-exec.exp: Define BASEDIR during compilation.
	* gdb.base/foll-vfork.c (main): Use BASEDIR.
	* gdb.base/foll-vfork.exp: Define BASEDIR during compilation.
	* gdb.multi/bkpt-multi-exec.c (main): Use BASEDIR.
	* gdb.multi/bkpt-multi-exec.exp: Define BASEDIR during compilation.
---
 gdb/testsuite/gdb.base/foll-exec.c          | 12 ++++++------
 gdb/testsuite/gdb.base/foll-exec.exp        |  8 ++++++--
 gdb/testsuite/gdb.base/foll-vfork.c         |  2 +-
 gdb/testsuite/gdb.base/foll-vfork.exp       |  8 ++++++--
 gdb/testsuite/gdb.multi/bkpt-multi-exec.c   |  4 ++--
 gdb/testsuite/gdb.multi/bkpt-multi-exec.exp |  8 ++++++--
 6 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/gdb/testsuite/gdb.base/foll-exec.c b/gdb/testsuite/gdb.base/foll-exec.c
index 1b76090..78c1cda 100644
--- a/gdb/testsuite/gdb.base/foll-exec.c
+++ b/gdb/testsuite/gdb.base/foll-exec.c
@@ -17,27 +17,27 @@ main ()
 
   printf ("foll-exec is about to execlp(execd-prog)...\n");
 
-  execlp ("gdb.base/execd-prog",
-          "gdb.base/execd-prog",
+  execlp (BASEDIR "/execd-prog",
+          BASEDIR "/execd-prog",
           "execlp arg1 from foll-exec",
           (char *)0);
 
   printf ("foll-exec is about to execl(execd-prog)...\n");
 
-  execl ("gdb.base/execd-prog",
-         "gdb.base/execd-prog",
+  execl (BASEDIR "/execd-prog",
+         BASEDIR "/execd-prog",
          "execl arg1 from foll-exec",
          "execl arg2 from foll-exec",
          (char *)0);
 
   {
     static char * argv[] = {
-      (char *)"gdb.base/execd-prog",
+      (char *)BASEDIR "/execd-prog",
       (char *)"execv arg1 from foll-exec",
       (char *)0};
 
     printf ("foll-exec is about to execv(execd-prog)...\n");
 
-    execv ("gdb.base/execd-prog", argv);
+    execv (BASEDIR "/execd-prog", argv);
   }
 }
diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp
index 9456f42..135cad6 100644
--- a/gdb/testsuite/gdb.base/foll-exec.exp
+++ b/gdb/testsuite/gdb.base/foll-exec.exp
@@ -29,13 +29,17 @@ set testfile2 "execd-prog"
 set srcfile2 ${testfile2}.c
 set binfile2 [standard_output_file ${testfile2}]
 
+set compile_options debug
+set dirname [relative_filename [pwd] [file dirname $binfile]]
+lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\""
+
 # build the first test case
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } {
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable $compile_options] != "" } {
      untested foll-exec.exp
      return -1
 }
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_options] != "" } {
      untested foll-exec.exp
      return -1
 }
diff --git a/gdb/testsuite/gdb.base/foll-vfork.c b/gdb/testsuite/gdb.base/foll-vfork.c
index 694843f..d7d72fd 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.c
+++ b/gdb/testsuite/gdb.base/foll-vfork.c
@@ -29,7 +29,7 @@ main ()
   pid = vfork ();
   if (pid == 0) {
     printf ("I'm the child!\n");
-    execlp ("gdb.base/vforked-prog", "gdb.base/vforked-prog", (char *)0);
+    execlp (BASEDIR "/vforked-prog", BASEDIR "/vforked-prog", (char *)0);
     perror ("exec failed");
     _exit (1);
   }
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index 0660060..29d6da0 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -47,7 +47,11 @@ if [istarget "hppa*-hp-hpux10.20"] then {
 
 standard_testfile
 
-if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
+set compile_options debug
+set dirname [relative_filename [pwd] [file dirname $binfile]]
+lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\""
+
+if {[build_executable $testfile.exp $testfile $srcfile $compile_options] == -1} {
     untested "failed to compile $testfile"
     return -1
 }
@@ -55,7 +59,7 @@ if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
 set testfile2 "vforked-prog"
 set srcfile2 ${testfile2}.c
 
-if {[build_executable $testfile.exp $testfile2 $srcfile2 {debug}] == -1} {
+if {[build_executable $testfile.exp $testfile2 $srcfile2 $compile_options] == -1} {
     untested "failed to compile $testfile2"
     return -1
 }
diff --git a/gdb/testsuite/gdb.multi/bkpt-multi-exec.c b/gdb/testsuite/gdb.multi/bkpt-multi-exec.c
index 672d63b..94c9668 100644
--- a/gdb/testsuite/gdb.multi/bkpt-multi-exec.c
+++ b/gdb/testsuite/gdb.multi/bkpt-multi-exec.c
@@ -7,7 +7,7 @@ int main (void)
 {
   printf ("foll-exec is about to execl(crashme)...\n");
 
-  execl ("gdb.multi/crashme",
-         "gdb.multi/crashme",
+  execl (BASEDIR "/crashme",
+         BASEDIR "/crashme",
          (char *)0);
 }
diff --git a/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp b/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp
index cf74701..c4eee8f 100644
--- a/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp
+++ b/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp
@@ -33,11 +33,15 @@ set exec2 "crashme"
 set srcfile2 ${exec2}.c
 set binfile2 [standard_output_file ${exec2}]
 
-if { [build_executable ${testfile}.exp ${exec1} "${srcfile1}" {debug nowarnings}] == -1 } {
+set compile_options {debug nowarnings}
+set dirname [relative_filename [pwd] [file dirname $binfile1]]
+lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\""
+
+if { [build_executable ${testfile}.exp ${exec1} "${srcfile1}" $compile_options] == -1 } {
     return -1
 }
 
-if { [build_executable ${testfile}.exp ${exec2} "${srcfile2}" {debug nowarnings}] == -1 } {
+if { [build_executable ${testfile}.exp ${exec2} "${srcfile2}" $compile_options] == -1 } {
     return -1
 }
 
-- 
1.8.1.4

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

* [PATCH v2 03/17] fix weird.exp for parallel testing
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (2 preceding siblings ...)
  2013-10-18 20:49 ` [PATCH v2 07/17] fix up gdb.trace Tom Tromey
@ 2013-10-18 20:49 ` Tom Tromey
  2013-10-18 20:49 ` [PATCH v2 02/17] fix some simple thinkos in the test suite Tom Tromey
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 20:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes up gdb.stabs/weird.exp for parallel testing.  This just
means using gdb_remote_download and standard_output_file, so that the
tests end up in the right place.

	* gdb.stabs/weird.exp: Use gdb_remote_download and
	standard_output_file.
---
 gdb/testsuite/gdb.stabs/weird.exp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.stabs/weird.exp b/gdb/testsuite/gdb.stabs/weird.exp
index bf0fdba..64e6082 100644
--- a/gdb/testsuite/gdb.stabs/weird.exp
+++ b/gdb/testsuite/gdb.stabs/weird.exp
@@ -292,7 +292,8 @@ gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 
-set binfile [remote_download host ${binfile} object.o]
+set binfile [gdb_remote_download host ${binfile} \
+		 [standard_output_file object.o]]
 send_gdb "file $binfile\n"
 # If $binfile is very long, a \r (but not a \n) will echo in the
 # middle of the echo of the command.  So to match the echo, we
-- 
1.8.1.4

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

* [PATCH v2 09/17] update checkpoint test
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (7 preceding siblings ...)
  2013-10-18 20:49 ` [PATCH v2 15/17] fix some "exec" tests Tom Tromey
@ 2013-10-18 20:49 ` Tom Tromey
  2013-10-18 21:00 ` [PATCH v2 14/17] fix argv0-symlink.exp for parallel mode Tom Tromey
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 20:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes the "checkpoint" test to use the standard output directory.
This makes the test be parallel-safe.

	* gdb.base/checkpoint.c (main): Use PI_TXT and COPY1_TXT
	defines.
	* gdb.base/checkpoint.exp: Define PI_TXT and COPY1_TXT during
	compilation.  Use prepare_for_testing, standard_output_file.
---
 gdb/testsuite/gdb.base/checkpoint.c   |  6 +++---
 gdb/testsuite/gdb.base/checkpoint.exp | 30 ++++++++++++++++--------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/gdb/testsuite/gdb.base/checkpoint.c b/gdb/testsuite/gdb.base/checkpoint.c
index c287094..d498047 100644
--- a/gdb/testsuite/gdb.base/checkpoint.c
+++ b/gdb/testsuite/gdb.base/checkpoint.c
@@ -28,8 +28,8 @@ main()
   long i;
   int c = 0;
 
-  in  = fopen ("pi.txt", "r");
-  out = fopen ("copy1.txt", "w");
+  in  = fopen (PI_TXT, "r");
+  out = fopen (COPY1_TXT, "w");
 
   if (!in || !out)
     {
@@ -54,6 +54,6 @@ main()
   fclose (in);
   fclose (out);
   printf ("Deleting copy.\n");	/* breakpoint 3 */
-  unlink ("copy1.txt");
+  unlink (COPY1_TXT);
   exit (0);			/* breakpoint 4 */
 }
diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index b86fead..f1af471 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -27,23 +27,25 @@ if {![istarget "*-*-linux*"]} then {
 
 standard_testfile .c
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+set pi_txt [gdb_remote_download host ${srcdir}/${subdir}/pi.txt]
+if {[is_remote host]} {
+    set copy1_txt copy1.txt
+} else {
+    set copy1_txt [standard_output_file copy1.txt]
+}
+
+if {[prepare_for_testing ${testfile}.exp $testfile $srcfile \
+	 [list debug "additional_flags=-DPI_TXT=\"$pi_txt\" -DCOPY1_TXT=\"$copy1_txt\""]]} {
      untested checkpoint.exp
      return -1
 }
 
-# Start with a fresh gdb
-
-clean_restart ${binfile}
-
 global gdb_prompt
 
 #
 # This tests gdb checkpoint and restart.
 #
 
-remote_download host ${srcdir}/${subdir}/pi.txt pi.txt
-
 runto_main
 set break1_loc [gdb_get_line_number "breakpoint 1"]
 set break2_loc [gdb_get_line_number "breakpoint 2"]
@@ -148,8 +150,8 @@ gdb_test "restart 0" "Switching to .*breakpoint 2.*" "restart 0 one"
 gdb_breakpoint $break3_loc
 gdb_test "continue" "breakpoint 3.*" "break3 one"
 
-gdb_test "shell diff -s pi.txt copy1.txt" \
-    "Files pi.txt and copy1.txt are identical.*" \
+gdb_test "shell diff -s $pi_txt $copy1_txt" \
+    "Files .*pi.txt and .*copy1.txt are identical.*" \
     "Diff input and output one"
 
 #
@@ -201,8 +203,8 @@ gdb_test "continue 1100" "breakpoint 1.*" "breakpoint 1 7 one"
 gdb_test "step" "if .c == EOF.*" "step in 7 two"
 gdb_test "print lines" " = 1162.*" "verify lines 7 two"
 
-gdb_test "shell diff -s pi.txt copy1.txt" \
-    "Files pi.txt and copy1.txt are identical.*" \
+gdb_test "shell diff -s $pi_txt $copy1_txt" \
+    "Files .*pi.txt and .*copy1.txt are identical.*" \
     "Diff input and output two"
 
 # 
@@ -214,8 +216,8 @@ gdb_test "restart 0" "Switching to .*breakpoint 3.*" "restart 0 one"
 gdb_breakpoint $break4_loc
 gdb_test "continue" "breakpoint 4.*" "break4 one"
 
-gdb_test "shell diff pi.txt copy1.txt" \
-    "diff: copy1.txt: No such file or directory" \
+gdb_test "shell diff $pi_txt $copy1_txt" \
+    "diff: .*copy1.txt: No such file or directory" \
     "delete copy1"
 
 delete_breakpoints
@@ -370,4 +372,4 @@ verbose "Timeout now $timeout sec."
 # Finished: cleanup
 #
 
-remote_exec build "rm -f pi.txt"
+remote_exec host "rm -f $pi_txt"
-- 
1.8.1.4

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

* [PATCH v2 02/17] fix some simple thinkos in the test suite
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (3 preceding siblings ...)
  2013-10-18 20:49 ` [PATCH v2 03/17] fix weird.exp for parallel testing Tom Tromey
@ 2013-10-18 20:49 ` Tom Tromey
  2013-10-18 20:49 ` [PATCH v2 01/17] fix up log-file toggling Tom Tromey
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 20:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes some parallelization thinkos from a while ago.  I'm not
sure how the problems ever slipped through.  In addition to a thinko
fix in twice.exp, this also finishes fixing it up for parallelization.

	* gdb.base/gcore-buffer-overflow.exp: Use
	standard_output_file, not standard_testfile.
	* gdb.base/twice.exp: Use standard_testfile, not
	standard_output_file.  Use gdb_remote_download.
---
 gdb/testsuite/gdb.base/gcore-buffer-overflow.exp | 3 ++-
 gdb/testsuite/gdb.base/twice.exp                 | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
index 8d0867e..47dccf9 100644
--- a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
+++ b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
@@ -51,4 +51,5 @@ if { ! [ runto_main ] } then {
     return -1
 }
 
-gdb_gcore_cmd [standard_testfile gcore-buffer-overflow.test] "save a corefile"
+gdb_gcore_cmd [standard_output_file gcore-buffer-overflow.test] \
+    "save a corefile"
diff --git a/gdb/testsuite/gdb.base/twice.exp b/gdb/testsuite/gdb.base/twice.exp
index 936ddcb..9e7e334 100644
--- a/gdb/testsuite/gdb.base/twice.exp
+++ b/gdb/testsuite/gdb.base/twice.exp
@@ -14,7 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-standard_output_file twice.c
+standard_testfile twice.c
 set options debug
 lappend options "additional_flags=-I."
 
@@ -23,7 +23,7 @@ set fileid [open $local_srcfile w]
 puts $fileid "#include \"twice.c\""
 close $fileid
 
-remote_download host ${srcdir}/${subdir}/twice.c twice.c
+gdb_remote_download host ${srcdir}/${subdir}/twice.c
 
 if  { [gdb_compile $local_srcfile "${binfile}" executable $options] != "" } {
      untested twice.exp
-- 
1.8.1.4

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

* [PATCH v2 07/17] fix up gdb.trace
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
  2013-10-18 20:49 ` [PATCH v2 06/17] fix up gdb.mi Tom Tromey
  2013-10-18 20:49 ` [PATCH v2 12/17] fix up gdb.server Tom Tromey
@ 2013-10-18 20:49 ` Tom Tromey
  2013-10-25 16:22   ` Pedro Alves
  2013-10-18 20:49 ` [PATCH v2 03/17] fix weird.exp for parallel testing Tom Tromey
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 20:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes gdb.trace to be parallel-safe.

	* gdb.trace/mi-traceframe-changed.exp: Pass -DTFILE_DIR
	to compilation.  Use standard_output_file.
	(test_tfind_tfile): Update.
	* gdb.trace/tfile.c (write_basic_trace_file)
	(write_error_trace_file): Use TFILE_DIR.
	* gdb.trace/tfile.exp: Pass -DTFILE_DIR to compilation.  Use
	standard_output_file.
---
 gdb/testsuite/gdb.trace/mi-traceframe-changed.exp | 31 ++++++++++----
 gdb/testsuite/gdb.trace/tfile.c                   |  4 +-
 gdb/testsuite/gdb.trace/tfile.exp                 | 51 ++++++++++++++++-------
 3 files changed, 61 insertions(+), 25 deletions(-)

diff --git a/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp b/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
index 21e11d5..413e5c4 100644
--- a/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
@@ -20,32 +20,49 @@ set MIFLAGS "-i=mi"
 standard_testfile tfile.c
 set executable $testfile
 
+if {![is_remote host] && ![is_remote target]} {
+    set tfile_basic [standard_output_file tfile-basic.tf]
+    set tfile_dir [file dirname $tfile_basic]/
+    set purely_local 1
+} else {
+    set purely_local 0
+    set tfile_basic tfile-basic.tf
+    set tfile_dir ""
+}
+
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
-	   executable {debug nowarnings}] != "" } {
+	   executable \
+	   [list debug nowarnings \
+		"additional_flags=-DTFILE_DIR=\"$tfile_dir\""]] \
+	  != "" } {
      untested ${testfile}.exp
      return -1
 }
 
 # Make sure we are starting fresh.
-remote_file host delete tfile-basic.tf
-remote_file target delete tfile-basic.tf
+remote_file host delete $tfile_basic
+remote_file target delete $tfile_basic
 
 remote_exec target "$binfile"
-# Copy tracefile from target to host.
-remote_download host [remote_upload target tfile-basic.tf] \
-    tfile-basic.tf
+
+if {!$purely_local} {
+    # Copy tracefile from target to host.
+    remote_download host [remote_upload target tfile-basic.tf] \
+	tfile-basic.tf
+}
 
 proc test_tfind_tfile { } {
     with_test_prefix "tfile" {
 	global binfile
 	global decimal
+	global tfile_basic
 
 	if [mi_gdb_start] {
 	    return
 	}
 	mi_gdb_load ${binfile}
 
-	mi_gdb_test "-target-select tfile tfile-basic.tf" \
+	mi_gdb_test "-target-select tfile ${tfile_basic}" \
 	    ".*=breakpoint-created,bkpt=\{number=\"${decimal}\",type=\"tracepoint\",disp=\"keep\",enabled=\"y\",.*,func=\"write_basic_trace_file\".*\\^connected" \
 	    "select trace file"
 
diff --git a/gdb/testsuite/gdb.trace/tfile.c b/gdb/testsuite/gdb.trace/tfile.c
index 7020744..3610086 100644
--- a/gdb/testsuite/gdb.trace/tfile.c
+++ b/gdb/testsuite/gdb.trace/tfile.c
@@ -92,7 +92,7 @@ write_basic_trace_file (void)
   int fd, int_x;
   short short_x;
 
-  fd = start_trace_file ("tfile-basic.tf");
+  fd = start_trace_file (TFILE_DIR "tfile-basic.tf");
 
   /* The next part of the file consists of newline-separated lines
      defining status, tracepoints, etc.  The section is terminated by
@@ -177,7 +177,7 @@ write_error_trace_file (void)
   int len = sizeof (made_up) - 1;
   char *hex = alloca (len * 2 + 1);
 
-  fd = start_trace_file ("tfile-error.tf");
+  fd = start_trace_file (TFILE_DIR "tfile-error.tf");
 
   /* The next part of the file consists of newline-separated lines
      defining status, tracepoints, etc.  The section is terminated by
diff --git a/gdb/testsuite/gdb.trace/tfile.exp b/gdb/testsuite/gdb.trace/tfile.exp
index b4a7460..0255bca 100644
--- a/gdb/testsuite/gdb.trace/tfile.exp
+++ b/gdb/testsuite/gdb.trace/tfile.exp
@@ -22,33 +22,50 @@
 
 load_lib "trace-support.exp"
 
+if {![is_remote host] && ![is_remote target]} {
+    set tfile_basic [standard_output_file tfile-basic.tf]
+    set tfile_error [standard_output_file tfile-error.tf]
+    set tfile_dir [file dirname $tfile_basic]/
+    set purely_local 1
+} else {
+    set tfile_basic tfile-basic.tf
+    set tfile_error tfile-error.tf
+    set purely_local 0
+    set tfile_dir ""
+}
+
 gdb_exit
 gdb_start
 standard_testfile
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
-	  executable {debug nowarnings}] != "" } {
+	  executable \
+	  [list debug nowarnings \
+	       "additional_flags=-DTFILE_DIR=\"$tfile_dir\""]] \
+	 != "" } {
     untested ${testfile}.exp
     return -1
 }
 gdb_reinitialize_dir $srcdir/$subdir
 
 # Make sure we are starting fresh.
-remote_file host delete tfile-basic.tf
-remote_file host delete tfile-error.tf
-remote_file target delete tfile-basic.tf
-remote_file target delete tfile-error.tf
+remote_file host delete $tfile_basic
+remote_file host delete $tfile_error
+remote_file target delete $tfile_basic
+remote_file target delete $tfile_error
 
 remote_exec target "$binfile"
-# Copy tracefile from target to host through build.
-remote_download host [remote_upload target tfile-basic.tf] tfile-basic.tf
-remote_download host [remote_upload target tfile-error.tf] tfile-error.tf
+if {!$purely_local} {
+    # Copy tracefile from target to host through build.
+    remote_download host [remote_upload target tfile-basic.tf] tfile-basic.tf
+    remote_download host [remote_upload target tfile-error.tf] tfile-error.tf
+}
 
 gdb_load $binfile
 
 # Program has presumably exited, now target a trace file it created.
 
-gdb_test "target tfile tfile-basic.tf" "Created tracepoint.*" \
-    "target tfile"
+gdb_test "target tfile $tfile_basic" "Created tracepoint.*" \
+    "target tfile [file tail $tfile_basic]"
 
 gdb_test "info trace" ".*tracepoint.*in write_basic_trace_file.*" \
     "info tracepoints on trace file"
@@ -108,8 +125,8 @@ gdb_start
 
 gdb_load $binfile
 
-gdb_test "target tfile tfile-error.tf" "Created tracepoint.*" \
-    "target tfile"
+gdb_test "target tfile $tfile_error" "Created tracepoint.*" \
+    "target tfile [file tail $tfile_error]"
 
 gdb_test "tstatus" \
     "Using a trace file.*
@@ -124,14 +141,16 @@ gdb_test "info inferiors" "\\* 1    <null>\[ \t\]+${binfile}.*"
 
 # Make sure we can reopen without error.
 gdb_test \
-    "interpreter-exec mi \"-target-select tfile tfile-basic.tf\"" \
-    "\\^connected.*"
+    "interpreter-exec mi \"-target-select tfile $tfile_basic\"" \
+    "\\^connected.*" \
+    "interpreter-exec mi \"-target-select tfile tfile-basic.tf\""
 
 gdb_test "interpreter-exec mi \"-trace-status\"" \
-    "\\^done,supported=\"file\",trace-file=\".*tfile-basic.tf\",running=\"0\",stop-reason=\"request\",frames=\"${decimal}\",frames-created=\"${decimal}\",buffer-size=\"${decimal}\",buffer-free=\"${decimal}\",disconnected=\".*\",circular=\".*\",user-name=\"\",notes=\"\",start-time=\".*\",stop-time=\".*\"" \
+    "\\^done,supported=\"file\",trace-file=\".*$tfile_basic\",running=\"0\",stop-reason=\"request\",frames=\"${decimal}\",frames-created=\"${decimal}\",buffer-size=\"${decimal}\",buffer-free=\"${decimal}\",disconnected=\".*\",circular=\".*\",user-name=\"\",notes=\"\",start-time=\".*\",stop-time=\".*\"" \
     "-trace-status"
 
 # Test completion works well.
 
-gdb_test "target tfile tfile-basic\t" "Assuming tracepoint.*" \
+gdb_test "target tfile [file rootname $tfile_basic]\t" \
+    "Assuming tracepoint.*" \
     "complete-command 'target tfile'"
-- 
1.8.1.4

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

* [PATCH v2 00/17] test suite parallel safety
@ 2013-10-18 20:49 Tom Tromey
  2013-10-18 20:49 ` [PATCH v2 06/17] fix up gdb.mi Tom Tromey
                   ` (17 more replies)
  0 siblings, 18 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 20:49 UTC (permalink / raw)
  To: gdb-patches

This is a refresh of my test suite parallel safety series.

You can see the original thread here:

    https://sourceware.org/ml/gdb-patches/2013-08/msg00696.html

This resubmission also rolls in the patch to turn on parallel mode,
originally submitted separately:

    https://sourceware.org/ml/gdb-patches/2013-08/msg00844.html

I believe this series addresses all the comments from the previous
one.

After rebasing, there were a few tests that started failing in
parallel mode.  I've amended this series with a few patches (patches
14-16) to fix these.

Built and regtested on x86-64 Fedora 18 in both parallel and
"traditional" modes.

Let me know what you think.

Tom


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

* [PATCH v2 12/17] fix up gdb.server
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
  2013-10-18 20:49 ` [PATCH v2 06/17] fix up gdb.mi Tom Tromey
@ 2013-10-18 20:49 ` Tom Tromey
  2013-10-18 20:49 ` [PATCH v2 07/17] fix up gdb.trace Tom Tromey
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 20:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes gdb.server to be parallel-safe.

	* gdb.server/file-transfer.exp: Use standard_output_file.
---
 gdb/testsuite/gdb.server/file-transfer.exp | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/gdb.server/file-transfer.exp b/gdb/testsuite/gdb.server/file-transfer.exp
index aa56380..841d757 100644
--- a/gdb/testsuite/gdb.server/file-transfer.exp
+++ b/gdb/testsuite/gdb.server/file-transfer.exp
@@ -35,15 +35,22 @@ gdb_test "disconnect" ".*"
 gdbserver_run ""
 
 proc test_file_transfer { filename description } {
-    gdb_test "remote put \"$filename\" down-server" \
+    set up_server up-server
+    set down_server down-server
+    if {![is_remote host] && ![is_remote target]} {
+	set up_server [standard_output_file $up_server]
+	set down_server [standard_output_file $down_server]
+    }
+
+    gdb_test "remote put \"$filename\" $down_server" \
 	"Successfully sent .*" "put $description"
-    gdb_test "remote get down-server up-server" \
+    gdb_test "remote get $down_server $up_server" \
 	"Successfully fetched .*" "get $description"
 
     if { ![is_remote target] } {
 	# If we can check the target copy of the file, do that too.
 	# This should catch symmetric errors in upload and download.
-	set result [remote_exec host "cmp -s $filename down-server"]
+	set result [remote_exec host "cmp -s $filename $down_server"]
 	if { [lindex $result 0] == 0 } {
 	    pass "compare intermediate $description"
 	} else {
@@ -51,25 +58,25 @@ proc test_file_transfer { filename description } {
 	}
     }
 
-    set result [remote_exec host "cmp -s $filename up-server"]
+    set result [remote_exec host "cmp -s $filename $up_server"]
     if { [lindex $result 0] == 0 } {
 	pass "compare $description"
     } else {
 	fail "compare $description"
     }
 
-    gdb_test "remote delete down-server" \
+    gdb_test "remote delete $down_server" \
 	"Successfully deleted .*" "deleted $description"
 
     if { ![is_remote target] } {
-	if { ! [remote_file target exists down-server] } {
+	if { ! [remote_file target exists $down_server] } {
 	    pass "verified deleted $description"
 	} else {
 	    fail "verified deleted $description"
 	}
     }
 
-    catch { file delete up-server }
+    catch { file delete $up_server }
 }
 
 test_file_transfer "$binfile" "binary file"
-- 
1.8.1.4

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

* [PATCH v2 14/17] fix argv0-symlink.exp for parallel mode
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (8 preceding siblings ...)
  2013-10-18 20:49 ` [PATCH v2 09/17] update checkpoint test Tom Tromey
@ 2013-10-18 21:00 ` Tom Tromey
  2013-10-18 21:00 ` [PATCH v2 11/17] introduce relative_filename and use it Tom Tromey
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 21:00 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

argv0-symlink.exp doesn't work properly if standard_output_file puts
files into a per-test subdirectory.  That's because it assumes that
files appear in $subdir, which is no longer true.

This patch fixes the problem by computing the correct directory at
runtime.

Tested both with and without GDB_PARALLEL on x86-64 Fedora 18.

	* gdb.base/argv0-symlink.exp: Compute executable's directory
	dynamically.
---
 gdb/testsuite/gdb.base/argv0-symlink.exp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/argv0-symlink.exp b/gdb/testsuite/gdb.base/argv0-symlink.exp
index cf5785c..e4efe19 100644
--- a/gdb/testsuite/gdb.base/argv0-symlink.exp
+++ b/gdb/testsuite/gdb.base/argv0-symlink.exp
@@ -37,7 +37,14 @@ if ![runto_main] {
 }
 
 gdb_test {print argv[0]} "/$filelink\"" $test
-gdb_test "info inferiors" "/$subdir/$filelink *" "$test for info inferiors"
+
+# For a link named /PATH/TO/DIR/LINK, we want to check the output
+# against "/DIR/LINK", but computed in a way that doesn't make
+# assumptions about the test directory layout.
+set full_filelink [standard_output_file $filelink]
+set lastdir [file tail [file dirname $full_filelink]]
+
+gdb_test "info inferiors" "/$lastdir/$filelink *" "$test for info inferiors"
 
 
 set test "kept directory symbolic link name"
@@ -65,4 +72,4 @@ if ![is_remote target] {
     setup_kfail "*-*-*" gdb/15934
 }
 gdb_test {print argv[0]} "/$dirlink/$filelink\"" $test
-gdb_test "info inferiors" "/$subdir/$filelink *" "$test for info inferiors"
+gdb_test "info inferiors" "/$lastdir/$filelink *" "$test for info inferiors"
-- 
1.8.1.4

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

* [PATCH v2 11/17] introduce relative_filename and use it
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (9 preceding siblings ...)
  2013-10-18 21:00 ` [PATCH v2 14/17] fix argv0-symlink.exp for parallel mode Tom Tromey
@ 2013-10-18 21:00 ` Tom Tromey
  2013-10-25 16:22   ` Pedro Alves
  2013-10-28 19:01   ` Doug Evans
  2013-10-18 21:11 ` [PATCH v2 17/17] switch to fully parallel mode Tom Tromey
                   ` (6 subsequent siblings)
  17 siblings, 2 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 21:00 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces a new relative_filename proc to gdb.exp and changes
some tests to use it.  This helps make these tests parallel-safe.

	* gdb.base/fullname.exp: Use standard_output_file,
	relative_filename.
	* gdb.base/hashline1.exp: Use standard_testfile,
	standard_output_file, relative_filename, clean_restart.
	* gdb.base/hashline2.exp: Use standard_testfile,
	standard_output_file, relative_filename.
	* gdb.base/hashline3.exp: Use standard_testfile,
	standard_output_file, relative_filename.
	* lib/gdb.exp (relative_filename): New proc.
---
 gdb/testsuite/gdb.base/fullname.exp  |  5 +++--
 gdb/testsuite/gdb.base/hashline1.exp | 21 +++++++++------------
 gdb/testsuite/gdb.base/hashline2.exp | 13 ++++++-------
 gdb/testsuite/gdb.base/hashline3.exp | 14 +++++++-------
 gdb/testsuite/lib/gdb.exp            | 15 +++++++++++++++
 5 files changed, 40 insertions(+), 28 deletions(-)

diff --git a/gdb/testsuite/gdb.base/fullname.exp b/gdb/testsuite/gdb.base/fullname.exp
index 32f6ea4..2754f59 100644
--- a/gdb/testsuite/gdb.base/fullname.exp
+++ b/gdb/testsuite/gdb.base/fullname.exp
@@ -70,7 +70,8 @@ if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}]
 }
 
 # Build the test executable using a relative path.
-if  { [gdb_compile "${subdir}/tmp-${srcfile}" "${binfile}" executable {debug}] != "" } {
+if  { [gdb_compile [relative_filename [pwd] [standard_output_file tmp-${srcfile}]] \
+	   "${binfile}" executable {debug}] != "" } {
     return -1
 }
 
@@ -99,7 +100,7 @@ if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}]
 # we'll run GDB from.
 
 set save_pwd [pwd]
-cd ${subdir}
+cd [standard_output_file {}]
 if  { [gdb_compile [standard_output_file tmp-${srcfile}] "${testfile}" \
 	   executable {debug}] != "" } {
     cd $save_pwd
diff --git a/gdb/testsuite/gdb.base/hashline1.exp b/gdb/testsuite/gdb.base/hashline1.exp
index 950d67e..2330daf 100644
--- a/gdb/testsuite/gdb.base/hashline1.exp
+++ b/gdb/testsuite/gdb.base/hashline1.exp
@@ -21,28 +21,25 @@
 # srcfile is in objdir because we need to machine generate it in order
 # to get the correct path in the #line directive.
 
-set testfile "hashline1"
-set srcfile "${testfile}.c"
-set binfile "${objdir}/${subdir}/${testfile}"
+standard_testfile .c
 
-set fd [open ${objdir}/${subdir}/${srcfile} w]
-puts $fd "#line 2 \"[pwd]/${subdir}/${srcfile}\""
+set new_srcfile [standard_output_file $srcfile]
+set fd [open $new_srcfile w]
+puts $fd "#line 2 \"$new_srcfile\""
 puts $fd "int main () { return 0; } /* set breakpoint here */"
 close $fd
 
 # The choice of path name for the source file is important in order to trigger
-# the bug.  Using ${objdir}/${subdir}/${srcfile} here won't trigger the bug.
-if { [gdb_compile "./${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+# the bug.  Using $new_srcfile here won't trigger the bug.
+set compile_name [relative_filename $objdir $new_srcfile]
+if { [gdb_compile $compile_name "${binfile}" executable {debug}] != "" } {
     untested hashline1.exp
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
-set bp_location [gdb_get_line_number "set breakpoint here" ${objdir}/${subdir}/${srcfile}]
+set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile]
 
 # Try to set a breakpoint on the specified file location.
 
diff --git a/gdb/testsuite/gdb.base/hashline2.exp b/gdb/testsuite/gdb.base/hashline2.exp
index d7ee4a7..cd748ca 100644
--- a/gdb/testsuite/gdb.base/hashline2.exp
+++ b/gdb/testsuite/gdb.base/hashline2.exp
@@ -21,16 +21,15 @@
 # srcfile is in objdir because we need to machine generate it in order
 # to get the correct path in the #line directive.
 
-set testfile "hashline2"
-set srcfile "${testfile}.c"
-set binfile "${objdir}/${subdir}/${testfile}"
+standard_testfile .c
 
-set fd [open ${objdir}/${subdir}/${srcfile} w]
-puts $fd "#line 2 \"///[pwd]/${subdir}/${srcfile}\""
+set new_srcfile [standard_output_file $srcfile]
+set fd [open $new_srcfile w]
+puts $fd "#line 2 \"///${new_srcfile}\""
 puts $fd "int main () { return 0; } /* set breakpoint here */"
 close $fd
 
-if { [gdb_compile "${objdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } {
     untested hashline2.exp
     return -1
 }
@@ -40,7 +39,7 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
-set bp_location [gdb_get_line_number "set breakpoint here" ${objdir}/${subdir}/${srcfile}]
+set bp_location [gdb_get_line_number "set breakpoint here" ${new_srcfile}]
 
 # Try to set a breakpoint on the specified file location.
 
diff --git a/gdb/testsuite/gdb.base/hashline3.exp b/gdb/testsuite/gdb.base/hashline3.exp
index 2496b3c..eba5f77 100644
--- a/gdb/testsuite/gdb.base/hashline3.exp
+++ b/gdb/testsuite/gdb.base/hashline3.exp
@@ -21,16 +21,16 @@
 # srcfile is in objdir because we need to machine generate it in order
 # to get the correct path in the #line directive.
 
-set testfile "hashline3"
-set srcfile "${testfile}.c"
-set binfile "${objdir}/${subdir}/${testfile}"
+standard_testfile
 
-set fd [open ${objdir}/${subdir}/${srcfile} w]
-puts $fd "#line 2 \"./${subdir}/${srcfile}\""
+set new_srcfile [standard_output_file $srcfile]
+set fd [open $new_srcfile w]
+set relative [relative_filename $objdir $new_srcfile]
+puts $fd "#line 2 \"./$relative\""
 puts $fd "int main () { return 0; } /* set breakpoint here */"
 close $fd
 
-if { [gdb_compile "${objdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } {
     untested hashline3.exp
     return -1
 }
@@ -40,7 +40,7 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
-set bp_location [gdb_get_line_number "set breakpoint here" ${objdir}/${subdir}/${srcfile}]
+set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile]
 
 # Try to set a breakpoint on the specified file location.
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index fbb9f71..a1c18b7 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4320,6 +4320,21 @@ proc set_remotetimeout { timeout } {
     }
 }
 
+# ROOT and FULL are file names.  Returns the relative path from ROOT
+# to FULL.  Note that FULL must be in a subdirectory of ROOT.
+# For example, given ROOT = /usr/bin and FULL = /usr/bin/ls, this
+# will return "ls".
+
+proc relative_filename {root full} {
+    if {[string compare [string range $full 0 \
+			     [expr {[string length $root] - 1}]] $root] != 0} {
+	error "$full not a subdir of $root"
+    }
+
+    set len [llength [file split $root]]
+    return [eval file join [lrange [file split $full] $len end]]
+}
+
 # Log gdb command line and script if requested.
 if {[info exists TRANSCRIPT]} {
   rename send_gdb real_send_gdb
-- 
1.8.1.4

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

* [PATCH v2 17/17] switch to fully parallel mode
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (10 preceding siblings ...)
  2013-10-18 21:00 ` [PATCH v2 11/17] introduce relative_filename and use it Tom Tromey
@ 2013-10-18 21:11 ` Tom Tromey
  2013-10-18 21:24 ` [PATCH v2 10/17] update fileio test Tom Tromey
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 21:11 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This switches "make check" to fully parallel mode.

One primary issue facing full parallelization is the overhead of
"runtest".  On my machine, if I "touch gdb.base/empty.exp", making a
new file, and then "time runtest.exp", it takes 0.08 seconds.

Multiply this by the 1008 (in my configuration) tests and you get ~80
seconds.  This is the overhead that would theoretically be present if
all tests were run in parallel.

However, the problem isn't nearly as bad as this, for two reasons.

First, you must divide by the number of jobs, assuming perfect
parallelization -- reasonably true for small -j numbers, based on the
results I see.

Second, the current test suite parallelization approach bundles the
tests, largely by directory, but also splitting up gdb.base into two
halves.

I was curious to see how the current bundling played out in practice,
so I ran "make -j1 check RUNTEST='/bin/time runtest'".  This invokes
the parallel mode (thus the bundling) and then shows the time taken by
each invocation of runtest.

Then, I ran "/bin/time make -j3 check".  (See below about -j2.)

The time for the entire -j3 test run was the same as the time for
"gdb.base1".  What this means is that gdb.base1 is currently the
time-limiting run, preventing further parallelization gains.

So, I reason, whatever overhead we see from full parallelization will
only be seen by "-j1" and "-j2".

I then tried a -j2 test run.  This does take longer than a -j3 build,
meaning that the gdb.base1 job finishes and then proceeds to other
runtest invocations.

Finally I tried a -j2 test run with the appended patch.
This was 9% slower than the -j2 run without the patch.

I think that is a reasonable slowdown for what is probably a rare
case.  I believe this patch will yield faster test results for all -j
values greater than 2.  For -j3 on my machine, the test suite is a few
seconds faster; I didn't try any larger -j values.

For -j1, I went ahead and changed the Makefile so that, if no -j
option is given, then the "check-single" mode is used.  You can still
use "make -j1 check" to get single-job parallel-mode, though of course
there's no good reason to do so.

This change is likely to speed up the plain "make check" scenario a
little as we will now bypass dg-extract-results.sh.

One drawback of this change is that "make -jN check" is now much more
verbose.  I generally only look at the .sum and .log files, but
perhaps this will bother some.

Another interesting question is scalability of the result.  The
slowest test, which limits the scalability, took 80.78 seconds.  The
mean of the remaining tests is 1.08 seconds.  (Note that this is just
a rough estimate, since there are still outliers.)

This means we can run 80.78 / 1.08 =~ 74 tests in the time available.
And, in this data set (slightly older than the above, but materially
the same) there were 948 tests.  So, I think the current test suite
should scale ok up to about -j12.

We could improve this number if need be by breaking up the biggest
tests.

	* Makefile.in (TEST_DIRS): Remove.
	(TEST_TARGETS, check-parallel): Rewrite.
	(check-gdb.%, BASE1_FILES, BASE2_FILES, check-gdb.base%)
	(subdir_do, subdirs): Remove.
	(do-check-parallel, check/%): New targets.
	(clean): Remove outputs, temp, and cache directories.
	(saw_dash_j): New variable.
	(CHECK_TARGET): Use it.
	(check): Depend on all, site.exp.  Rewrite.
	(check-single): Remove dependencies.
	(slow_tests, all_tests, reordered_tests): New variables.
---
 gdb/testsuite/Makefile.in | 100 +++++++++++++++++++---------------------------
 1 file changed, 42 insertions(+), 58 deletions(-)

diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in
index a7b3d5c..46dac13 100644
--- a/gdb/testsuite/Makefile.in
+++ b/gdb/testsuite/Makefile.in
@@ -128,14 +128,23 @@ $(abs_builddir)/site.exp site.exp: ./config.status Makefile
 
 installcheck:
 
-# For GNU make, try to run the tests in parallel.  If RUNTESTFLAGS is
-# not empty, then by default the tests will be serialized.  This can
-# be overridden by setting FORCE_PARALLEL to any non-empty value.
-# For a non-GNU make, do not parallelize.
-@GMAKE_TRUE@CHECK_TARGET = $(if $(FORCE_PARALLEL),check-parallel,$(if $(RUNTESTFLAGS),check-single,check-parallel))
+# See whether -j was given to make.  Either it was given with no
+# arguments, and appears as "j" in the first word, or it was given an
+# argument and appears as "-j" in a separate word.
+@GMAKE_TRUE@saw_dash_j = $(or $(findstring j,$(firstword $(MAKEFLAGS))),$(filter -j,$(MAKEFLAGS)))
+
+# For GNU make, try to run the tests in parallel if any -j option is
+# given.  If RUNTESTFLAGS is not empty, then by default the tests will
+# be serialized.  This can be overridden by setting FORCE_PARALLEL to
+# any non-empty value.  For a non-GNU make, do not parallelize.
+@GMAKE_TRUE@CHECK_TARGET = $(if $(FORCE_PARALLEL),check-parallel,$(if $(RUNTESTFLAGS),check-single,$(if $(saw_dash_j),check-parallel,check-single)))
 @GMAKE_FALSE@CHECK_TARGET = check-single
 
-check: $(CHECK_TARGET)
+# Note that we must resort to a recursive make invocation here,
+# because GNU make 3.82 has a bug preventing MAKEFLAGS from being used
+# in conditions.
+check: all $(abs_builddir)/site.exp
+	$(MAKE) $(CHECK_TARGET)
 
 # All the hair to invoke dejagnu.  A given invocation can just append
 # $(RUNTESTFLAGS)
@@ -151,70 +160,45 @@ DO_RUNTEST = \
 	  export TCL_LIBRARY ; fi ; \
 	$(RUNTEST)
 
-check-single: all $(abs_builddir)/site.exp
+check-single:
 	$(DO_RUNTEST) $(RUNTESTFLAGS)
 
-# A list of all directories named "gdb.*" which also hold a .exp file.
-# We filter out gdb.base and add fake entries, because that directory
-# takes the longest to process, and so we split it in half.
-TEST_DIRS = gdb.base1 gdb.base2 $(filter-out gdb.base,$(sort $(notdir $(patsubst %/,%,$(dir $(wildcard $(srcdir)/gdb.*/*.exp))))))
-
-TEST_TARGETS = $(addprefix check-,$(TEST_DIRS))
-
-# We explicitly re-invoke make here for two reasons.  First, it lets
-# us add a -k option, which makes the parallel check mimic the
-# behavior of the serial check; and second, it means that we can still
-# regenerate the sum and log files even if a sub-make fails -- which
-# it usually does because dejagnu exits with an error if any test
-# fails.
 check-parallel:
-	$(MAKE) -k $(TEST_TARGETS); \
+	-rm -rf cache
+	$(MAKE) -k do-check-parallel; \
 	$(SHELL) $(srcdir)/dg-extract-results.sh \
-	  $(addsuffix /gdb.sum,$(TEST_DIRS)) > gdb.sum; \
+	  `find outputs -name gdb.sum -print` > gdb.sum; \
 	$(SHELL) $(srcdir)/dg-extract-results.sh -L \
-	  $(addsuffix /gdb.log,$(TEST_DIRS)) > gdb.log
-
-@GMAKE_TRUE@$(filter-out check-gdb.base%,$(TEST_TARGETS)): check-gdb.%: all $(abs_builddir)/site.exp
-@GMAKE_TRUE@	@if test ! -d gdb.$*; then mkdir gdb.$*; fi
-@GMAKE_TRUE@	$(DO_RUNTEST) --directory=gdb.$* --outdir=gdb.$* $(RUNTESTFLAGS)
-
-# Each half (roughly) of the .exp files from gdb.base.
-BASE1_FILES = $(patsubst $(srcdir)/%,%,$(wildcard $(srcdir)/gdb.base/[a-m]*.exp))
-BASE2_FILES = $(patsubst $(srcdir)/%,%,$(wildcard $(srcdir)/gdb.base/[n-z]*.exp))
-
-# Handle each half of gdb.base.
-check-gdb.base%: all $(abs_builddir)/site.exp
-	@if test ! -d gdb.base$*; then mkdir gdb.base$*; fi
-	$(DO_RUNTEST) $(BASE$*_FILES) --outdir gdb.base$* $(RUNTESTFLAGS)
-
-subdir_do: force
-	@for i in $(DODIRS); do \
-		if [ -d ./$$i ] ; then \
-			if (rootme=`pwd`/ ; export rootme ; \
-			    rootsrc=`cd $(srcdir); pwd`/ ; export rootsrc ; \
-				cd ./$$i; \
-				$(MAKE) $(TARGET_FLAGS_TO_PASS) $(DO)) ; then true ; \
-			else exit 1 ; fi ; \
-		else true ; fi ; \
-	done
+	  `find outputs -name gdb.log -print` > gdb.log
+
+# Turn a list of .exp files into "check/" targets.  Only examine .exp
+# files appearing in a gdb.* directory -- we don't want to pick up
+# lib/ by mistake.  For example, gdb.linespec/linespec.exp becomes
+# check/gdb.linespec/linespec.exp.  The list is generally sorted
+# alphabetically, but we take a few tests known to be slow and push
+# them to the front of the list to try to lessen the overall time
+# taken by the test suite -- if one of these tests happens to be run
+# late, it will cause the overall time to increase.
+slow_tests = gdb.base/break-interp.exp gdb.base/interp.exp \
+	gdb.base/multi-forks.exp
+@GMAKE_TRUE@all_tests := $(shell cd $(srcdir) && find gdb.* -name '*.exp' -print)
+@GMAKE_TRUE@reordered_tests := $(slow_tests) $(filter-out $(slow_tests),$(all_tests))
+@GMAKE_TRUE@TEST_TARGETS := $(addprefix check/,$(reordered_tests))
+
+do-check-parallel: $(TEST_TARGETS)
+	@:
+
+@GMAKE_TRUE@check/%.exp:
+@GMAKE_TRUE@	-mkdir -p outputs/$*
+@GMAKE_TRUE@	@$(DO_RUNTEST) GDB_PARALLEL=yes --outdir=outputs/$* $*.exp $(RUNTESTFLAGS)
 
 force:;
 
-subdirs:
-	for dir in ${ALL_SUBDIRS} ; \
-	do \
-		echo "$$dir:" ; \
-		if [ -d $$dir ] ; then \
-			(rootme=`pwd`/ ; export rootme ; \
-			 rootsrc=`cd $(srcdir); pwd`/ ; export rootsrc ; \
-			 cd $$dir; $(MAKE) $(TARGET_FLAGS_TO_PASS)); \
-		fi; \
-	done
-
 clean mostlyclean:
 	-rm -f *~ core *.o a.out xgdb *.x *.grt bigcore.corefile .gdb_history
 	-rm -f core.* *.tf *.cl *.py tracecommandsscript copy1.txt zzz-gdbscript
 	-rm -f *.dwo *.dwp
+	-rm -rf outputs temp cache
 	if [ x"${ALL_SUBDIRS}" != x ] ; then \
 	    for dir in ${ALL_SUBDIRS}; \
 	    do \
-- 
1.8.1.4

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

* [PATCH v2 13/17] make gdb.asm parallel-safe
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (12 preceding siblings ...)
  2013-10-18 21:24 ` [PATCH v2 10/17] update fileio test Tom Tromey
@ 2013-10-18 21:24 ` Tom Tromey
  2013-10-18 21:36 ` [PATCH v2 04/17] fix up gdb.gdb Tom Tromey
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 21:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes gdb.asm to be parallel-safe.

	* gdb.asm/asm-source.exp: Use standard_output_file.
---
 gdb/testsuite/gdb.asm/asm-source.exp | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.asm/asm-source.exp b/gdb/testsuite/gdb.asm/asm-source.exp
index 5168452..511bd21 100644
--- a/gdb/testsuite/gdb.asm/asm-source.exp
+++ b/gdb/testsuite/gdb.asm/asm-source.exp
@@ -200,10 +200,13 @@ if [board_info $dest exists multilib_flags] {
 
 standard_testfile asmsrc1.s asmsrc2.s
 
-remote_exec build "rm -f ${subdir}/arch.inc"
-remote_download host ${srcdir}/${subdir}/${asm-arch}.inc ${subdir}/arch.inc
-remote_exec build "rm -f ${subdir}/note.inc"
-remote_download host ${srcdir}/${subdir}/${asm-note}.inc ${subdir}/note.inc
+set arch_inc [standard_output_file arch.inc]
+set note_inc [standard_output_file note.inc]
+
+remote_exec build "rm -f $arch_inc"
+remote_download host ${srcdir}/${subdir}/${asm-arch}.inc $arch_inc
+remote_exec build "rm -f $note_inc"
+remote_download host ${srcdir}/${subdir}/${asm-note}.inc $note_inc
 
 if { [string equal ${asm-flags} ""] } {
     set asm-flags "-I${srcdir}/${subdir} $obj_include"
@@ -467,5 +470,5 @@ test_dis "disassem &staticvar, &staticvar+1" "staticvar"
 gdb_test "disassem foostatic" ".*<\\+0>:.*End of assembler dump." \
 	"look at static function"
 
-remote_exec build "rm -f ${subdir}/arch.inc"
-remote_exec build "rm -f ${subdir}/note.inc"
+remote_exec build "rm -f $arch_inc"
+remote_exec build "rm -f $note_inc"
-- 
1.8.1.4

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

* [PATCH v2 10/17] update fileio test
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (11 preceding siblings ...)
  2013-10-18 21:11 ` [PATCH v2 17/17] switch to fully parallel mode Tom Tromey
@ 2013-10-18 21:24 ` Tom Tromey
  2013-10-18 21:24 ` [PATCH v2 13/17] make gdb.asm parallel-safe Tom Tromey
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 21:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This updates the fileio test to be parallel-safe.

	* gdb.base/fileio.c (test_open, test_write, test_read)
	(test_lseek, test_close, test_stat, test_fstat)
	(test_isatty, test_system, test_rename, test_unlink):
	Use OUTDIR define.
	* gdb.base/fileio.exp: Define OUTDIR during compilation.
	Use standard_output_file.
---
 gdb/testsuite/gdb.base/fileio.c   | 54 ++++++++++++++++++++-------------------
 gdb/testsuite/gdb.base/fileio.exp | 24 ++++++++++-------
 2 files changed, 43 insertions(+), 35 deletions(-)

diff --git a/gdb/testsuite/gdb.base/fileio.c b/gdb/testsuite/gdb.base/fileio.c
index 329522f..4926c05 100644
--- a/gdb/testsuite/gdb.base/fileio.c
+++ b/gdb/testsuite/gdb.base/fileio.c
@@ -58,6 +58,7 @@ system (const char * string);
 1) Invalid string/command. -  returns 127.  */
 static const char *strerrno (int err);
 
+/* Note that OUTDIR is defined by the test suite.  */
 #define FILENAME    "foo.fileio.test"
 #define RENAMED     "bar.fileio.test"
 #define NONEXISTANT "nofoo.fileio.test"
@@ -77,7 +78,7 @@ test_open ()
 
   /* Test opening */
   errno = 0;
-  ret = open (FILENAME, O_CREAT | O_TRUNC | O_RDWR, S_IWUSR | S_IRUSR);
+  ret = open (OUTDIR FILENAME, O_CREAT | O_TRUNC | O_RDWR, S_IWUSR | S_IRUSR);
   printf ("open 1: ret = %d, errno = %d %s\n", ret, errno,
 	  ret >= 0 ? "OK" : "");
   
@@ -86,7 +87,7 @@ test_open ()
   stop ();
   /* Creating an already existing file (created by fileio.exp) */
   errno = 0;
-  ret = open (FILENAME, O_CREAT | O_EXCL | O_WRONLY, S_IWUSR | S_IRUSR);
+  ret = open (OUTDIR FILENAME, O_CREAT | O_EXCL | O_WRONLY, S_IWUSR | S_IRUSR);
   printf ("open 2: ret = %d, errno = %d %s\n", ret, errno,
 	  strerrno (errno));
   if (ret >= 0)
@@ -110,13 +111,13 @@ test_open ()
   stop ();
   /* Open for write but no write permission */
   errno = 0;
-  ret = open (NOWRITE, O_CREAT | O_RDONLY, S_IRUSR);
+  ret = open (OUTDIR NOWRITE, O_CREAT | O_RDONLY, S_IRUSR);
   if (ret >= 0)
     {
       close (ret);
       stop ();
       errno = 0;
-      ret = open (NOWRITE, O_WRONLY);
+      ret = open (OUTDIR NOWRITE, O_WRONLY);
       printf ("open 5: ret = %d, errno = %d %s\n", ret, errno,
 	      strerrno (errno));
       if (ret >= 0)
@@ -137,7 +138,7 @@ test_write ()
 
   /* Test writing */
   errno = 0;
-  fd = open (FILENAME, O_WRONLY);
+  fd = open (OUTDIR FILENAME, O_WRONLY);
   if (fd >= 0)
     {
       errno = 0;
@@ -157,7 +158,7 @@ test_write ()
   stop ();
   /* Write to a read-only file */
   errno = 0;
-  fd = open (FILENAME, O_RDONLY);
+  fd = open (OUTDIR FILENAME, O_RDONLY);
   if (fd >= 0)
     {
       errno = 0;
@@ -178,7 +179,7 @@ test_read ()
 
   /* Test reading */
   errno = 0;
-  fd = open (FILENAME, O_RDONLY);
+  fd = open (OUTDIR FILENAME, O_RDONLY);
   if (fd >= 0)
     {
       memset (buf, 0, 16);
@@ -210,7 +211,7 @@ test_lseek ()
 
   /* Test seeking */
   errno = 0;
-  fd = open (FILENAME, O_RDONLY);
+  fd = open (OUTDIR FILENAME, O_RDONLY);
   if (fd >= 0)
     {
       errno = 0;
@@ -251,7 +252,7 @@ test_close ()
 
   /* Test close */
   errno = 0;
-  fd = open (FILENAME, O_RDONLY);
+  fd = open (OUTDIR FILENAME, O_RDONLY);
   if (fd >= 0)
     {
       errno = 0;
@@ -278,7 +279,7 @@ test_stat ()
 
   /* Test stat */
   errno = 0;
-  ret = stat (FILENAME, &st);
+  ret = stat (OUTDIR FILENAME, &st);
   if (!ret)
     printf ("stat 1: ret = %d, errno = %d %s\n", ret, errno,
 	    st.st_size == 11 ? "OK" : "");
@@ -313,7 +314,7 @@ test_fstat ()
 
   /* Test fstat */
   errno = 0;
-  fd = open (FILENAME, O_RDONLY);
+  fd = open (OUTDIR FILENAME, O_RDONLY);
   if (fd >= 0)
     {
       errno = 0;
@@ -352,7 +353,7 @@ test_isatty ()
   printf ("isatty 4: invalid %s\n", isatty (999) ? "yes" : "no OK");
   stop ();
   /* Check open file */
-  fd = open (FILENAME, O_RDONLY);
+  fd = open (OUTDIR FILENAME, O_RDONLY);
   if (fd >= 0)
     {
       printf ("isatty 5: file %s\n", isatty (fd) ? "yes" : "no OK");
@@ -364,6 +365,8 @@ test_isatty ()
 }
 
 
+char sys[1512];
+
 int
 test_system ()
 {
@@ -371,14 +374,13 @@ test_system ()
    * Requires test framework to switch on "set remote system-call-allowed 1"
    */
   int ret;
-  char sys[512];
 
   /* Test for shell */
   ret = system (NULL);
   printf ("system 1: ret = %d %s\n", ret, ret != 0 ? "OK" : "");
   stop ();
   /* This test prepares the directory for test_rename() */
-  sprintf (sys, "mkdir -p %s %s", TESTSUBDIR, TESTDIR2);
+  sprintf (sys, "mkdir -p %s/%s %s/%s", OUTDIR, TESTSUBDIR, OUTDIR, TESTDIR2);
   ret = system (sys);
   if (ret == 127)
     printf ("system 2: ret = %d /bin/sh unavailable???\n", ret);
@@ -399,7 +401,7 @@ test_rename ()
 
   /* Test rename */
   errno = 0;
-  ret = rename (FILENAME, RENAMED);
+  ret = rename (OUTDIR FILENAME, OUTDIR RENAMED);
   if (!ret)
     {
       errno = 0;
@@ -407,7 +409,7 @@ test_rename ()
       if (ret && errno == ENOENT)
         {
 	  errno = 0;
-	  ret = stat (RENAMED, &st);
+	  ret = stat (OUTDIR RENAMED, &st);
 	  printf ("rename 1: ret = %d, errno = %d %s\n", ret, errno,
 		  strerrno (errno));
 	  errno = 0;
@@ -420,50 +422,50 @@ test_rename ()
   stop ();
   /* newpath is existing directory, oldpath is not a directory */
   errno = 0;
-  ret = rename (RENAMED, TESTDIR2);
+  ret = rename (OUTDIR RENAMED, OUTDIR TESTDIR2);
   printf ("rename 2: ret = %d, errno = %d %s\n", ret, errno,
 	  strerrno (errno));
   stop ();
   /* newpath is a non-empty directory */
   errno = 0;
-  ret = rename (TESTDIR2, TESTDIR1);
+  ret = rename (OUTDIR TESTDIR2, OUTDIR TESTDIR1);
   printf ("rename 3: ret = %d, errno = %d %s\n", ret, errno,
           strerrno (errno));
   stop ();
   /* newpath is a subdirectory of old path */
   errno = 0;
-  ret = rename (TESTDIR1, TESTSUBDIR);
+  ret = rename (OUTDIR TESTDIR1, OUTDIR TESTSUBDIR);
   printf ("rename 4: ret = %d, errno = %d %s\n", ret, errno,
 	  strerrno (errno));
   stop ();
   /* oldpath does not exist */
   errno = 0;
-  ret = rename (NONEXISTANT, FILENAME);
+  ret = rename (OUTDIR NONEXISTANT, OUTDIR FILENAME);
   printf ("rename 5: ret = %d, errno = %d %s\n", ret, errno,
 	  strerrno (errno));
   stop ();
 }
 
+char name[1256];
+
 int
 test_unlink ()
 {
   int ret;
-  char name[256];
-  char sys[512];
 
   /* Test unlink */
   errno = 0;
-  ret = unlink (RENAMED);
+  ret = unlink (OUTDIR RENAMED);
   printf ("unlink 1: ret = %d, errno = %d %s\n", ret, errno,
 	  strerrno (errno));
   stop ();
   /* No write access */
-  sprintf (name, "%s/%s", TESTDIR2, FILENAME);
+  sprintf (name, "%s/%s/%s", OUTDIR, TESTDIR2, FILENAME);
   errno = 0;
   ret = open (name, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR);
   if (ret >= 0)
     {
-      sprintf (sys, "chmod -w %s", TESTDIR2);
+      sprintf (sys, "chmod -w %s/%s", OUTDIR, TESTDIR2);
       ret = system (sys);
       if (!ret)
         {
@@ -480,7 +482,7 @@ test_unlink ()
   stop ();
   /* pathname doesn't exist */
   errno = 0;
-  ret = unlink (NONEXISTANT);
+  ret = unlink (OUTDIR NONEXISTANT);
   printf ("unlink 3: ret = %d, errno = %d %s\n", ret, errno,
           strerrno (errno));
   stop ();
diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp
index ded043f..b9dfb38 100644
--- a/gdb/testsuite/gdb.base/fileio.exp
+++ b/gdb/testsuite/gdb.base/fileio.exp
@@ -23,7 +23,15 @@ if [target_info exists gdb,nofileio] {
 
 standard_testfile
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+if {[is_remote host]} {
+    set outdir .
+} else {
+    set outdir [standard_output_file {}]
+}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+	   executable \
+	   [list debug "additional_flags=-DOUTDIR=\"$outdir/\""]] != "" } {
     untested fileio.exp
     return -1
 }
@@ -35,8 +43,11 @@ if [get_compiler_info] {
     return -1
 }
 
-remote_exec build {sh -xc test\ -r\ dir2.fileio.test\ &&\ chmod\ -f\ +w\ dir2.fileio.test}
-remote_exec build {sh -xc rm\ -rf\ *.fileio.test}
+set dir2 [standard_output_file dir2.fileio.test]
+if {[file exists $dir2] && ![file writable $dir2]} {
+    system "chmod +w $dir2"
+}
+system "rm -rf [standard_output_file *.fileio.test]"
 
 set oldtimeout $timeout
 set timeout [expr "$timeout + 60"]
@@ -78,7 +89,7 @@ gdb_test continue \
 
 gdb_test "continue" ".*" ""
 
-catch "system \"chmod -f -w nowrt.fileio.test\""
+catch "system \"chmod -f -w [standard_output_file nowrt.fileio.test]\""
 
 gdb_test continue \
 "Continuing\\..*open 5:.*EACCES$stop_msg" \
@@ -241,11 +252,6 @@ gdb_test continue \
 "Time(2) returns feasible values"
 
 gdb_exit
-# Wait till GDB really exits.
-sleep 1
-
-remote_exec build {sh -xc test\ -r\ dir2.fileio.test\ &&\ chmod\ -f\ +w\ dir2.fileio.test}
-remote_exec build {sh -xc rm\ -rf\ *.fileio.test}
 
 set timeout $oldtimeout
 return 0
-- 
1.8.1.4

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

* [PATCH v2 04/17] fix up gdb.gdb
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (13 preceding siblings ...)
  2013-10-18 21:24 ` [PATCH v2 13/17] make gdb.asm parallel-safe Tom Tromey
@ 2013-10-18 21:36 ` Tom Tromey
  2013-10-18 21:36 ` [PATCH v2 05/17] fix up gdb.xml Tom Tromey
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 21:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes the gdb.gdb tests to be parallel-safe, by ensuring that the
new "xgdb" file ends up in the standard output directory during the
tests.

	* gdb.gdb/selftest.exp: Use standard_output_file.
	* lib/selftest-support.exp (do_self_tests): Use
	standard_output_file.
---
 gdb/testsuite/gdb.gdb/selftest.exp     | 10 ++++++++--
 gdb/testsuite/lib/selftest-support.exp | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp
index d700715..3f934cf 100644
--- a/gdb/testsuite/gdb.gdb/selftest.exp
+++ b/gdb/testsuite/gdb.gdb/selftest.exp
@@ -479,11 +479,17 @@ proc test_with_self { executable } {
 
 set GDB_FULLPATH [find_gdb $GDB]
 
+if {[is_remote host]} {
+    set xgdb x$tool
+} else {
+    set xgdb [standard_output_file x$tool]
+}
+
 # Remove any old copy lying around.
-remote_file host delete x$tool
+remote_file host delete $xgdb
 
 gdb_start
-set file [remote_download host $GDB_FULLPATH x$tool]
+set file [remote_download host $GDB_FULLPATH $xgdb]
 set result [test_with_self $file]
 gdb_exit
 catch "remote_file host delete $file"
diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
index fc4bccc..98a83aa 100644
--- a/gdb/testsuite/lib/selftest-support.exp
+++ b/gdb/testsuite/lib/selftest-support.exp
@@ -129,11 +129,17 @@ proc do_self_tests {function body} {
 
     set GDB_FULLPATH [find_gdb $GDB]
 
+    if {[is_remote host]} {
+	set xgdb x$tool
+    } else {
+	set xgdb [standard_output_file x$tool]
+    }
+
     # Remove any old copy lying around.
-    remote_file host delete x$tool
+    remote_file host delete $xgdb
 
     gdb_start
-    set file [remote_download host $GDB_FULLPATH x$tool]
+    set file [remote_download host $GDB_FULLPATH $xgdb]
 
     set result [selftest_setup $file $function]
     if {$result == 0} then {
-- 
1.8.1.4

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

* [PATCH v2 05/17] fix up gdb.xml
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (14 preceding siblings ...)
  2013-10-18 21:36 ` [PATCH v2 04/17] fix up gdb.gdb Tom Tromey
@ 2013-10-18 21:36 ` Tom Tromey
  2013-10-25 16:21   ` Pedro Alves
  2013-10-18 21:44 ` [PATCH v2 16/17] fix some fission tests Tom Tromey
  2013-10-25 16:23 ` [PATCH v2 00/17] test suite parallel safety Pedro Alves
  17 siblings, 1 reply; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 21:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes the gdb.xml tests to be parallel-safe.

	* gdb.xml/tdesc-arch.exp: Use standard_output_file.  Make
	downloads conditional on remote host.
	(set_arch): Likewise.
	* gdb.xml/tdesc-regs.exp: Use gdb_remote_download.
	(load_description): Use standard_output_file.  Add "should_cd"
	argument.
---
 gdb/testsuite/gdb.xml/tdesc-arch.exp | 28 +++++++++++++++-----------
 gdb/testsuite/gdb.xml/tdesc-regs.exp | 39 ++++++++++++++++++++++++++----------
 2 files changed, 44 insertions(+), 23 deletions(-)

diff --git a/gdb/testsuite/gdb.xml/tdesc-arch.exp b/gdb/testsuite/gdb.xml/tdesc-arch.exp
index 5fde2ff..241ad28 100644
--- a/gdb/testsuite/gdb.xml/tdesc-arch.exp
+++ b/gdb/testsuite/gdb.xml/tdesc-arch.exp
@@ -60,17 +60,20 @@ proc set_arch { arch which } {
     global gdb_prompt
     global subdir
 
-    set fd [open "$subdir/tdesc-arch.xml" w]
+    set filename [standard_output_file tdesc-arch.xml]
+    set fd [open $filename w]
     puts $fd \
 	"<target>
 	    <architecture>$arch</architecture>
 	 </target>"
     close $fd
-    remote_download host "${subdir}/tdesc-arch.xml" "tdesc-arch.xml"
+    if {[is_remote host]} {
+	set filename [remote_download host $filename tdesc-arch.xml]
+    }
 
     # Anchor the test output, so that error messages are detected.
-    set cmd "set tdesc filename tdesc-arch.xml"
-    set msg "$cmd ($which architecture)"
+    set cmd "set tdesc filename $filename"
+    set msg "set tdesc filename tdesc-arch.xml ($which architecture)"
     set cmd_regex [string_to_regexp $cmd]
     gdb_test_multiple $cmd $msg {
 	-re "^$cmd_regex\r\n$gdb_prompt $" {
@@ -86,31 +89,32 @@ proc set_arch { arch which } {
 	"The target architecture is set automatically \\(currently $arch\\)" \
 	"$cmd ($which architecture)"
 
-    file delete "${subdir}/tdesc-arch.xml"
-    remote_file host delete "tdesc-arch.xml"
+    remote_file host delete $filename
 }
 
 set_arch $arch1 first
 set_arch $arch2 second
 
 # Check an invalid architecture setting.
-set fd [open "${subdir}/tdesc-arch.xml" w]
+set filename [standard_output_file tdesc-arch.xml]
+set fd [open $filename w]
 puts $fd \
     "<target>
        <architecture>invalid</architecture>
      </target>"
 close $fd
-remote_download host "$subdir/tdesc-arch.xml" "tdesc-arch.xml"
+if {[is_remote host]} {
+    set filename [remote_download host $filename "tdesc-arch.xml"]
+}
 
-set cmd "set tdesc filename tdesc-arch.xml"
+set cmd "set tdesc filename $filename"
 gdb_test $cmd \
     "warning:.*Target description specified unknown architecture.*" \
-    "$cmd (invalid architecture)"
+    "set tdesc filename tdesc-arch.xml (invalid architecture)"
 
 set cmd "show architecture"
 gdb_test $cmd \
     "The target architecture is set automatically \\(currently $default_arch\\)" \
     "$cmd (invalid architecture)"
 
-file delete "${subdir}/tdesc-arch.xml"
-remote_file host delete "tdesc-arch.xml"
+remote_file host delete $filename
diff --git a/gdb/testsuite/gdb.xml/tdesc-regs.exp b/gdb/testsuite/gdb.xml/tdesc-regs.exp
index 533812f..c0f4978 100644
--- a/gdb/testsuite/gdb.xml/tdesc-regs.exp
+++ b/gdb/testsuite/gdb.xml/tdesc-regs.exp
@@ -94,20 +94,27 @@ gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \
 # Copy the core registers into the objdir if necessary, so that they
 # will be found by <xi:include>.
 foreach src ${core-regs} {
-    set file [remote_download host "$srcdir/../features/$regdir$src" "$src"]
+    set remote_filename($src) \
+	[gdb_remote_download host "$srcdir/../features/$regdir$src"]
 }
 
-# Similarly, we need to copy files under test into the objdir.
-proc load_description { file errmsg } {
+# Similarly, we need to copy files under test into the objdir.  If
+# SHOULD_CD is set, it causes the gdb under test to "cd" to the
+# directory holding the XML code.  This should only be set once; so
+# the first call should use it and subsequent calls should not.
+proc load_description { file errmsg {should_cd 1} } {
     global srcdir
     global subdir
     global gdb_prompt
     global core-regs
     global architecture
+    global remote_filename
 
-    file delete "$subdir/regs.xml"
+    set regs_file [standard_output_file regs.xml]
+
+    file delete $regs_file
     set ifd [open "$srcdir/$subdir/$file" r]
-    set ofd [open "$subdir/regs.xml" w]
+    set ofd [open $regs_file w]
     while {[gets $ifd line] >= 0} {
 	if {[regexp {<xi:include href="core-regs.xml"/>} $line]} {
 	    if {! [string equal ${architecture} ""]} {
@@ -122,11 +129,18 @@ proc load_description { file errmsg } {
     }
     close $ifd
     close $ofd
-    remote_download host "$subdir/regs.xml" "regs.xml"
-    file delete "$subdir/regs.xml"
+
+    if {[is_remote host]} {
+	set regs_file [remote_download host "$subdir/regs.xml" "regs.xml"]
+    }
+
+    if {$should_cd && ![is_remote host]} {
+	gdb_test "cd [file dirname $regs_file]" "Working directory .*" \
+	    "cd to directory holding xml"
+    }
 
     # Anchor the test output, so that error messages are detected.
-    set cmd "set tdesc filename regs.xml"
+    set cmd "set tdesc filename [file tail $regs_file]"
     set msg "set tdesc filename regs.xml - from $file"
     set cmd_regex [string_to_regexp $cmd]
     gdb_test_multiple $cmd $msg {
@@ -134,7 +148,10 @@ proc load_description { file errmsg } {
 	    pass $msg
 	}
     }
-    remote_file host delete "regs.xml"
+
+    if {[is_remote host]} {
+	remote_file host delete "regs.xml"
+    }
 }
 
 load_description "extra-regs.xml" ""
@@ -150,10 +167,10 @@ gdb_test "ptype \$structreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\
 gdb_test "ptype \$bitfields" \
     "type = struct struct2 {\r\n *uint64_t f1 : 35;\r\n *uint64_t f2 : 1;\r\n}"
 
-load_description "core-only.xml" ""
+load_description "core-only.xml" "" 0
 # The extra register from the previous description should be gone.
 gdb_test "ptype \$extrareg" "type = void"
 
 foreach src ${core-regs} {
-    remote_file host delete "$src"
+    remote_file host delete $remote_filename($src)
 }
-- 
1.8.1.4

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

* [PATCH v2 16/17] fix some fission tests
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (15 preceding siblings ...)
  2013-10-18 21:36 ` [PATCH v2 05/17] fix up gdb.xml Tom Tromey
@ 2013-10-18 21:44 ` Tom Tromey
  2013-10-25 16:23 ` [PATCH v2 00/17] test suite parallel safety Pedro Alves
  17 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-18 21:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A couple of Fission tests rely on the current directory layout.  This
assumption is not valid in parallel mode.

This patch fixes the problem by removing the relative directory from
the .S files and instead having the tests set debug-file-directory
before opening the main file.

	* gdb.dwarf2/fission-base.S: Remove "gdb.dwarf/".
	* gdb.dwarf2/fission-base.exp: Set debug-file-directory
	before loading binfile.
	* gdb.dwarf2/fission-loclists.S: Remove "gdb.dwarf/".
	* gdb.dwarf2/fission-loclists.exp: Set debug-file-directory
	before loading binfile.
---
 gdb/testsuite/gdb.dwarf2/fission-base.S       | 4 ++--
 gdb/testsuite/gdb.dwarf2/fission-base.exp     | 9 ++++++++-
 gdb/testsuite/gdb.dwarf2/fission-loclists.S   | 2 +-
 gdb/testsuite/gdb.dwarf2/fission-loclists.exp | 9 ++++++++-
 4 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/fission-base.S b/gdb/testsuite/gdb.dwarf2/fission-base.S
index ccd6b23..e670423 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-base.S
+++ b/gdb/testsuite/gdb.dwarf2/fission-base.S
@@ -85,7 +85,7 @@ main:
 	.uleb128 0x1	# (DIE (0xb) DW_TAG_compile_unit)
 	.ascii "GNU C 4.6.x-fission\0"	# DW_AT_producer
 	.byte	0x1	# DW_AT_language
-	.ascii "gdb.dwarf2/fission-base.c\0"	# DW_AT_name
+	.ascii "fission-base.c\0"	# DW_AT_name
 	.ascii "/tmp/src/gdb/testsuite\0"	# DW_AT_comp_dir
 	.byte	1	# DW_AT_GNU_dwo_id
 	.byte	2
@@ -143,7 +143,7 @@ main:
 	.8byte	.Letext0-.Ltext0	# DW_AT_high_pc
 	.4byte	.Ldebug_line0	# DW_AT_stmt_list
 	.ascii "/tmp/src/gdb/testsuite\0"	# DW_AT_comp_dir
-	.ascii "gdb.dwarf2/fission-base.dwo\0"	# DW_AT_GNU_dwo_name
+	.ascii "fission-base.dwo\0"	# DW_AT_GNU_dwo_name
 	.4byte	.Ldebug_pubnames0	# DW_AT_GNU_pubnames
 	.4byte	.Ldebug_pubtypes0	# DW_AT_GNU_pubtypes
 	.4byte	.Ldebug_addr0_begin	# DW_AT_GNU_addr_base
diff --git a/gdb/testsuite/gdb.dwarf2/fission-base.exp b/gdb/testsuite/gdb.dwarf2/fission-base.exp
index bb4eb77..81ca585 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-base.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-base.exp
@@ -37,7 +37,14 @@ if [build_executable_from_fission_assembler \
     return -1
 }
 
-clean_restart ${binfile}
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+# Make sure we can find the .dwo file, regardless of whether we're
+# running in parallel mode.
+gdb_test_no_output "set debug-file-directory [file dirname $binfile]" \
+    "set debug-file-directory"
+gdb_load $binfile
 
 if ![runto_main] {
     return -1
diff --git a/gdb/testsuite/gdb.dwarf2/fission-loclists.S b/gdb/testsuite/gdb.dwarf2/fission-loclists.S
index 876c610..ee34a29 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-loclists.S
+++ b/gdb/testsuite/gdb.dwarf2/fission-loclists.S
@@ -240,7 +240,7 @@ main:
 	.byte	0x5
 	.4byte	.Ldebug_ranges0	# DW_AT_GNU_ranges_base
 	.ascii "/tmp/src/gdb/testsuite\0"	# DW_AT_comp_dir
-	.ascii "gdb.dwarf2/fission-loclists.dwo\0"	# DW_AT_GNU_dwo_name
+	.ascii "fission-loclists.dwo\0"	# DW_AT_GNU_dwo_name
 	.4byte	.Ldebug_pubnames0	# DW_AT_GNU_pubnames
 	.4byte	.Ldebug_pubtypes0	# DW_AT_GNU_pubtypes
 	.4byte	.Ldebug_addr0	# DW_AT_GNU_addr_base
diff --git a/gdb/testsuite/gdb.dwarf2/fission-loclists.exp b/gdb/testsuite/gdb.dwarf2/fission-loclists.exp
index 29ccd1b..dccd6c2 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-loclists.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-loclists.exp
@@ -37,7 +37,14 @@ if [build_executable_from_fission_assembler \
     return -1
 }
 
-clean_restart ${binfile}
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+# Make sure we can find the .dwo file, regardless of whether we're
+# running in parallel mode.
+gdb_test_no_output "set debug-file-directory [file dirname $binfile]" \
+    "set debug-file-directory"
+gdb_load $binfile
 
 if ![runto_main] {
     return -1
-- 
1.8.1.4

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

* Re: [PATCH v2 05/17] fix up gdb.xml
  2013-10-18 21:36 ` [PATCH v2 05/17] fix up gdb.xml Tom Tromey
@ 2013-10-25 16:21   ` Pedro Alves
  2013-10-25 18:23     ` Tom Tromey
  0 siblings, 1 reply; 31+ messages in thread
From: Pedro Alves @ 2013-10-25 16:21 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 10/18/2013 09:49 PM, Tom Tromey wrote:
> -# Similarly, we need to copy files under test into the objdir.
> -proc load_description { file errmsg } {
> +# Similarly, we need to copy files under test into the objdir.  If
> +# SHOULD_CD is set, it causes the gdb under test to "cd" to the
> +# directory holding the XML code.  This should only be set once; so
> +# the first call should use it and subsequent calls should not.
> +proc load_description { file errmsg {should_cd 1} } {
>      global srcdir
>      global subdir
>      global gdb_prompt
>      global core-regs
>      global architecture
> +    global remote_filename
>  
> -    file delete "$subdir/regs.xml"
> +    set regs_file [standard_output_file regs.xml]

Sorry, I guess I'm a little dense, as this CD stuff still confused
me.  IIUC, we only CD once, because subsequent calls to load_description
will use the cwd set from the first call.  Is that right?
(I can't tell whether the path passed to "cd" is relative -- if so,
if we don't cd back to the previous dir, then that'd be clearly
a problem).

So that I understand, given we only CD if !remote-host, cd'ing
before calling load_description in the first place work be the
same then, right?  Like:

    set regs_file [standard_output_file regs.xml]
    if {![is_remote host]} {
	gdb_test "cd [file dirname $regs_file]" "Working directory .*" \
	    "cd to directory holding xml"
    }

    load_description "extra-regs.xml" ""
    ...
    load_description "core-only.xml" ""

Thanks,
-- 
Pedro Alves

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

* Re: [PATCH v2 15/17] fix some "exec" tests
  2013-10-18 20:49 ` [PATCH v2 15/17] fix some "exec" tests Tom Tromey
@ 2013-10-25 16:21   ` Pedro Alves
  2013-10-25 16:39     ` Tom Tromey
  0 siblings, 1 reply; 31+ messages in thread
From: Pedro Alves @ 2013-10-25 16:21 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 10/18/2013 09:49 PM, Tom Tromey wrote:
> A few tests run an inferior that execs some other inferior.  These
> tests have the correct file name compiled in.  These tests assume the
> current test suite directory layout, but fail in parallel mode.

FYI, the "These tests have the correct file name compiled in."
sentence confused me.  I'm not exactly sure what you meant
by that.

-- 
Pedro Alves

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

* Re: [PATCH v2 07/17] fix up gdb.trace
  2013-10-18 20:49 ` [PATCH v2 07/17] fix up gdb.trace Tom Tromey
@ 2013-10-25 16:22   ` Pedro Alves
  2013-10-25 16:37     ` Tom Tromey
  0 siblings, 1 reply; 31+ messages in thread
From: Pedro Alves @ 2013-10-25 16:22 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 10/18/2013 09:49 PM, Tom Tromey wrote:
> +if {![is_remote host] && ![is_remote target]} {
> +    set tfile_basic [standard_output_file tfile-basic.tf]
> +    set tfile_dir [file dirname $tfile_basic]/
> +    set purely_local 1
> +} else {
> +    set purely_local 0
> +    set tfile_basic tfile-basic.tf
> +    set tfile_dir ""
> +}
> +

Minor, minor nit.  Can you define the variables in the same
order in both branches?  My eyes crossed a little going back
and forth comparing the values of both branches, for the
branches not having the same pattern.  Sorry for the trouble.

> +if {![is_remote host] && ![is_remote target]} {
> +    set tfile_basic [standard_output_file tfile-basic.tf]
> +    set tfile_error [standard_output_file tfile-error.tf]
> +    set tfile_dir [file dirname $tfile_basic]/
> +    set purely_local 1
> +} else {
> +    set tfile_basic tfile-basic.tf
> +    set tfile_error tfile-error.tf
> +    set purely_local 0
> +    set tfile_dir ""
> +}
> +

Here too, and also in tfile.exp.

-- 
Pedro Alves

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

* Re: [PATCH v2 11/17] introduce relative_filename and use it
  2013-10-18 21:00 ` [PATCH v2 11/17] introduce relative_filename and use it Tom Tromey
@ 2013-10-25 16:22   ` Pedro Alves
  2013-10-25 16:42     ` Tom Tromey
  2013-10-28 19:01   ` Doug Evans
  1 sibling, 1 reply; 31+ messages in thread
From: Pedro Alves @ 2013-10-25 16:22 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 10/18/2013 09:49 PM, Tom Tromey wrote:
> This introduces a new relative_filename proc to gdb.exp and changes
> some tests to use it.  This helps make these tests parallel-safe.
> 
> 	* gdb.base/fullname.exp: Use standard_output_file,
> 	relative_filename.
> 	* gdb.base/hashline1.exp: Use standard_testfile,
> 	standard_output_file, relative_filename, clean_restart.
> 	* gdb.base/hashline2.exp: Use standard_testfile,
> 	standard_output_file, relative_filename.
> 	* gdb.base/hashline3.exp: Use standard_testfile,
> 	standard_output_file, relative_filename.
> 	* lib/gdb.exp (relative_filename): New proc.

...

It seems like gdb.base/hashline2.exp doesn't actually use
relative_filename.  Was that a mistake?

> diff --git a/gdb/testsuite/gdb.base/hashline2.exp b/gdb/testsuite/gdb.base/hashline2.exp
> index d7ee4a7..cd748ca 100644
> --- a/gdb/testsuite/gdb.base/hashline2.exp
> +++ b/gdb/testsuite/gdb.base/hashline2.exp
> @@ -21,16 +21,15 @@
>  # srcfile is in objdir because we need to machine generate it in order
>  # to get the correct path in the #line directive.
>  
> -set testfile "hashline2"
> -set srcfile "${testfile}.c"
> -set binfile "${objdir}/${subdir}/${testfile}"
> +standard_testfile .c
>  
> -set fd [open ${objdir}/${subdir}/${srcfile} w]
> -puts $fd "#line 2 \"///[pwd]/${subdir}/${srcfile}\""
> +set new_srcfile [standard_output_file $srcfile]
> +set fd [open $new_srcfile w]
> +puts $fd "#line 2 \"///${new_srcfile}\""
>  puts $fd "int main () { return 0; } /* set breakpoint here */"
>  close $fd
>  
> -if { [gdb_compile "${objdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
> +if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } {
>      untested hashline2.exp
>      return -1
>  }
> @@ -40,7 +39,7 @@ gdb_start
>  gdb_reinitialize_dir $srcdir/$subdir
>  gdb_load ${binfile}
>  
> -set bp_location [gdb_get_line_number "set breakpoint here" ${objdir}/${subdir}/${srcfile}]
> +set bp_location [gdb_get_line_number "set breakpoint here" ${new_srcfile}]
>  
>  # Try to set a breakpoint on the specified file location.
>  

-- 
Pedro Alves

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

* Re: [PATCH v2 00/17] test suite parallel safety
  2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
                   ` (16 preceding siblings ...)
  2013-10-18 21:44 ` [PATCH v2 16/17] fix some fission tests Tom Tromey
@ 2013-10-25 16:23 ` Pedro Alves
  17 siblings, 0 replies; 31+ messages in thread
From: Pedro Alves @ 2013-10-25 16:23 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 10/18/2013 09:49 PM, Tom Tromey wrote:

> Let me know what you think.

I sent a few minor comments, but otherwise this looks pretty
much ready to go in to me.  Looks great.

Thanks a lot for doing this.

-- 
Pedro Alves

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

* Re: [PATCH v2 07/17] fix up gdb.trace
  2013-10-25 16:22   ` Pedro Alves
@ 2013-10-25 16:37     ` Tom Tromey
  0 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-25 16:37 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> On 10/18/2013 09:49 PM, Tom Tromey wrote:
>> +if {![is_remote host] && ![is_remote target]} {
>> +    set tfile_basic [standard_output_file tfile-basic.tf]
>> +    set tfile_dir [file dirname $tfile_basic]/
>> +    set purely_local 1
>> +} else {
>> +    set purely_local 0
>> +    set tfile_basic tfile-basic.tf
>> +    set tfile_dir ""
>> +}
>> +

Pedro> Minor, minor nit.  Can you define the variables in the same
Pedro> order in both branches?  My eyes crossed a little going back
Pedro> and forth comparing the values of both branches, for the
Pedro> branches not having the same pattern.  Sorry for the trouble.

It's no trouble.
I made the change locally.

Tom

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

* Re: [PATCH v2 15/17] fix some "exec" tests
  2013-10-25 16:21   ` Pedro Alves
@ 2013-10-25 16:39     ` Tom Tromey
  2013-10-25 17:02       ` Pedro Alves
  0 siblings, 1 reply; 31+ messages in thread
From: Tom Tromey @ 2013-10-25 16:39 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro> FYI, the "These tests have the correct file name compiled in."
Pedro> sentence confused me.  I'm not exactly sure what you meant
Pedro> by that.

I rewrote that paragraph as

    A few tests run an inferior that execs some other program.  The name
    of this exec'd program is compiled in.  These tests assume the current
    test suite directory layout, but fail in parallel mode.

Tom

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

* Re: [PATCH v2 11/17] introduce relative_filename and use it
  2013-10-25 16:22   ` Pedro Alves
@ 2013-10-25 16:42     ` Tom Tromey
  2013-10-25 17:03       ` Pedro Alves
  0 siblings, 1 reply; 31+ messages in thread
From: Tom Tromey @ 2013-10-25 16:42 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> On 10/18/2013 09:49 PM, Tom Tromey wrote:
>> This introduces a new relative_filename proc to gdb.exp and changes
>> some tests to use it.  This helps make these tests parallel-safe.
>> 
>> * gdb.base/fullname.exp: Use standard_output_file,
>> relative_filename.
>> * gdb.base/hashline1.exp: Use standard_testfile,
>> standard_output_file, relative_filename, clean_restart.
>> * gdb.base/hashline2.exp: Use standard_testfile,
>> standard_output_file, relative_filename.
>> * gdb.base/hashline3.exp: Use standard_testfile,
>> standard_output_file, relative_filename.
>> * lib/gdb.exp (relative_filename): New proc.

Pedro> It seems like gdb.base/hashline2.exp doesn't actually use
Pedro> relative_filename.  Was that a mistake?

I looked, and it was intentional.
The test case is supposed to use absolute file names here.
I've corrected the ChangeLog entry.

Tom

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

* Re: [PATCH v2 15/17] fix some "exec" tests
  2013-10-25 16:39     ` Tom Tromey
@ 2013-10-25 17:02       ` Pedro Alves
  0 siblings, 0 replies; 31+ messages in thread
From: Pedro Alves @ 2013-10-25 17:02 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 10/25/2013 05:39 PM, Tom Tromey wrote:
> Pedro> FYI, the "These tests have the correct file name compiled in."
> Pedro> sentence confused me.  I'm not exactly sure what you meant
> Pedro> by that.
> 
> I rewrote that paragraph as
> 
>     A few tests run an inferior that execs some other program.  The name
>     of this exec'd program is compiled in.  These tests assume the current
>     test suite directory layout, but fail in parallel mode.

Thanks.

-- 
Pedro Alves

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

* Re: [PATCH v2 11/17] introduce relative_filename and use it
  2013-10-25 16:42     ` Tom Tromey
@ 2013-10-25 17:03       ` Pedro Alves
  0 siblings, 0 replies; 31+ messages in thread
From: Pedro Alves @ 2013-10-25 17:03 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 10/25/2013 05:42 PM, Tom Tromey wrote:

> Pedro> It seems like gdb.base/hashline2.exp doesn't actually use
> Pedro> relative_filename.  Was that a mistake?
> 
> I looked, and it was intentional.
> The test case is supposed to use absolute file names here.
> I've corrected the ChangeLog entry.

Thanks, sounds good.

-- 
Pedro Alves

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

* Re: [PATCH v2 05/17] fix up gdb.xml
  2013-10-25 16:21   ` Pedro Alves
@ 2013-10-25 18:23     ` Tom Tromey
  0 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-25 18:23 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> So that I understand, given we only CD if !remote-host, cd'ing
Pedro> before calling load_description in the first place work be the
Pedro> same then, right?  Like:

Yeah.  I made this change.  It does look simpler now.

thanks,
Tom

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

* Re: [PATCH v2 11/17] introduce relative_filename and use it
  2013-10-18 21:00 ` [PATCH v2 11/17] introduce relative_filename and use it Tom Tromey
  2013-10-25 16:22   ` Pedro Alves
@ 2013-10-28 19:01   ` Doug Evans
  2013-10-28 20:10     ` Tom Tromey
  1 sibling, 1 reply; 31+ messages in thread
From: Doug Evans @ 2013-10-28 19:01 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Fri, Oct 18, 2013 at 1:49 PM, Tom Tromey <tromey@redhat.com> wrote:
> This introduces a new relative_filename proc to gdb.exp and changes
> some tests to use it.  This helps make these tests parallel-safe.
>
>         * gdb.base/fullname.exp: Use standard_output_file,
>         relative_filename.
>         * gdb.base/hashline1.exp: Use standard_testfile,
>         standard_output_file, relative_filename, clean_restart.
>         * gdb.base/hashline2.exp: Use standard_testfile,
>         standard_output_file, relative_filename.
>         * gdb.base/hashline3.exp: Use standard_testfile,
>         standard_output_file, relative_filename.
>         * lib/gdb.exp (relative_filename): New proc.
> [...]
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -4320,6 +4320,21 @@ proc set_remotetimeout { timeout } {
>      }
>  }
>
> +# ROOT and FULL are file names.  Returns the relative path from ROOT
> +# to FULL.  Note that FULL must be in a subdirectory of ROOT.
> +# For example, given ROOT = /usr/bin and FULL = /usr/bin/ls, this
> +# will return "ls".
> +
> +proc relative_filename {root full} {
> +    if {[string compare [string range $full 0 \
> +                            [expr {[string length $root] - 1}]] $root] != 0} {
> +       error "$full not a subdir of $root"
> +    }
> +
> +    set len [llength [file split $root]]
> +    return [eval file join [lrange [file split $full] $len end]]
> +}
> +

There's also string compare -length.

Or maybe for some incremental robustness, do the file splits first and
then compare that?

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

* Re: [PATCH v2 11/17] introduce relative_filename and use it
  2013-10-28 19:01   ` Doug Evans
@ 2013-10-28 20:10     ` Tom Tromey
  0 siblings, 0 replies; 31+ messages in thread
From: Tom Tromey @ 2013-10-28 20:10 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> There's also string compare -length.

Doug> Or maybe for some incremental robustness, do the file splits first and
Doug> then compare that?

Ok, I replaced it with this implementation.
Let me know what you think.


proc relative_filename {root full} {
    set root_split [file split $root]
    set full_split [file split $full]

    set len [llength $root_split]

    if {[eval file join $root_split]
	!= [eval file join [lrange $full_split 0 [expr {$len - 1}]]]} {
	error "$full not a subdir of $root"
    }

    return [eval file join [lrange $full_split $len end]]
}

Tom

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

end of thread, other threads:[~2013-10-28 20:10 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-18 20:49 [PATCH v2 00/17] test suite parallel safety Tom Tromey
2013-10-18 20:49 ` [PATCH v2 06/17] fix up gdb.mi Tom Tromey
2013-10-18 20:49 ` [PATCH v2 12/17] fix up gdb.server Tom Tromey
2013-10-18 20:49 ` [PATCH v2 07/17] fix up gdb.trace Tom Tromey
2013-10-25 16:22   ` Pedro Alves
2013-10-25 16:37     ` Tom Tromey
2013-10-18 20:49 ` [PATCH v2 03/17] fix weird.exp for parallel testing Tom Tromey
2013-10-18 20:49 ` [PATCH v2 02/17] fix some simple thinkos in the test suite Tom Tromey
2013-10-18 20:49 ` [PATCH v2 01/17] fix up log-file toggling Tom Tromey
2013-10-18 20:49 ` [PATCH v2 08/17] simple changes in gdb.base Tom Tromey
2013-10-18 20:49 ` [PATCH v2 15/17] fix some "exec" tests Tom Tromey
2013-10-25 16:21   ` Pedro Alves
2013-10-25 16:39     ` Tom Tromey
2013-10-25 17:02       ` Pedro Alves
2013-10-18 20:49 ` [PATCH v2 09/17] update checkpoint test Tom Tromey
2013-10-18 21:00 ` [PATCH v2 14/17] fix argv0-symlink.exp for parallel mode Tom Tromey
2013-10-18 21:00 ` [PATCH v2 11/17] introduce relative_filename and use it Tom Tromey
2013-10-25 16:22   ` Pedro Alves
2013-10-25 16:42     ` Tom Tromey
2013-10-25 17:03       ` Pedro Alves
2013-10-28 19:01   ` Doug Evans
2013-10-28 20:10     ` Tom Tromey
2013-10-18 21:11 ` [PATCH v2 17/17] switch to fully parallel mode Tom Tromey
2013-10-18 21:24 ` [PATCH v2 10/17] update fileio test Tom Tromey
2013-10-18 21:24 ` [PATCH v2 13/17] make gdb.asm parallel-safe Tom Tromey
2013-10-18 21:36 ` [PATCH v2 04/17] fix up gdb.gdb Tom Tromey
2013-10-18 21:36 ` [PATCH v2 05/17] fix up gdb.xml Tom Tromey
2013-10-25 16:21   ` Pedro Alves
2013-10-25 18:23     ` Tom Tromey
2013-10-18 21:44 ` [PATCH v2 16/17] fix some fission tests Tom Tromey
2013-10-25 16:23 ` [PATCH v2 00/17] test suite parallel safety Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).