OSDN Git Service

a0c675a7fe86dfc71d5398cf93e5d1ee2927025b
[pf3gnuchains/gcc-fork.git] / libgomp / testsuite / lib / libgomp-dg.exp
1 # Damn dejagnu for not having proper library search paths for load_lib.
2 # We have to explicitly load everything that gcc-dg.exp wants to load.
3
4 proc load_gcc_lib { filename } {
5     global srcdir loaded_libs
6
7     load_file $srcdir/../../gcc/testsuite/lib/$filename
8     set loaded_libs($filename) ""
9 }
10
11 load_lib dg.exp
12 load_gcc_lib file-format.exp
13 load_gcc_lib target-supports.exp
14 load_gcc_lib target-supports-dg.exp
15 load_gcc_lib scanasm.exp
16 load_gcc_lib scandump.exp
17 load_gcc_lib scantree.exp
18 load_gcc_lib scanipa.exp
19 load_gcc_lib prune.exp
20 load_gcc_lib target-libpath.exp
21 load_gcc_lib wrapper.exp
22 load_gcc_lib gcc-defs.exp
23 load_gcc_lib gcc-dg.exp
24 load_gcc_lib gfortran-dg.exp
25
26 set dg-do-what-default run
27
28 #
29 # GCC_UNDER_TEST is the compiler under test.
30 #
31
32 set libgomp_compile_options ""
33
34 #
35 # libgomp_init -- This gets run more than it should be....
36 #
37
38 if [info exists TOOL_OPTIONS] {
39     set multilibs [get_multilibs $TOOL_OPTIONS]
40 } else {
41     set multilibs [get_multilibs]
42 }
43 set blddir [lookfor_file $multilibs libgomp]
44
45 proc libgomp_init { args } {
46     global srcdir blddir objdir tool_root_dir
47     global libgomp_initialized
48     global tmpdir
49     global gluefile wrap_flags
50     global ALWAYS_CFLAGS
51     global CFLAGS
52     global TOOL_EXECUTABLE TOOL_OPTIONS
53     global GCC_UNDER_TEST
54     global TESTING_IN_BUILD_TREE
55     global target_triplet
56     global ld_library_path
57     global lang_test_file
58     global lang_library_path
59     global lang_link_flags
60
61     # We set LC_ALL and LANG to C so that we get the same error
62     # messages as expected.
63     setenv LC_ALL C
64     setenv LANG C
65
66     if ![info exists GCC_UNDER_TEST] then {
67         if [info exists TOOL_EXECUTABLE] {
68             set GCC_UNDER_TEST $TOOL_EXECUTABLE
69         } else {
70             set GCC_UNDER_TEST "[find_gcc]"
71         }
72     }
73
74     if ![info exists tmpdir] {
75         set tmpdir "/tmp"
76     }
77
78     if [info exists gluefile] {
79         unset gluefile
80     }
81
82     if {![info exists CFLAGS]} {
83         set CFLAGS ""
84     }
85
86     # Locate libgcc.a so we don't need to account for different values of
87     # SHLIB_EXT on different platforms
88     set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
89     if {$gccdir != ""} {
90         set gccdir [file dirname $gccdir]
91     }
92
93     # Compute what needs to be put into LD_LIBRARY_PATH
94     set ld_library_path ".:${blddir}/.libs"
95
96     if {$gccdir != ""} {
97         append ld_library_path ":${gccdir}"
98     }
99
100     if { [info exists lang_test_file] && [file exists "${blddir}/"] } {
101         append ld_library_path ":${blddir}/${lang_library_path}"
102     }
103     append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
104     set_ld_library_path_env_vars
105
106     set ALWAYS_CFLAGS ""
107     lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
108     lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
109     lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
110     lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs -lgomp"
111     if { [info exists lang_test_file] && [file exists "${blddir}/"] } {
112         lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${lang_library_path} ${lang_link_flags}"
113     }
114
115     # We use atomic operations in the testcases to validate results.
116     if [istarget i?86-*-*] {
117         lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
118     }
119     if [istarget sparc*-*-*] {
120         lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9"
121     }
122
123     if [info exists TOOL_OPTIONS] {
124         lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
125     }
126
127     # Make sure that lines are not wrapped.  That can confuse the
128     # error-message parsing machinery.
129     lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
130
131     # And, gee, turn on OpenMP.
132     lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
133 }
134
135 #
136 # libgomp_target_compile -- compile a source file
137 #
138
139 proc libgomp_target_compile { source dest type options } {
140     global tmpdir
141     global libgomp_compile_options
142     global gluefile wrap_flags
143     global ALWAYS_CFLAGS
144     global GCC_UNDER_TEST
145
146     libgomp_init
147
148     if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
149         lappend options "libs=${gluefile}"
150         lappend options "ldflags=${wrap_flags}"
151     }
152
153     lappend options "additional_flags=[libio_include_flags]"
154     lappend options "compiler=$GCC_UNDER_TEST"
155
156     set options [concat $libgomp_compile_options $options]
157
158     set options [concat "$ALWAYS_CFLAGS" $options]
159
160     set options [dg-additional-files-options $options $source]
161
162     set result [target_compile $source $dest $type $options]
163
164     return $result
165 }
166
167 # ??? The same as in standard.exp.  Why doesn't anyone else have to 
168 # define this?
169
170 proc libgomp_load { program args } {
171     if { [llength $args] > 0 } {
172         set program_args [lindex $args 0]
173     } else {
174         set program_args ""
175     }
176
177     if { [llength $args] > 1 } {
178         set input_file [lindex $args 1]
179     } else {
180         set input_file ""
181     }
182     return [remote_load target $program $program_args $input_file]
183 }
184
185 proc libgomp_option_help { } {
186     send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
187 }
188
189 proc libgomp_option_proc { option } {
190     if [regexp "^--additional_options," $option] {
191         global libgomp_compile_options
192         regsub "--additional_options," $option "" option
193         foreach x [split $option ","] {
194             lappend libgomp_compile_options "additional_flags=$x"
195         }
196         return 1
197     } else {
198         return 0
199     }
200 }
201
202 proc libgomp-dg-test { prog do_what extra_tool_flags } {
203     return [gcc-dg-test-1 libgomp_target_compile $prog $do_what $extra_tool_flags]
204 }
205
206 proc libgomp-dg-prune { system text } {
207     return [gcc-dg-prune $system $text]
208 }