]> git.ipfire.org Git - thirdparty/gcc.git/blob - libvtv/testsuite/lib/libvtv.exp
Update libvtv testsuite so that most of the tests now run under
[thirdparty/gcc.git] / libvtv / testsuite / lib / libvtv.exp
1 # This program is free software; you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation; either version 2 of the License, or
4 # (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software
13 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14
15 # Damn dejagnu for not having proper library search paths for load_lib.
16 # We have to explicitly load everything that gcc-dg.exp wants to load.
17
18 proc load_gcc_lib { filename } {
19 global srcdir loaded_libs
20
21 load_file $srcdir/../../gcc/testsuite/lib/$filename
22 set loaded_libs($filename) ""
23 }
24
25 load_lib dg.exp
26 load_gcc_lib file-format.exp
27 load_gcc_lib target-supports.exp
28 load_gcc_lib target-supports-dg.exp
29 load_gcc_lib scanasm.exp
30 load_gcc_lib scandump.exp
31 load_gcc_lib scanrtl.exp
32 load_gcc_lib scantree.exp
33 load_gcc_lib scanipa.exp
34 load_gcc_lib prune.exp
35 load_gcc_lib target-libpath.exp
36 load_gcc_lib wrapper.exp
37 load_gcc_lib gcc-defs.exp
38 load_gcc_lib torture-options.exp
39 load_gcc_lib timeout.exp
40 load_gcc_lib timeout-dg.exp
41 load_gcc_lib fortran-modules.exp
42 load_gcc_lib gcc-dg.exp
43
44 set dg-do-what-default run
45
46 #
47 # GCC_UNDER_TEST is the compiler under test.
48 #
49
50 set libvtv_compile_options ""
51
52 #
53 # libvtv_init
54 #
55
56 if [info exists TOOL_OPTIONS] {
57 set multilibs [get_multilibs $TOOL_OPTIONS]
58 } else {
59 set multilibs [get_multilibs]
60 }
61
62 proc libvtv_init { args } {
63 global srcdir blddir objdir tool_root_dir
64 global libvtv_initialized
65 global tmpdir
66 global blddir
67 global gluefile wrap_flags
68 global ALWAYS_CFLAGS
69 global CFLAGS
70 global TOOL_EXECUTABLE TOOL_OPTIONS
71 global GCC_UNDER_TEST
72 global TESTING_IN_BUILD_TREE
73 global target_triplet
74 global always_ld_library_path
75
76 set blddir [lookfor_file [get_multilibs] libvtv]
77
78 # We set LC_ALL and LANG to C so that we get the same error
79 # messages as expected.
80 setenv LC_ALL C
81 setenv LANG C
82
83 if ![info exists GCC_UNDER_TEST] then {
84 if [info exists TOOL_EXECUTABLE] {
85 set GCC_UNDER_TEST $TOOL_EXECUTABLE
86 } else {
87 set GCC_UNDER_TEST "[find_gcc]"
88 }
89 }
90
91 if ![info exists tmpdir] {
92 set tmpdir "/tmp"
93 }
94
95 if [info exists gluefile] {
96 unset gluefile
97 }
98
99 if {![info exists CFLAGS]} {
100 set CFLAGS ""
101 }
102
103 # Locate libgcc.a so we don't need to account for different values of
104 # SHLIB_EXT on different platforms
105 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
106 if {$gccdir != ""} {
107 set gccdir [file dirname $gccdir]
108 }
109
110 # Compute what needs to be put into LD_LIBRARY_PATH
111 set always_ld_library_path ".:${blddir}/.libs"
112
113 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
114 if {$gccdir != ""} {
115 # Add AIX pthread directory first.
116 if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
117 append always_ld_library_path ":${gccdir}/pthread"
118 }
119 append always_ld_library_path ":${gccdir}"
120 set compiler [lindex $GCC_UNDER_TEST 0]
121
122 if { [is_remote host] == 0 && [which $compiler] != 0 } {
123 foreach i "[exec $compiler --print-multi-lib]" {
124 set mldir ""
125 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
126 set mldir [string trimright $mldir "\;@"]
127 if { "$mldir" == "." } {
128 continue
129 }
130 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
131 append always_ld_library_path ":${gccdir}/${mldir}"
132 }
133 }
134 }
135 }
136
137 set ALWAYS_CFLAGS ""
138 if { $blddir != "" } {
139 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
140 lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
141 lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
142 }
143 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
144
145 if [istarget *-*-darwin*] {
146 lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
147 }
148
149 if [info exists TOOL_OPTIONS] {
150 lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
151 }
152
153 # Make sure that lines are not wrapped. That can confuse the
154 # error-message parsing machinery.
155 lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
156
157 # Turn on vtable verification
158 lappend ALWAYS_CFLAGS "-fvtable-verify=std"
159 # lappend ALWAYS_CFLAGS "ldflags=-lvtv"
160 }
161
162 #
163 # libvtv_target_compile -- compile a source file
164 #
165
166 proc libvtv_target_compile { source dest type options } {
167 global blddir
168 global libvtv_compile_options
169 global gluefile wrap_flags
170 global ALWAYS_CFLAGS
171 global GCC_UNDER_TEST
172 global lang_test_file
173 global lang_library_path
174 global lang_link_flags
175
176 if { [info exists lang_test_file] } {
177 if { $blddir != "" } {
178 lappend options "ldflags=-L${blddir}/${lang_library_path}"
179 }
180 lappend options "ldflags=${lang_link_flags}"
181 }
182
183 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
184 lappend options "libs=${gluefile}"
185 lappend options "ldflags=${wrap_flags}"
186 }
187
188 lappend options "additional_flags=[libio_include_flags]"
189 lappend options "timeout=[timeout_value]"
190 lappend options "compiler=$GCC_UNDER_TEST"
191
192 set options [concat $libvtv_compile_options $options]
193
194 if [info exists ALWAYS_CFLAGS] {
195 set options [concat "$ALWAYS_CFLAGS" $options]
196 }
197
198 set options [dg-additional-files-options $options $source]
199
200 set result [target_compile $source $dest $type $options]
201
202 return $result
203 }
204
205 proc libvtv_option_help { } {
206 send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
207 }
208
209 proc libvtv_option_proc { option } {
210 if [regexp "^--additional_options," $option] {
211 global libvtv_compile_options
212 regsub "--additional_options," $option "" option
213 foreach x [split $option ","] {
214 lappend libvtv_compile_options "additional_flags=$x"
215 }
216 return 1
217 } else {
218 return 0
219 }
220 }