[gcc/devel/ranger] testsuite: Move C++ tests in gdc.test into own subdirectory.

Aldy Hernandez aldyh@gcc.gnu.org
Wed Jun 17 20:02:32 GMT 2020


https://gcc.gnu.org/g:afd9da8b8ad01268478fca6db3f63ca4c51b1900

commit afd9da8b8ad01268478fca6db3f63ca4c51b1900
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sun Mar 29 13:27:22 2020 +0200

    testsuite: Move C++ tests in gdc.test into own subdirectory.
    
    Tests have been moved into runnable_cxx as part of upstream dmd 3e10e2dd2.
    
    The extra flags required for tests that mix C++ and D are now limited to
    only a small subset of tests, rather than applied to all tests across
    gdc.dg and gdc.test.
    
    Reviewed-on: https://github.com/dlang/dmd/pull/10980
    
    gcc/testsuite/ChangeLog:
    
            * gdc.test/runnable_cxx/runnable_cxx.exp: New file.
            * lib/gdc-utils.exp (gdc-do-test): Add case for runnable_cxx.
            * lib/gdc.exp (gdc_include_flags): Only add flags for libstdc++-v3 if
            GDC_INCLUDE_CXX_FLAGS is true.
            (gdc_link_flags): Likewise.
            (gdc_init): Move setting of default gdc test flags to...
            (gdc_target_compile): ...here.

Diff:
---
 gcc/d/dmd/MERGE                                    |   2 +-
 gcc/testsuite/ChangeLog                            |  10 ++
 .../gdc.test/{runnable => runnable_cxx}/cabi1.d    |   0
 .../{runnable => runnable_cxx}/cpp_abi_tests.d     |   0
 .../gdc.test/{runnable => runnable_cxx}/cppa.d     |   0
 .../{runnable => runnable_cxx}/externmangle.d      |   0
 .../{runnable => runnable_cxx}/externmangle2.d     |   0
 .../extra-files/cabi2.cpp                          |   0
 .../extra-files/cpp_abi_tests.cpp                  |   0
 .../extra-files/cppb.cpp                           |   0
 .../extra-files/externmangle.cpp                   |   0
 .../extra-files/externmangle2.cpp                  |   0
 .../gdc.test/runnable_cxx/runnable_cxx.exp         |  46 +++++++++
 gcc/testsuite/lib/gdc-utils.exp                    |   1 +
 gcc/testsuite/lib/gdc.exp                          | 106 +++++++++++++--------
 15 files changed, 122 insertions(+), 43 deletions(-)

diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index a421448a287..7f0140708c6 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-d1a606599e7c2bea8fda8bf5e3ddceb486ae69ac
+3e10e2dd29e583f1d94d84de5e4bd858e0303669
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cd57ba6f5d3..498c2a9e062 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2020-03-29  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	* gdc.test/runnable_cxx/runnable_cxx.exp: New file.
+	* lib/gdc-utils.exp (gdc-do-test): Add case for runnable_cxx.
+	* lib/gdc.exp (gdc_include_flags): Only add flags for libstdc++-v3 if
+	GDC_INCLUDE_CXX_FLAGS is true.
+	(gdc_link_flags): Likewise.
+	(gdc_init): Move setting of default gdc test flags to...
+	(gdc_target_compile): ...here.
+
 2020-03-29  Iain Buclaw  <ibuclaw@gdcproject.org>
 
 	* gdc.test/compilable/compilable.exp: New file.
