1 # Copyright
(C
) 1992-1998, 1999, 2000 Free Software Foundation
, Inc.
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.
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.
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
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
17 # Please email
any bugs
, comments
, and
/or additions to this file to
:
18 # bug
-dejagnu@gnu.org.
20 # This file was written by Rob Savoye.
(rob@cygnus.com
)
22 load_lib file
-format.exp
24 # The default option list can be overridden by
25 # TORTURE_OPTIONS
="{ { list1 } ... { listN } }"
27 if ![info exists TORTURE_OPTIONS
] {
28 # It is theoretically beneficial to group all of the O2
/O3 options together
,
29 # as in many cases the compiler will generate identical executables
for
30 # all of them
--and the objc
-torture testsuite will skip testing identical
31 # executables multiple times.
32 # Also note that
-finline
-functions is explicitly included in one of the
33 # items below
, even though
-O3 is also specified
, because some ports may
34 # choose to disable inlining functions by default
, even when optimizing.
35 set TORTURE_OPTIONS
[list \
39 { -O3
-fomit
-frame
-pointer
} \
40 { -O3
-fomit
-frame
-pointer
-funroll
-loops
} \
41 { -O3
-fomit
-frame
-pointer
-funroll
-all
-loops
-finline
-functions
} \
47 # Split TORTURE_OPTIONS into two choices
: one
for testcases with loops and
48 # one
for testcases without loops.
50 set torture_with_loops $TORTURE_OPTIONS
51 set torture_without_loops
""
52 foreach option $TORTURE_OPTIONS
{
53 if ![string match
"*loop*" $option] {
54 lappend torture_without_loops $option
59 # objc
-torture
-compile -- runs the Tege OBJC
-torture test
61 # SRC is the full pathname of the testcase.
62 # OPTION is the specific compiler flag we
're testing (eg: -O2).
64 proc objc-torture-compile { src option } {
69 set output "$tmpdir/[file tail [file rootname $src]].o"
71 regsub "^$srcdir/?" $src "" testcase
72 # If we couldn't rip $srcdir out of `src
' then just do the best we can.
73 # The point is to reduce the unnecessary noise in the logs. Don't
strip
74 # out too much because different testcases with the same
name can confuse
76 if [string match "/*" $testcase] {
77 set testcase "[file tail [file dirname $src]]/[file tail $src]"
80 verbose "Testing $testcase, $option" 1
82 # Run the compiler and analyze the results.
84 lappend options "additional_flags=-w $option -I${srcdir}/../../libobjc"
86 set comp_output [objc_target_compile "$src" "$output" object $options];
87 objc_check_compile $testcase $option $output $comp_output
88 remote_file build delete $output
92 # objc-torture-execute -- utility to compile and execute a testcase
94 # SRC is the full pathname of the testcase.
96 # If the testcase has an associated .x file, we source that to run the
97 # test instead. We use .x so that we don't lengthen the existing filename
98 # to more than
14 chars.
100 proc objc
-torture
-execute { src
args } {
101 global tmpdir tool srcdir output compiler_conditional_xfail_data
103 if { [llength $
args] > 0 } {
104 set additional_flags
[lindex $
args 0];
106 set additional_flags
"";
108 # Check
for alternate driver.
109 if [file
exists [file rootname $src
].x
] {
110 verbose
"Using alternate driver [file rootname [file tail $src]].x" 2
112 catch
"set done_p \[source [file rootname $src].x\]"
118 # Look
for a loop within the source code
- if we don
't find one,
119 # don't pass
-funroll
[-all
]-loops.
120 global torture_with_loops torture_without_loops
121 if [expr
[search_for $src
"for*("]+[search_for $src "while*("]] then {
122 set option_list $torture_with_loops
124 set option_list $torture_without_loops
127 set executable $tmpdir
/[file tail
[file rootname $src
].x
]
129 regsub
"^$srcdir/?" $src "" testcase
130 #
If we couldn
't rip $srcdir out of `src' then just
do the best we can.
131 # The point is to reduce the unnecessary noise in the logs. Don
't strip
132 # out too much because different testcases with the same name can confuse
134 if [string match
"/*" $testcase] {
135 set testcase
"[file tail [file dirname $src]]/[file tail $src]"
140 foreach option $option_list
{
142 set oldexec $execname
;
144 set execname
"${executable}${count}";
147 # torture_
{compile,execute}_xfail are
set by the .x script
149 if [info exists torture_compile_xfail
] {
150 setup_xfail $torture_compile_xfail
153 # torture_execute_before_
{compile,execute} can be
set by the .x script
155 if [info exists torture_eval_before_compile
] {
156 set ignore_me
[eval $torture_eval_before_compile
]
159 remote_file build
delete $execname
;
160 verbose
"Testing $testcase, $option" 1
163 lappend options
"additional_flags=-w $option -I${srcdir}/../../libobjc"
164 if { $additional_flags
!= "" } {
165 lappend options
"additional_flags=$additional_flags";
167 set comp_output
[objc_target_compile
"$src" "${execname}" executable $options];
169 if ![objc_check_compile
"$testcase compilation" $option $execname $comp_output] {
170 unresolved
"$testcase execution, $option"
171 remote_file build
delete $execname
175 # See
if this source file uses
"long long" types, if it does, and
176 # no_long_long is
set, skip execution of the test.
177 if [target_info
exists no_long_long
] then {
178 if [expr
[search_for $src
"long long"]] then {
179 unsupported
"$testcase execution, $option"
184 if [info exists torture_execute_xfail
] {
185 setup_xfail $torture_execute_xfail
188 if [info exists torture_eval_before_execute
] {
189 set ignore_me
[eval $torture_eval_before_execute
]
193 # Sometimes we end up creating identical executables
for two
194 # consecutive sets of different of compiler options.
196 # In such cases we know the result of this test will be identical
197 # to the result of the last test.
199 # So in cases where the time to
load and run
/simulate the test
200 # is relatively high
, compare the two binaries and avoid rerunning
201 # tests
if the executables are identical.
203 #
Do not
do this
for native testing since the cost to
load/execute
204 # the test is fairly small and the comparison step actually slows
205 # the entire process down because it usually does not
"hit".
207 if { ![isnative
] && [info exists oldexec
] } {
208 if { [remote_file build cmp $oldexec $execname
] == 0 } {
213 set result
[objc_load
"$execname" "" ""]
214 set status [lindex $result
0];
215 set output
[lindex $result
1];
217 if { $oldstatus
== "pass" } {
218 remote_file build
delete $oldexec
;
220 $
status "$testcase execution, $option"
221 set oldstatus $
status;
223 if [info exists status] {
224 if { $
status == "pass" } {
225 remote_file build
delete $execname
;
231 # search_for
-- looks
for a string match in a file
233 proc search_for
{ file pattern
} {
234 set fd
[open $file r
]
235 while { [gets $fd cur_line
]>=0 } {
236 if [string match
"*$pattern*" $cur_line] then {
246 # objc
-torture
-- the objc
-torture testcase source file processor
248 # This runs compilation only tests
(no
execute tests
).
249 # SRC is the full pathname of the testcase
, or just a file
name in which case
250 # we prepend $srcdir
/$subdir.
252 #
If the testcase has an associated .x file
, we source that to run the
253 # test instead. We use .x so that we don
't lengthen the existing filename
254 # to more than 14 chars.
256 proc objc-torture { args } {
257 global srcdir subdir compiler_conditional_xfail_data
259 set src [lindex $args 0];
260 if { [llength $args] > 1 } {
261 set options [lindex $args 1];
266 # Prepend $srdir/$subdir if missing.
267 if ![string match "*/*" $src] {
268 set src "$srcdir/$subdir/$src"
271 # Check for alternate driver.
272 if [file exists [file rootname $src].x] {
273 verbose "Using alternate driver [file rootname [file tail $src]].x" 2
275 catch "set done_p \[source [file rootname $src].x\]"
281 # Look for a loop within the source code - if we don't find one
,
282 # don
't pass -funroll[-all]-loops.
283 global torture_with_loops torture_without_loops
284 if [expr [search_for $src "for*("]+[search_for $src "while*("]] then {
285 set option_list $torture_with_loops
287 set option_list $torture_without_loops
290 # loop through all the options
291 foreach option $option_list {
292 # torture_compile_xfail is set by the .x script (if present)
293 if [info exists torture_compile_xfail] {
294 setup_xfail $torture_compile_xfail
297 # torture_execute_before_compile is set by the .x script (if present)
298 if [info exists torture_eval_before_compile] {
299 set ignore_me [eval $torture_eval_before_compile]
302 objc-torture-compile $src "$option $options"