1 |
12 |
jlechner |
# Copyright (C) 1992-1998, 1999, 2000 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
16 |
|
|
|
17 |
|
|
# This file was written by Rob Savoye. (rob@cygnus.com)
|
18 |
|
|
|
19 |
|
|
load_lib file-format.exp
|
20 |
|
|
|
21 |
|
|
# The default option list can be overridden by
|
22 |
|
|
# TORTURE_OPTIONS="{ { list1 } ... { listN } }"
|
23 |
|
|
|
24 |
|
|
if ![info exists OBJC_RUNTIME_OPTIONS] {
|
25 |
|
|
set OBJC_RUNTIME_OPTIONS ""
|
26 |
|
|
foreach type {-fgnu-runtime -fnext-runtime} {
|
27 |
|
|
global srcdir subdir
|
28 |
|
|
|
29 |
|
|
set comp_output [objc_target_compile \
|
30 |
|
|
"$srcdir/$subdir/trivial.m" "trivial.exe" executable "additional_flags=$type"]
|
31 |
|
|
|
32 |
|
|
# If we get any error, then we failed
|
33 |
|
|
if ![string match "" $comp_output] then {
|
34 |
|
|
continue;
|
35 |
|
|
}
|
36 |
|
|
lappend OBJC_RUNTIME_OPTIONS $type
|
37 |
|
|
}
|
38 |
|
|
}
|
39 |
|
|
verbose -log "Using the following runtimes: $OBJC_RUNTIME_OPTIONS"
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
if ![info exists TORTURE_OPTIONS] {
|
43 |
|
|
# It is theoretically beneficial to group all of the O2/O3 options together,
|
44 |
|
|
# as in many cases the compiler will generate identical executables for
|
45 |
|
|
# all of them--and the objc-torture testsuite will skip testing identical
|
46 |
|
|
# executables multiple times.
|
47 |
|
|
# Also note that -finline-functions is explicitly included in one of the
|
48 |
|
|
# items below, even though -O3 is also specified, because some ports may
|
49 |
|
|
# choose to disable inlining functions by default, even when optimizing.
|
50 |
|
|
set TORTURE_OPTIONS [list \
|
51 |
|
|
" -O0 " \
|
52 |
|
|
" -O1 " \
|
53 |
|
|
" -O2 " \
|
54 |
|
|
" -O3 -fomit-frame-pointer " \
|
55 |
|
|
" -O3 -fomit-frame-pointer -funroll-loops " \
|
56 |
|
|
" -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions " \
|
57 |
|
|
" -O3 -g " \
|
58 |
|
|
" -Os " ]
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
# Split TORTURE_OPTIONS into two choices: one for testcases with loops and
|
63 |
|
|
# one for testcases without loops. Add in the objc runtime options also.
|
64 |
|
|
|
65 |
|
|
set torture_with_loops ""
|
66 |
|
|
set torture_without_loops ""
|
67 |
|
|
foreach objc_option $OBJC_RUNTIME_OPTIONS {
|
68 |
|
|
foreach option $TORTURE_OPTIONS {
|
69 |
|
|
|
70 |
|
|
if ![string match "*loop*" $option] {
|
71 |
|
|
lappend torture_without_loops "$option $objc_option"
|
72 |
|
|
}
|
73 |
|
|
lappend torture_with_loops "$option $objc_option"
|
74 |
|
|
}
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
#
|
79 |
|
|
# objc-torture-compile -- runs the Tege OBJC-torture test
|
80 |
|
|
#
|
81 |
|
|
# SRC is the full pathname of the testcase.
|
82 |
|
|
# OPTION is the specific compiler flag we're testing (eg: -O2).
|
83 |
|
|
#
|
84 |
|
|
proc objc-torture-compile { src option } {
|
85 |
|
|
global output
|
86 |
|
|
global srcdir tmpdir
|
87 |
|
|
global host_triplet
|
88 |
|
|
|
89 |
|
|
set output "$tmpdir/[file tail [file rootname $src]].o"
|
90 |
|
|
|
91 |
|
|
regsub "^$srcdir/?" $src "" testcase
|
92 |
|
|
# If we couldn't rip $srcdir out of `src' then just do the best we can.
|
93 |
|
|
# The point is to reduce the unnecessary noise in the logs. Don't strip
|
94 |
|
|
# out too much because different testcases with the same name can confuse
|
95 |
|
|
# `test-tool'.
|
96 |
|
|
if [string match "/*" $testcase] {
|
97 |
|
|
set testcase "[file tail [file dirname $src]]/[file tail $src]"
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
verbose "Testing $testcase, $option" 1
|
101 |
|
|
|
102 |
|
|
# Run the compiler and analyze the results.
|
103 |
|
|
set options ""
|
104 |
|
|
lappend options "additional_flags=-w $option"
|
105 |
|
|
|
106 |
|
|
set comp_output [objc_target_compile "$src" "$output" object $options]
|
107 |
|
|
objc_check_compile $testcase $option $output $comp_output
|
108 |
|
|
remote_file build delete $output
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
#
|
112 |
|
|
# objc-torture-execute -- utility to compile and execute a testcase
|
113 |
|
|
#
|
114 |
|
|
# SRC is the full pathname of the testcase.
|
115 |
|
|
#
|
116 |
|
|
# If the testcase has an associated .x file, we source that to run the
|
117 |
|
|
# test instead. We use .x so that we don't lengthen the existing filename
|
118 |
|
|
# to more than 14 chars.
|
119 |
|
|
#
|
120 |
|
|
proc objc-torture-execute { src args } {
|
121 |
|
|
global tmpdir tool srcdir output compiler_conditional_xfail_data
|
122 |
|
|
|
123 |
|
|
if { [llength $args] > 0 } {
|
124 |
|
|
set additional_flags [lindex $args 0]
|
125 |
|
|
} else {
|
126 |
|
|
set additional_flags ""
|
127 |
|
|
}
|
128 |
|
|
# Check for alternate driver.
|
129 |
|
|
if [file exists [file rootname $src].x] {
|
130 |
|
|
verbose "Using alternate driver [file rootname [file tail $src]].x" 2
|
131 |
|
|
set done_p 0
|
132 |
|
|
catch "set done_p \[source [file rootname $src].x\]"
|
133 |
|
|
if { $done_p } {
|
134 |
|
|
return
|
135 |
|
|
}
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
# Look for a loop within the source code - if we don't find one,
|
139 |
|
|
# don't pass -funroll[-all]-loops.
|
140 |
|
|
global torture_with_loops torture_without_loops
|
141 |
|
|
if [expr [search_for $src "for*("]+[search_for $src "while*("]] then {
|
142 |
|
|
set option_list $torture_with_loops
|
143 |
|
|
} else {
|
144 |
|
|
set option_list $torture_without_loops
|
145 |
|
|
}
|
146 |
|
|
|
147 |
|
|
set executable $tmpdir/[file tail [file rootname $src].x]
|
148 |
|
|
|
149 |
|
|
regsub "^$srcdir/?" $src "" testcase
|
150 |
|
|
# If we couldn't rip $srcdir out of `src' then just do the best we can.
|
151 |
|
|
# The point is to reduce the unnecessary noise in the logs. Don't strip
|
152 |
|
|
# out too much because different testcases with the same name can confuse
|
153 |
|
|
# `test-tool'.
|
154 |
|
|
if [string match "/*" $testcase] {
|
155 |
|
|
set testcase "[file tail [file dirname $src]]/[file tail $src]"
|
156 |
|
|
}
|
157 |
|
|
|
158 |
|
|
set count 0
|
159 |
|
|
set oldstatus "foo"
|
160 |
|
|
foreach option $option_list {
|
161 |
|
|
if { $count > 0 } {
|
162 |
|
|
set oldexec $execname
|
163 |
|
|
}
|
164 |
|
|
set execname "${executable}${count}"
|
165 |
|
|
incr count
|
166 |
|
|
|
167 |
|
|
# torture_{compile,execute}_xfail are set by the .x script
|
168 |
|
|
# (if present)
|
169 |
|
|
if [info exists torture_compile_xfail] {
|
170 |
|
|
setup_xfail $torture_compile_xfail
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
# torture_execute_before_{compile,execute} can be set by the .x script
|
174 |
|
|
# (if present)
|
175 |
|
|
if [info exists torture_eval_before_compile] {
|
176 |
|
|
set ignore_me [eval $torture_eval_before_compile]
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
remote_file build delete $execname
|
180 |
|
|
verbose "Testing $testcase, $option" 1
|
181 |
|
|
|
182 |
|
|
set options ""
|
183 |
|
|
lappend options "additional_flags=-w $option"
|
184 |
|
|
if { $additional_flags != "" } {
|
185 |
|
|
lappend options "additional_flags=$additional_flags"
|
186 |
|
|
}
|
187 |
|
|
set comp_output [objc_target_compile "$src" "${execname}" executable $options]
|
188 |
|
|
|
189 |
|
|
if ![objc_check_compile "$testcase compilation" $option $execname $comp_output] {
|
190 |
|
|
unresolved "$testcase execution, $option"
|
191 |
|
|
remote_file build delete $execname
|
192 |
|
|
continue
|
193 |
|
|
}
|
194 |
|
|
|
195 |
|
|
# See if this source file uses "long long" types, if it does, and
|
196 |
|
|
# no_long_long is set, skip execution of the test.
|
197 |
|
|
if [target_info exists no_long_long] then {
|
198 |
|
|
if [expr [search_for $src "long long"]] then {
|
199 |
|
|
unsupported "$testcase execution, $option"
|
200 |
|
|
continue
|
201 |
|
|
}
|
202 |
|
|
}
|
203 |
|
|
|
204 |
|
|
if [info exists torture_execute_xfail] {
|
205 |
|
|
setup_xfail $torture_execute_xfail
|
206 |
|
|
}
|
207 |
|
|
|
208 |
|
|
if [info exists torture_eval_before_execute] {
|
209 |
|
|
set ignore_me [eval $torture_eval_before_execute]
|
210 |
|
|
}
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
# Sometimes we end up creating identical executables for two
|
214 |
|
|
# consecutive sets of different of compiler options.
|
215 |
|
|
#
|
216 |
|
|
# In such cases we know the result of this test will be identical
|
217 |
|
|
# to the result of the last test.
|
218 |
|
|
#
|
219 |
|
|
# So in cases where the time to load and run/simulate the test
|
220 |
|
|
# is relatively high, compare the two binaries and avoid rerunning
|
221 |
|
|
# tests if the executables are identical.
|
222 |
|
|
#
|
223 |
|
|
# Do not do this for native testing since the cost to load/execute
|
224 |
|
|
# the test is fairly small and the comparison step actually slows
|
225 |
|
|
# the entire process down because it usually does not "hit".
|
226 |
|
|
set skip 0
|
227 |
|
|
if { ![isnative] && [info exists oldexec] } {
|
228 |
|
|
if { [remote_file build cmp $oldexec $execname] == 0 } {
|
229 |
|
|
set skip 1
|
230 |
|
|
}
|
231 |
|
|
}
|
232 |
|
|
if { $skip == 0 } {
|
233 |
|
|
set result [objc_load "$execname" "" ""]
|
234 |
|
|
set status [lindex $result 0]
|
235 |
|
|
set output [lindex $result 1]
|
236 |
|
|
}
|
237 |
|
|
if { $oldstatus == "pass" } {
|
238 |
|
|
remote_file build delete $oldexec
|
239 |
|
|
}
|
240 |
|
|
$status "$testcase execution, $option"
|
241 |
|
|
set oldstatus $status
|
242 |
|
|
}
|
243 |
|
|
if [info exists status] {
|
244 |
|
|
if { $status == "pass" } {
|
245 |
|
|
remote_file build delete $execname
|
246 |
|
|
}
|
247 |
|
|
}
|
248 |
|
|
}
|
249 |
|
|
|
250 |
|
|
#
|
251 |
|
|
# search_for -- looks for a string match in a file
|
252 |
|
|
#
|
253 |
|
|
proc search_for { file pattern } {
|
254 |
|
|
set fd [open $file r]
|
255 |
|
|
while { [gets $fd cur_line]>=0 } {
|
256 |
|
|
if [string match "*$pattern*" $cur_line] then {
|
257 |
|
|
close $fd
|
258 |
|
|
return 1
|
259 |
|
|
}
|
260 |
|
|
}
|
261 |
|
|
close $fd
|
262 |
|
|
return 0
|
263 |
|
|
}
|
264 |
|
|
|
265 |
|
|
#
|
266 |
|
|
# objc-torture -- the objc-torture testcase source file processor
|
267 |
|
|
#
|
268 |
|
|
# This runs compilation only tests (no execute tests).
|
269 |
|
|
# SRC is the full pathname of the testcase, or just a file name in which case
|
270 |
|
|
# we prepend $srcdir/$subdir.
|
271 |
|
|
#
|
272 |
|
|
# If the testcase has an associated .x file, we source that to run the
|
273 |
|
|
# test instead. We use .x so that we don't lengthen the existing filename
|
274 |
|
|
# to more than 14 chars.
|
275 |
|
|
#
|
276 |
|
|
proc objc-torture { args } {
|
277 |
|
|
global srcdir subdir compiler_conditional_xfail_data
|
278 |
|
|
|
279 |
|
|
set src [lindex $args 0]
|
280 |
|
|
if { [llength $args] > 1 } {
|
281 |
|
|
set options [lindex $args 1]
|
282 |
|
|
} else {
|
283 |
|
|
set options ""
|
284 |
|
|
}
|
285 |
|
|
|
286 |
|
|
# Prepend $srdir/$subdir if missing.
|
287 |
|
|
if ![string match "*/*" $src] {
|
288 |
|
|
set src "$srcdir/$subdir/$src"
|
289 |
|
|
}
|
290 |
|
|
|
291 |
|
|
# Check for alternate driver.
|
292 |
|
|
if [file exists [file rootname $src].x] {
|
293 |
|
|
verbose "Using alternate driver [file rootname [file tail $src]].x" 2
|
294 |
|
|
set done_p 0
|
295 |
|
|
catch "set done_p \[source [file rootname $src].x\]"
|
296 |
|
|
if { $done_p } {
|
297 |
|
|
return
|
298 |
|
|
}
|
299 |
|
|
}
|
300 |
|
|
|
301 |
|
|
# Look for a loop within the source code - if we don't find one,
|
302 |
|
|
# don't pass -funroll[-all]-loops.
|
303 |
|
|
global torture_with_loops torture_without_loops
|
304 |
|
|
if [expr [search_for $src "for*("]+[search_for $src "while*("]] then {
|
305 |
|
|
set option_list $torture_with_loops
|
306 |
|
|
} else {
|
307 |
|
|
set option_list $torture_without_loops
|
308 |
|
|
}
|
309 |
|
|
|
310 |
|
|
# loop through all the options
|
311 |
|
|
foreach option $option_list {
|
312 |
|
|
# torture_compile_xfail is set by the .x script (if present)
|
313 |
|
|
if [info exists torture_compile_xfail] {
|
314 |
|
|
setup_xfail $torture_compile_xfail
|
315 |
|
|
}
|
316 |
|
|
|
317 |
|
|
# torture_execute_before_compile is set by the .x script (if present)
|
318 |
|
|
if [info exists torture_eval_before_compile] {
|
319 |
|
|
set ignore_me [eval $torture_eval_before_compile]
|
320 |
|
|
}
|
321 |
|
|
|
322 |
|
|
objc-torture-compile $src "$option $options"
|
323 |
|
|
}
|
324 |
|
|
}
|