1# Copyright (C) 2011-2018 Free Software Foundation, Inc. 2# 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 2 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program; if not, write to the Free Software 15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 17load_lib libitm-dg.exp 18load_gcc_lib gcc-dg.exp 19 20global shlib_ext 21 22set shlib_ext [get_shlib_extension] 23# The C++ tests should be linked with g++, which defaults to -shared-libgcc. 24# Doing that is currently too intrusive, so hardcode here. 25set lang_link_flags "-shared-libgcc -lstdc++" 26set lang_test_file_found 0 27set lang_library_path "../libstdc++-v3/src/.libs" 28 29# Initialize dg. 30dg-init 31 32set blddir [lookfor_file [get_multilibs] libitm] 33 34 35if { $blddir != "" } { 36 # Look for a static libstdc++ first. 37 if [file exists "${blddir}/${lang_library_path}/libstdc++.a"] { 38 set lang_test_file "${lang_library_path}/libstdc++.a" 39 set lang_test_file_found 1 40 # We may have a shared only build, so look for a shared libstdc++. 41 } elseif [file exists "${blddir}/${lang_library_path}/libstdc++.${shlib_ext}"] { 42 set lang_test_file "${lang_library_path}/libstdc++.${shlib_ext}" 43 set lang_test_file_found 1 44 } else { 45 puts "No libstdc++ library found, will not execute c++ tests" 46 } 47} elseif { [info exists GXX_UNDER_TEST] } { 48 set lang_test_file_found 1 49 # Needs to exist for libitm.exp. 50 set lang_test_file "" 51} else { 52 puts "GXX_UNDER_TEST not defined, will not execute c++ tests" 53} 54 55if { $lang_test_file_found } { 56 # Gather a list of all tests. 57 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]] 58 59 if { $blddir != "" } { 60 set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}" 61 } else { 62 set ld_library_path "$always_ld_library_path" 63 } 64 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST] 65 set_ld_library_path_env_vars 66 67 set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags" 68 if { [file exists $flags_file] } { 69 set libstdcxx_includes [exec sh $flags_file --build-includes] 70 } else { 71 set libstdcxx_includes "" 72 } 73 74 # Main loop. 75 dg-runtest $tests "" $libstdcxx_includes 76} 77 78# All done. 79dg-finish 80