Add tests for mixed C/C++ unit test library usage
[dejagnu.git] / baseboards / multi-sim.exp
blob8c084cb72c06b607d527e02e3f2dfb0be4b60fd7
1 # Copyright (C) 2013-2016 Free Software Foundation, Inc.
3 # This file is part of DejaGnu.
5 # DejaGnu is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # DejaGnu is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with DejaGnu; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
19 # Contributed by Steve Ellcey <sellcey@mips.com>.
21 # With the generic-sim.exp baseboard I would test GCC with something
22 # like:
23 # export DEJAGNU_SIM_LINK_FLAGS="-Wl,--dynamic-linker=/local/home/sellcey/nightly/install-mips-mti-linux-gnu/sysroot-mips-mti-linux-gnu/usr/lib/ld-2.17.90.so -Wl,-rpath=/local/home/sellcey/nightly/install-mips-mti-linux-gnu/sysroot-mips-mti-linux-gnu/usr/lib:/local/home/sellcey/nightly/install-mips-mti-linux-gnu/mips-mti-linux-gnu/lib"
24 # make check RUNTESTFLAGS="--target_board=generic-sim"
26 # With multi-sim.exp I can skip the export and just do:
27 # make check RUNTESTFLAGS="--target_board=multi-sim"
29 # And I can also do this now:
30 # make check RUNTESTFLAGS="--target_board=multi-sim\{-EB,-EL\}\{-mhard-float,-msoft-float\}"
32 # Use env to check env. variables and modify the simulator.
33 global env
34 global SIM
36 # Load the generic configuration for this board. This will define a basic
37 # set of routines needed by the tool to communicate with the board.
38 load_generic_config "sim"
40 # basic-sim.exp is a basic description for the standard Cygnus simulator.
41 load_base_board_description "basic-sim"
43 proc get_library_dirlist { args } {
44 global board
45 set compiler "[board_info $board compiler]"
46 set mflags "[board_info $board multilib_flags]"
47 set result [remote_exec host "$compiler $mflags --print-search-dirs"]
48 set regresult [regexp {(libraries: =)(\S*)} $result dummy1 dummy2 libdirlist]
49 if {$regresult == 0} {
50 perror "Could not find compilers library search path."
52 return [split $libdirlist :]
55 proc dynamic_linker_flag { args } {
56 global board
57 set compiler "[board_info $board compiler]"
58 set mflags "[board_info $board multilib_flags]"
59 foreach i [get_library_dirlist] {
60 set dynlinker [glob -nocomplain -directory $i ld-*.so]
61 if { $dynlinker ne "" } break
63 verbose "dynamic_linker_flag: -Wl,--dynamic-linker=$dynlinker"
64 return "-Wl,--dynamic-linker=$dynlinker"
67 proc rpath_flags { args } {
68 global board
69 set compiler "[board_info $board compiler]"
70 set mflags "[board_info $board multilib_flags] [libgloss_include_flags] [newlib_include_flags] [libgloss_link_flags] [libgloss_link_flags]"
71 set rpathflags ""
72 set gccpath [get_multilibs]
73 foreach i {libgcc_s.so libstdc++.so libgfortran.so libatomic.so libgomp.so} {
74 set result [remote_exec host "$compiler $mflags --print-file-name=$i"]
75 set output [lindex $result 1]
76 set rpathdir [file dirname $output]
77 # If testing an installed compiler, --print-file-name will find the
78 # libraries, if testing a built but not installed compiler it will not
79 # find libraries like libstdc++.so or libgfortran.so so we add the
80 # extra hack/search so it can work.
81 if {$rpathdir eq "."} {
82 if {$i eq "libstdc++.so"} {
83 if {[file exists $gccpath/libstdc++-v3/src/.libs/libstdc++.so]} {
84 set rpathflags "$rpathflags -Wl,-rpath=$gccpath/libstdc++-v3/src/.libs"
87 if {$i eq "libgfortran.so"} {
88 if {[file exists $gccpath/libgfortran/.libs/libgfortran.so]} {
89 set rpathflags "$rpathflags -Wl,-rpath=$gccpath/libgfortran/.libs"
92 if {$i eq "libatomic.so"} {
93 if {[file exists $gccpath/libatomic/.libs/libatomic.so]} {
94 set rpathflags "$rpathflags -Wl,-rpath=$gccpath/libatomic/.libs"
97 if {$i eq "libgomp.so"} {
98 if {[file exists $gccpath/libgomp/.libs/libgomp.so]} {
99 set rpathflags "$rpathflags -Wl,-rpath=$gccpath/libgomp/.libs"
102 } else {
103 set rpathflags "$rpathflags -Wl,-rpath=$rpathdir"
106 foreach i [get_library_dirlist] {
107 set rpathflags "$rpathflags -Wl,-rpath=$i"
109 verbose "rpath_flags: $rpathflags"
110 return $rpathflags
113 # The TCL SIM variable takes precedence over the DEJAGNU_SIM env. variable
114 if {[info exists env(DEJAGNU_SIM)] && ![info exists SIM]} {
115 set SIM $env(DEJAGNU_SIM)
118 # This tells it which directory to look in for the simulator.
119 setup_sim sim
121 # No multilib flags are set by default.
122 if {[info exists env(DEJAGNU_SIM_MULTILIB_OPTIONS)]} {
123 process_multilib_options $env(DEJAGNU_SIM_MULTILIB_OPTIONS)
124 } else {
125 process_multilib_options ""
128 # The compiler used to build for this board. This has *nothing* to do
129 # with what compiler is tested if we're testing gcc.
130 if {[info exists env(DEJAGNU_SIM_GCC)]} {
131 set_board_info compiler $env(DEJAGNU_SIM_GCC)
132 } else {
133 set_board_info compiler "[find_gcc]"
136 if {[info exists env(DEJAGNU_SIM_INCLUDE_FLAGS)]} {
137 set_board_info cflags "[libgloss_include_flags] [newlib_include_flags] $env(DEJAGNU_SIM_INCLUDE_FLAGS)"
138 } else {
139 set_board_info cflags "[libgloss_include_flags] [newlib_include_flags]"
141 if {[info exists env(DEJAGNU_SIM_LINK_FLAGS)]} {
142 set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags] [dynamic_linker_flag] [rpath_flags] $env(DEJAGNU_SIM_LINK_FLAGS)"
143 } else {
144 set_board_info ldflags "[libgloss_link_flags] [newlib_link_flags] [dynamic_linker_flag] [rpath_flags]"
146 if {[info exists env(DEJAGNU_SIM_LDSCRIPT)]} {
147 set_board_info ldscript $env(DEJAGNU_SIM_LDSCRIPT)
149 if {[info exists env(DEJAGNU_SIM_OPTIONS)]} {
150 set_board_info sim,options $env(DEJAGNU_SIM_OPTIONS)
153 if {[info exists env(DEJAGNU_SIM_BOARD_INFO)]} {
154 foreach e $env(DEJAGNU_SIM_BOARD_INFO) {
155 set_board_info [lindex $e 0] [lindex $e 1]