Remote-host testing fixes

Joseph S. Myers joseph@codesourcery.com
Sat Sep 8 16:28:00 GMT 2007


This patch fixes some problems with GCC testing with a remote host
(runtest --host_board).  In particular:

* Tools must be run with remote_exec host, not "exec" or "local_exec".

* DejaGnu copies the source file to the remote host, builds from it
  with a local path and "-o a.out" and then copies a.out to the
  desired output file on the build system.  Certain tests need
  disabling as incompatible with this: -frepo does not work with
  object files being renamed in this way, and
  gcc.dg/cpp/trad/builtins.c relies on the file being compiled from an
  absolute path.  v3-build-support also needs adjusting to specify the
  output file when preprocessing.

* A problem with gcc.misc-tests/options.exp on Windows hosts needing
  to allow for ".exe" in the output is also fixed.

Tested native on i686-pc-linux-gnu to make sure the results for local
host testing are unchanged; the changes have also been spot-tested to
make sure they have the desired effect in remote-host testing.  (There
are still other problems with remote-host testing in general, though
having a shared filesystem between build and host systems helps reduce
them, as does a host board file that adds -I options to ensure
relative include paths in testcases work without each test needing to
specify all the headers to copy to the host.)  OK to commit?

gcc/testsuite:
2007-09-08  Joseph Myers  <joseph@codesourcery.com>

	* lib/file-format.exp (gcc_target_object_format): Use remote_exec
	to call objdump.
	* lib/scanasm.exp (scan-assembler-dem, scan-assembler-dem-not):
	Use remote_exec to call c++filt.
	* lib/target-supports-dg.exp (dg-require-host-local): New.
	* gcc.misc-tests/options.exp: Allow .exe in command paths.
	* g++.dg/parse/repo1.C: Use dg-require-host-local.
	* g++.dg/rtti/repo1.C: Likewise.
	* g++.dg/template/repo1.C: Likewise.
	* g++.dg/template/repo2.C: Likewise.
	* g++.dg/template/repo3.C: Likewise.
	* g++.dg/template/repo4.C: Likewise.
	* g++.dg/template/repo5.C: Likewise.
	* g++.old-deja/g++.pt/instantiate4.C: Likewise.
	* g++.old-deja/g++.pt/instantiate6.C: Likewise.
	* g++.old-deja/g++.pt/repo1.C: Likewise.
	* g++.old-deja/g++.pt/repo2.C: Likewise.
	* g++.old-deja/g++.pt/repo3.C: Likewise.
	* g++.old-deja/g++.pt/repo4.C: Likewise.
	* gcc.dg/cpp/trad/builtins.c: Likewise.

libstdc++-v3:
2007-09-08  Joseph Myers  <joseph@codesourcery.com>

	* testsuite/lib/libstdc++.exp (v3-build-support): Specify output
	file for preprocessing.  Use remote_exec to call ar and ranlib.

Index: gcc/testsuite/gcc.dg/cpp/trad/builtins.c
===================================================================
--- gcc/testsuite/gcc.dg/cpp/trad/builtins.c	(revision 128268)
+++ gcc/testsuite/gcc.dg/cpp/trad/builtins.c	(working copy)
@@ -50,3 +50,5 @@
 
   return 0;
 }
+
+/* { dg-require-host-local "" } */
Index: gcc/testsuite/gcc.misc-tests/options.exp
===================================================================
--- gcc/testsuite/gcc.misc-tests/options.exp	(revision 128268)
+++ gcc/testsuite/gcc.misc-tests/options.exp	(working copy)
@@ -36,15 +36,15 @@
     set gcc_output [gcc_target_compile $filename.c $filename.x executable $gcc_options]
     remote_file build delete $filename.c $filename.x $filename.gcno
 