diff --git a/gcc/testsuite/gdc.test/runnable/cabi1.d b/gcc/testsuite/gdc.test/runnable_cxx/cabi1.d
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/cabi1.d
rename to gcc/testsuite/gdc.test/runnable_cxx/cabi1.d
diff --git a/gcc/testsuite/gdc.test/runnable/cpp_abi_tests.d b/gcc/testsuite/gdc.test/runnable_cxx/cpp_abi_tests.d
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/cpp_abi_tests.d
rename to gcc/testsuite/gdc.test/runnable_cxx/cpp_abi_tests.d
diff --git a/gcc/testsuite/gdc.test/runnable/cppa.d b/gcc/testsuite/gdc.test/runnable_cxx/cppa.d
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/cppa.d
rename to gcc/testsuite/gdc.test/runnable_cxx/cppa.d
diff --git a/gcc/testsuite/gdc.test/runnable/externmangle.d b/gcc/testsuite/gdc.test/runnable_cxx/externmangle.d
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/externmangle.d
rename to gcc/testsuite/gdc.test/runnable_cxx/externmangle.d
diff --git a/gcc/testsuite/gdc.test/runnable/externmangle2.d b/gcc/testsuite/gdc.test/runnable_cxx/externmangle2.d
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/externmangle2.d
rename to gcc/testsuite/gdc.test/runnable_cxx/externmangle2.d
diff --git a/gcc/testsuite/gdc.test/runnable/extra-files/cabi2.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cabi2.cpp
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/extra-files/cabi2.cpp
rename to gcc/testsuite/gdc.test/runnable_cxx/extra-files/cabi2.cpp
diff --git a/gcc/testsuite/gdc.test/runnable/extra-files/cpp_abi_tests.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp_abi_tests.cpp
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/extra-files/cpp_abi_tests.cpp
rename to gcc/testsuite/gdc.test/runnable_cxx/extra-files/cpp_abi_tests.cpp
diff --git a/gcc/testsuite/gdc.test/runnable/extra-files/cppb.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/cppb.cpp
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/extra-files/cppb.cpp
rename to gcc/testsuite/gdc.test/runnable_cxx/extra-files/cppb.cpp
diff --git a/gcc/testsuite/gdc.test/runnable/extra-files/externmangle.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/externmangle.cpp
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/extra-files/externmangle.cpp
rename to gcc/testsuite/gdc.test/runnable_cxx/extra-files/externmangle.cpp
diff --git a/gcc/testsuite/gdc.test/runnable/extra-files/externmangle2.cpp b/gcc/testsuite/gdc.test/runnable_cxx/extra-files/externmangle2.cpp
similarity index 100%
rename from gcc/testsuite/gdc.test/runnable/extra-files/externmangle2.cpp
rename to gcc/testsuite/gdc.test/runnable_cxx/extra-files/externmangle2.cpp
diff --git a/gcc/testsuite/gdc.test/runnable_cxx/runnable_cxx.exp b/gcc/testsuite/gdc.test/runnable_cxx/runnable_cxx.exp
new file mode 100644
index 00000000000..a37376a4dc2
--- /dev/null
+++ b/gcc/testsuite/gdc.test/runnable_cxx/runnable_cxx.exp
@@ -0,0 +1,46 @@
+# Copyright (C) 2012-2020 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Runnable C++ tests for the D2 testsuite.
+
+# Load support procs.
+load_lib gdc-dg.exp
+load_lib gdc-utils.exp
+
+# If the D runtime library is missing, bail.
+if { ![check_effective_target_d_runtime] } {
+    return
+}
+
+# We are mixing D and C++ code, need to pull in libstdc++
+global GDC_INCLUDE_CXX_FLAGS
+set GDC_INCLUDE_CXX_FLAGS 1
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+if [check_no_compiler_messages extern_c++_tests assembly {
+   // C++
+   int main() { return 0; }
+}] {
+    gdc-do-test [glob -nocomplain $srcdir/$subdir/*.d]
+}
+
+set GDC_INCLUDE_CXX_FLAGS 0
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/lib/gdc-utils.exp b/gcc/testsuite/lib/gdc-utils.exp
index 298c6a733a6..ab8b9d5f838 100644
--- a/gcc/testsuite/lib/gdc-utils.exp
+++ b/gcc/testsuite/lib/gdc-utils.exp
@@ -404,6 +404,7 @@ proc gdc-do-test { testcases } {
 	set options [gdc-permute-options [lsort -unique $PERMUTE_ARGS]]
 
 	switch $dir {
+	    runnable_cxx -
 	    runnable {
 		for { set i 0 } { $i<[llength $options] } { incr i } {
 		    set flags [lindex $options $i]
diff --git a/gcc/testsuite/lib/gdc.exp b/gcc/testsuite/lib/gdc.exp
index 5d698749f0d..ddc6d9026a2 100644
--- a/gcc/testsuite/lib/gdc.exp
+++ b/gcc/testsuite/lib/gdc.exp
@@ -69,6 +69,7 @@ proc gdc_version { } {
 
 proc gdc_include_flags { paths } {
     global srcdir
+    global GDC_INCLUDE_CXX_FLAGS
     global TESTING_IN_BUILD_TREE
 
     set flags ""
@@ -77,6 +78,12 @@ proc gdc_include_flags { paths } {
 	return "${flags}"
     }
 
+    if [info exists GDC_INCLUDE_CXX_FLAGS] {
+	set include_cxx_flags $GDC_INCLUDE_CXX_FLAGS
+    } else {
+	set include_cxx_flags 0
+    }
+
     set gccpath ${paths}
 
     if { $gccpath != "" } {
@@ -88,11 +95,13 @@ proc gdc_include_flags { paths } {
     append flags "-I${srcdir}/../../libphobos/src "
 
     # For the tests that mix C++ and D, need to know where headers are located.
-    set odir [lookfor_file ${gccpath} libstdc++-v3]
-    if { ${odir} != "" } {
-	set cxxflags [exec sh ${odir}/scripts/testsuite_flags --build-includes]
-	set idx [lsearch $cxxflags "-nostdinc++"]
-	append flags [lreplace $cxxflags $idx $idx]
+    if $include_cxx_flags {
+	set odir [lookfor_file ${gccpath} libstdc++-v3]
+	if { ${odir} != "" && [file exists ${odir}/scripts/testsuite_flags] } {
+	    set cxxflags [exec sh ${odir}/scripts/testsuite_flags --build-includes]
+	    set idx [lsearch $cxxflags "-nostdinc++"]
+	    append flags [lreplace $cxxflags $idx $idx]
+	}
     }
 
     return "$flags"
@@ -106,6 +115,7 @@ proc gdc_link_flags { paths } {
     global srcdir
     global ld_library_path
     global GDC_UNDER_TEST
+    global GDC_INCLUDE_CXX_FLAGS
     global shlib_ext
     global SHARED_OPTION
 
@@ -117,6 +127,12 @@ proc gdc_link_flags { paths } {
     set SHARED_OPTION ""
     verbose "shared lib extension: $shlib_ext"
 
+    if [info exists GDC_INCLUDE_CXX_FLAGS] {
+	set include_cxx_flags $GDC_INCLUDE_CXX_FLAGS
+    } else {
+	set include_cxx_flags 0
+    }
+
     if { $gccpath != "" } {
 	# Path to libgphobos.spec.
 	append flags "-B${gccpath}/libphobos/src "
@@ -148,11 +164,13 @@ proc gdc_link_flags { paths } {
 	if [file exists "${gccpath}/libiberty/libiberty.a"] {
 	    append flags "-L${gccpath}/libiberty "
 	}
-	# For the tests that mix C++ and D, we should try and handle this better.
-	if { [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] \
-	     || [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] } {
-	    append flags "-L${gccpath}/libstdc++-v3/src/.libs "
-	    append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
+	# For the tests that mix C++ and D, need to know where library is located.
+	if $include_cxx_flags {
+	    if { [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] \
+		 || [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] } {
+		append flags "-L${gccpath}/libstdc++-v3/src/.libs "
+		append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
+	    }
 	}
 	append ld_library_path [gcc-set-multilib-library-path $GDC_UNDER_TEST]
     } else {
@@ -172,6 +190,13 @@ proc gdc_link_flags { paths } {
 	if { $libiberty != "" } {
 	    append flags "-L${libiberty} "
 	}
+	if $include_cxx_flags {
+	    set libstdcpp [lookfor_file ${tool_root_dir} libstdc++]
+	    if { $libstdcpp != "" } {
+		append flags "-L${libstdcpp} "
+		append ld_library_path ":${libstdcpp}"
+	    }
+	}
     }
 
     set_ld_library_path_env_vars
@@ -184,18 +209,14 @@ proc gdc_link_flags { paths } {
 #
 
 proc gdc_init { args } {
-    global subdir
     global gdc_initialized
     global base_dir
     global tmpdir
     global libdir
     global gluefile wrap_flags
-    global objdir srcdir
-    global ALWAYS_DFLAGS
-    global TOOL_EXECUTABLE TOOL_OPTIONS
+    global TOOL_EXECUTABLE
     global GDC_UNDER_TEST
     global TESTING_IN_BUILD_TREE
-    global TEST_ALWAYS_FLAGS
     global gcc_warning_prefix
     global gcc_error_prefix
 
@@ -231,31 +252,6 @@ proc gdc_init { args } {
 
     gdc_maybe_build_wrapper "${tmpdir}/d-testglue.o"
 
-    set ALWAYS_DFLAGS ""
-
-    # TEST_ALWAYS_FLAGS are flags that should be passed to every
-    # compilation.  They are passed first to allow individual
-    # tests to override them.
-    if [info exists TEST_ALWAYS_FLAGS] {
-	lappend ALWAYS_DFLAGS "additional_flags=$TEST_ALWAYS_FLAGS"
-    }
-
-    if ![is_remote host] {
-	if [info exists TOOL_OPTIONS] {
-	    lappend ALWAYS_DFLAGS "additional_flags=[gdc_include_flags [get_multilibs ${TOOL_OPTIONS}] ]"
-	    lappend ALWAYS_DFLAGS "ldflags=[gdc_link_flags [get_multilibs ${TOOL_OPTIONS}] ]"
-	} else {
-	    lappend ALWAYS_DFLAGS "additional_flags=[gdc_include_flags [get_multilibs] ]"
-	    lappend ALWAYS_DFLAGS "ldflags=[gdc_link_flags [get_multilibs] ]"
-	}
-    }
-
-    if [info exists TOOL_OPTIONS] {
-	lappend ALWAYS_DFLAGS "additional_flags=$TOOL_OPTIONS"
-    }
-
-    verbose -log "ALWAYS_DFLAGS set to $ALWAYS_DFLAGS"
-
     set gcc_warning_prefix "warning:"
     set gcc_error_prefix "(fatal )?error:"
 
@@ -269,18 +265,44 @@ proc gdc_init { args } {
 proc gdc_target_compile { source dest type options } {
     global tmpdir
     global gluefile wrap_flags
-    global ALWAYS_DFLAGS
     global GDC_UNDER_TEST
+    global TOOL_OPTIONS
+    global TEST_ALWAYS_FLAGS
 
     if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
 	lappend options "libs=${gluefile}"
 	lappend options "ldflags=${wrap_flags}"
     }
 
+    set always_dflags ""
+
+    # TEST_ALWAYS_FLAGS are flags that should be passed to every
+    # compilation.  They are passed first to allow individual
+    # tests to override them.
+    if [info exists TEST_ALWAYS_FLAGS] {
+	lappend always_dflags "additional_flags=$TEST_ALWAYS_FLAGS"
+    }
+
+    if ![is_remote host] {
+	if [info exists TOOL_OPTIONS] {
+	    lappend always_dflags "additional_flags=[gdc_include_flags [get_multilibs ${TOOL_OPTIONS}] ]"
+	    lappend always_dflags "ldflags=[gdc_link_flags [get_multilibs ${TOOL_OPTIONS}] ]"
+	} else {
+	    lappend always_dflags "additional_flags=[gdc_include_flags [get_multilibs] ]"
+	    lappend always_dflags "ldflags=[gdc_link_flags [get_multilibs] ]"
+	}
+    }
+
+    if [info exists TOOL_OPTIONS] {
+	lappend always_dflags "additional_flags=$TOOL_OPTIONS"
+    }
+
+    verbose "always_dflags set to: $always_dflags"
+
     lappend options "timeout=[timeout_value]"
     lappend options "compiler=$GDC_UNDER_TEST"
 
-    set options [concat "$ALWAYS_DFLAGS" $options]
+    set options [concat "$always_dflags" $options]
     set options [dg-additional-files-options $options $source]
     return [target_compile $source $dest $type $options]
 }


More information about the Gcc-cvs mailing list