-    if {![regexp -- "/$compiler -quiet.*$compiler_pattern" $gcc_output]} {
+    if {![regexp -- "/${compiler}(\\.exe)? -quiet.*$compiler_pattern" $gcc_output]} {
 	fail "$test (compiler options)"
 	return
     }
-    if {![regexp -- " *as .*$as_pattern" $gcc_output]} {
+    if {![regexp -- " *as(\\.exe)? .*$as_pattern" $gcc_output]} {
 	fail "$test (assembler options)"
 	return
     }
-    if {![regexp -- "/collect2 .*$ld_pattern" $gcc_output]} {
+    if {![regexp -- "/collect2(\\.exe)? .*$ld_pattern" $gcc_output]} {
 	fail "$test (linker options)"
 	return
     }
Index: gcc/testsuite/g++.old-deja/g++.pt/repo1.C
===================================================================
--- gcc/testsuite/g++.old-deja/g++.pt/repo1.C	(revision 128268)
+++ gcc/testsuite/g++.old-deja/g++.pt/repo1.C	(working copy)
@@ -1,5 +1,6 @@
 // { dg-do link }
 // { dg-options "-frepo" }
+// { dg-require-host-local "" }
 
 // Bug: g++ complains about duplicate explicit instantiations with -frepo.
 // From Jason Merrill <jason@cygnus.com>
Index: gcc/testsuite/g++.old-deja/g++.pt/instantiate4.C
===================================================================
--- gcc/testsuite/g++.old-deja/g++.pt/instantiate4.C	(revision 128268)
+++ gcc/testsuite/g++.old-deja/g++.pt/instantiate4.C	(working copy)
@@ -1,5 +1,6 @@
 // { dg-do link }
 // { dg-options "-frepo -Werror" }
+// { dg-require-host-local "" }
 // Build then link:
 
 
Index: gcc/testsuite/g++.old-deja/g++.pt/repo2.C
===================================================================
--- gcc/testsuite/g++.old-deja/g++.pt/repo2.C	(revision 128268)
+++ gcc/testsuite/g++.old-deja/g++.pt/repo2.C	(working copy)
@@ -1,5 +1,6 @@
 // { dg-do link  }
 // { dg-options "-frepo" }
+// { dg-require-host-local "" }
 // Test that collect2 isn't confused by GNU ld's "In function `foo':" message.
 // Contributed by Jason Merrill <jason@cygnus.com>
 
Index: gcc/testsuite/g++.old-deja/g++.pt/repo3.C
===================================================================
--- gcc/testsuite/g++.old-deja/g++.pt/repo3.C	(revision 128268)
+++ gcc/testsuite/g++.old-deja/g++.pt/repo3.C	(working copy)
@@ -1,5 +1,6 @@
 // { dg-do link }
 // { dg-options "-frepo" }
+// { dg-require-host-local "" }
 // Test that we properly generate the vtable and such for C.
 // Contributed by scott snyder <snyder@fnal.gov>
 
Index: gcc/testsuite/g++.old-deja/g++.pt/instantiate6.C
===================================================================
--- gcc/testsuite/g++.old-deja/g++.pt/instantiate6.C	(revision 128268)
+++ gcc/testsuite/g++.old-deja/g++.pt/instantiate6.C	(working copy)
@@ -1,5 +1,6 @@
 // { dg-do link }
 // { dg-options "-frepo" }
+// { dg-require-host-local "" }
 // Build then link:
 
 // Simplified from testcase by Erez Louidor Lior <s3824888@techst02.technion.ac.il>
Index: gcc/testsuite/g++.old-deja/g++.pt/repo4.C
===================================================================
--- gcc/testsuite/g++.old-deja/g++.pt/repo4.C	(revision 128268)
+++ gcc/testsuite/g++.old-deja/g++.pt/repo4.C	(working copy)
@@ -1,5 +1,6 @@
 // { dg-do link }
 // { dg-options "-frepo" }
+// { dg-require-host-local "" }
 // Build then link:
 
 template <class T>
Index: gcc/testsuite/g++.dg/rtti/repo1.C
===================================================================
--- gcc/testsuite/g++.dg/rtti/repo1.C	(revision 128268)
+++ gcc/testsuite/g++.dg/rtti/repo1.C	(working copy)
@@ -1,5 +1,6 @@
 // PR c++/22204
 // { dg-options "-frepo" }
+// { dg-require-host-local "" }
 
 #include <typeinfo>
 template<int>
Index: gcc/testsuite/g++.dg/parse/repo1.C
===================================================================
--- gcc/testsuite/g++.dg/parse/repo1.C	(revision 128268)
+++ gcc/testsuite/g++.dg/parse/repo1.C	(working copy)
@@ -1,4 +1,5 @@
 // { dg-options "-frepo" }
+// { dg-require-host-local "" }
 
 extern "C" inline void f() {}
 
Index: gcc/testsuite/g++.dg/template/repo1.C
===================================================================
--- gcc/testsuite/g++.dg/template/repo1.C	(revision 128268)
+++ gcc/testsuite/g++.dg/template/repo1.C	(working copy)
@@ -1,4 +1,5 @@
 // { dg-options "-frepo" }
+// { dg-require-host-local "" }
 
 struct A {
   A();
Index: gcc/testsuite/g++.dg/template/repo2.C
===================================================================
--- gcc/testsuite/g++.dg/template/repo2.C	(revision 128268)
+++ gcc/testsuite/g++.dg/template/repo2.C	(working copy)
@@ -1,5 +1,6 @@
 // PR c++/17163
 // { dg-options "-frepo" }
+// { dg-require-host-local "" }
 
 template <int __inst>
 struct __Atomicity_lock
Index: gcc/testsuite/g++.dg/template/repo3.C
===================================================================
--- gcc/testsuite/g++.dg/template/repo3.C	(revision 128268)
+++ gcc/testsuite/g++.dg/template/repo3.C	(working copy)
@@ -1,4 +1,5 @@
 // { dg-options "-frepo -DF='a'" }
+// { dg-require-host-local "" }
 
 template <typename A, typename B> void f () {}
 template <typename A, typename B> void g () { f<int,int>(); }
Index: gcc/testsuite/g++.dg/template/repo4.C
===================================================================
--- gcc/testsuite/g++.dg/template/repo4.C	(revision 128268)
+++ gcc/testsuite/g++.dg/template/repo4.C	(working copy)
@@ -1,6 +1,7 @@
 // PR c++/17775
 // { dg-options "-frepo" }
 // { dg-final { cleanup-repo-files } }
+// { dg-require-host-local "" }
 
 namespace { 
   struct Foo {}; 
Index: gcc/testsuite/g++.dg/template/repo5.C
===================================================================
--- gcc/testsuite/g++.dg/template/repo5.C	(revision 128268)
+++ gcc/testsuite/g++.dg/template/repo5.C	(working copy)
@@ -1,6 +1,7 @@
 // PR c++/25625
 // { dg-options "-frepo" } 
 // { dg-final { cleanup-repo-files } }
+// { dg-require-host-local "" }
 
 template< typename T, T N > struct integral_c {
   static const T value = N;
Index: gcc/testsuite/lib/scanasm.exp
===================================================================
--- gcc/testsuite/lib/scanasm.exp	(revision 128268)
+++ gcc/testsuite/lib/scanasm.exp	(working copy)
@@ -217,9 +217,8 @@
     upvar 2 name testcase
     set output_file "[file rootname [file tail $testcase]].s"
 
-    set fd [open "| $cxxfilt < $output_file" r]
-    set text [read $fd]
-    close $fd
+    set output [remote_exec host "$cxxfilt" "" "$output_file"]
+    set text [lindex $output 1]
 
     if [regexp -- [lindex $args 0] $text] {
 	pass "$testcase scan-assembler-dem [lindex $args 0]"
@@ -263,9 +262,8 @@
     upvar 2 name testcase
     set output_file "[file rootname [file tail $testcase]].s"
 
-    set fd [open "| $cxxfilt < $output_file" r]
-    set text [read $fd]
-    close $fd
+    set output [remote_exec host "$cxxfilt" "" "$output_file"]
+    set text [lindex $output 1]
 
     if ![regexp -- [lindex $args 0] $text] {
 	pass "$testcase scan-assembler-dem-not [lindex $args 0]"
Index: gcc/testsuite/lib/file-format.exp
===================================================================
--- gcc/testsuite/lib/file-format.exp	(revision 128268)
+++ gcc/testsuite/lib/file-format.exp	(working copy)
@@ -48,9 +48,8 @@
         ${tool}_target_compile objfmtst.c objfmtst.o object ""
 	file delete objfmtst.c       
         
-	catch {
-          set output [exec $objdump_name --file-headers objfmtst.o ]
-        } output
+	set output [remote_exec host "$objdump_name" "--file-headers objfmtst.o"]
+	set output [lindex $output 1]
 
         file delete objfmtst.o
         
Index: gcc/testsuite/lib/target-supports-dg.exp
===================================================================
--- gcc/testsuite/lib/target-supports-dg.exp	(revision 128268)
+++ gcc/testsuite/lib/target-supports-dg.exp	(working copy)
@@ -150,6 +150,18 @@
     }
 }
 
+# If the host is remote rather than the same as the build system, skip
+# this test.  Some tests are incompatible with DejaGnu's handling of
+# remote hosts, which involves copying the source file to the host and
+# compiling it with a relative path and "-o a.out".
+
+proc dg-require-host-local { args } {
+    if [ is_remote host ] {
+        upvar dg-do-what dg-do-what
+        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+    }
+}
+
 # Check the flags with which the test will be run against options in
 # a test directive that will skip or xfail that test.  The DejaGnu proc
 # check_conditional_xfail will look at the options in compiler_flags, so
Index: libstdc++-v3/testsuite/lib/libstdc++.exp
===================================================================
--- libstdc++-v3/testsuite/lib/libstdc++.exp	(revision 128268)
+++ libstdc++-v3/testsuite/lib/libstdc++.exp	(working copy)
@@ -452,12 +452,15 @@
     set libtest_objs ""
 
     set config_src "config.cc"
+    set config_out "config.ii"
     set f [open $config_src "w"]
     puts $f "#include <bits/c++config.h>"
     puts $f "#include <bits/gthr.h>"
     close $f
-    set preprocessed [v3_target_compile $config_src "" \
-	    	       preprocess "additional_flags=-dN"]
+    v3_target_compile $config_src $config_out preprocess "additional_flags=-dN"
+    set file [open $config_out r]
+    set preprocessed [read $file]
+    close $file
     if { [string first "_GLIBCXX_USE_WCHAR_T" $preprocessed] != -1 } {
 	verbose -log "wchar_t support detected"
 	set v3-wchar_t 1
@@ -509,9 +512,9 @@
     } else {
 	set ar [transform "ar"]
     }
-    set arcommand "$ar -rc ./libtestc++.a ${libtest_objs}"
-    verbose -log "$arcommand"
-    set result [lindex [local_exec "$arcommand" "" "" 300] 0]
+    set arargs "-rc ./libtestc++.a ${libtest_objs}"
+    verbose -log "$ar $arargs"
+    set result [lindex [remote_exec host "$ar" "$arargs"] 0]
     verbose "link result is $result"
     if { $result == 0 } {
 	if  [info exists env(RANLIB)] {
@@ -519,9 +522,9 @@
 	} else {
 	    set ranlib [transform "ranlib"]
 	}
-	set ranlibcommand "$ranlib ./libtestc++.a"
-	verbose -log "$ranlibcommand"
-	set result [lindex [local_exec "$ranlibcommand" "" "" 300] 0]
+	set ranlibargs "./libtestc++.a"
+	verbose -log "$ranlib $ranlibargs"
+	set result [lindex [remote_exec host "$ranlib" "$ranlibargs"] 0]
 	if { $result != 0 } {
 	    error "could not link libtestc++.a"
 	}

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Libstdc++ mailing list