1 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997 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.prep.ai.mit.edu
20 # This file was written by Rob Savoye. (rob@cygnus.com)
22 # The default option list can be overridden by
23 # TORTURE_OPTIONS="{ { list1 } ... { listN } }"
25 if ![info exists TORTURE_OPTIONS] {
26 # FIXME: We should test -g at least once.
27 set TORTURE_OPTIONS [list { -O }]
31 # Split TORTURE_OPTIONS into two choices: one for testcases with loops and
32 # one for testcases without loops.
34 set torture_with_loops $TORTURE_OPTIONS
35 set torture_without_loops ""
36 foreach option $TORTURE_OPTIONS {
37 if ![string match "*loop*" $option] {
38 lappend torture_without_loops $option
43 # objc-torture-compile -- runs the Tege C-torture test
45 # SRC is the full pathname of the testcase.
46 # OPTION is the specific compiler flag we're testing (eg: -O2).
48 proc objc-torture-compile { src option } {
53 set output "$tmpdir/[file tail [file rootname $src]].o"
55 regsub "^$srcdir/?" $src "" testcase
56 # If we couldn't rip $srcdir out of `src' then just do the best we can.
57 # The point is to reduce the unnecessary noise in the logs. Don't strip
58 # out too much because different testcases with the same name can confuse
60 if [string match "/*" $testcase] {
61 set testcase "[file tail [file dirname $src]]/[file tail $src]"
64 verbose "Testing $testcase, $option" 1
66 # Run the compiler and analyze the results.
68 lappend options "additional_flags=-w $option"
70 set comp_output [objc_target_compile "$src" "$output" object $options];
72 # Set a few common compiler messages.
73 set fatal_signal "*Obj-C*: Internal compiler error: program*got fatal signal"
75 if [string match "$fatal_signal 6" $comp_output] then {
76 objc_fail $testcase "Got Signal 6, $option"
77 remote_file build delete $output
81 if [string match "$fatal_signal 11" $comp_output] then {
82 objc_fail $testcase "Got Signal 11, $option"
83 remote_file build delete $output
87 # We shouldn't get these because of -w, but just in case.
88 if [string match "*Obj-C*:*warning:*" $comp_output] then {
89 warning "$testcase: (with warnings) $option"
90 send_log "$comp_output\n"
91 unresolved "$testcase, $option"
92 remote_file build delete $output
96 set comp_output [prune_warnings $comp_output]
98 set unsupported_message [objc_check_unsupported_p $comp_output]
99 if { $unsupported_message != "" } {
100 unsupported "$testcase: $unsupported_message"
101 remote_file build delete $output
105 # remove any leftover LF/CR to make sure any output is legit
106 regsub -all -- "\[\r\n\]*" $comp_output "" comp_output
107 # If any message remains, we fail.
108 if ![string match "" $comp_output] then {
109 objc_fail $testcase $option
110 remote_file build delete $output
114 objc_pass $testcase $option
115 remote_file build delete $output
119 # objc-torture-execute -- utility to compile and execute a testcase
121 # SRC is the full pathname of the testcase.
123 # If the testcase has an associated .cexp file, we source that to run the
124 # test instead. We use .cexp instead of .exp so that the testcase is still
125 # controlled by the main .exp driver (this is useful when one wants to only
126 # run the compile.exp tests for example - one need only pass compile.exp to
127 # dejagnu, and not compile.exp, foo1.exp, foo2.exp, etc.).
129 proc objc-torture-execute { src } {
130 global tmpdir tool srcdir output
132 # Check for alternate driver.
133 if [file exists [file rootname $src].cexp] {
134 verbose "Using alternate driver [file rootname [file tail $src]].cexp" 2
136 catch "set done_p \[source [file rootname $src].cexp\]"
142 # Look for a loop within the source code - if we don't find one,
143 # don't pass -funroll[-all]-loops.
144 global torture_with_loops torture_without_loops
145 if [expr [search_for $src "do *\[0-9\]"]+[search_for $src "end *do"]] then {
146 set option_list $torture_with_loops
148 set option_list $torture_without_loops
151 set executable $tmpdir/[file tail [file rootname $src].x]
153 regsub "^$srcdir/?" $src "" testcase
154 # If we couldn't rip $srcdir out of `src' then just do the best we can.
155 # The point is to reduce the unnecessary noise in the logs. Don't strip
156 # out too much because different testcases with the same name can confuse
158 if [string match "/*" $testcase] {
159 set testcase "[file tail [file dirname $src]]/[file tail $src]"
162 foreach option $option_list {
163 # torture_{compile,execute}_xfail are set by the .cexp script
165 if [info exists torture_compile_xfail] {
166 setup_xfail $torture_compile_xfail
168 remote_file build delete $executable
169 verbose "Testing $testcase, $option" 1
172 lappend options "additional_flags=-w $option -I${srcdir}/../../libobjc"
173 set comp_output [objc_target_compile "$src" "$executable" executable $options];
175 # Set a few common compiler messages.
176 set fatal_signal "*Obj-C*: Internal compiler error: program*got fatal signal"
178 if [string match "$fatal_signal 6" $comp_output] then {
179 objc_fail $testcase "Got Signal 6, $option"
180 remote_file build delete $executable
184 if [string match "$fatal_signal 11" $comp_output] then {
185 objc_fail $testcase "Got Signal 11, $option"
186 remote_file build delete $executable
190 # We shouldn't get these because of -w, but just in case.
191 if [string match "*Obj-C*:*warning:*" $comp_output] then {
192 warning "$testcase: (with warnings) $option"
193 send_log "$comp_output\n"
194 unresolved "$testcase, $option"
195 remote_file build delete $executable
199 set comp_output [prune_warnings $comp_output]
201 set unsupported_message [objc_check_unsupported_p $comp_output]
203 if { $unsupported_message != "" } {
204 unsupported "$testcase: $unsupported_message"
206 } elseif ![file exists $executable] {
208 fail "$testcase compilation, $option"
209 untested "$testcase execution, $option"
212 # FIXME: since we can't test for the existance of a remote
213 # file without short of doing an remote file list, we assume
214 # that since we got no output, it must have compiled.
215 pass "$testcase compilation, $option"
218 pass "$testcase compilation, $option"
221 # See if this source file uses "long long" types, if it does, and
222 # no_long_long is set, skip execution of the test.
223 if [target_info exists no_long_long] then {
224 if [expr [search_for $src "integer\*8"]] then {
225 untested "$testcase execution, $option"
230 if [info exists torture_execute_xfail] {
231 setup_xfail $torture_execute_xfail
234 set result [objc_load "$executable" "" ""]
235 set status [lindex $result 0];
236 set output [lindex $result 1];
237 if { $status == "pass" } {
238 remote_file build delete $executable
240 $status "$testcase execution, $option"
245 # search_for -- looks for a string match in a file
247 proc search_for { file pattern } {
248 set fd [open $file r]
249 while { [gets $fd cur_line]>=0 } {
250 set lower [string tolower $cur_line]
251 if [regexp "$pattern" $lower] then {
261 # objc-torture -- the objc-torture testcase source file processor
263 # This runs compilation only tests (no execute tests).
264 # SRC is the full pathname of the testcase, or just a file name in which case
265 # we prepend $srcdir/$subdir.
267 # If the testcase has an associated .cexp file, we source that to run the
268 # test instead. We use .cexp instead of .exp so that the testcase is still
269 # controlled by the main .exp driver (this is useful when one wants to only
270 # run the compile.exp tests for example - one need only pass compile.exp to
271 # dejagnu, and not compile.exp, foo1.exp, foo2.exp, etc.).
273 proc objc-torture { args } {
276 set src [lindex $args 0];
277 if { [llength $args] > 1 } {
278 set options [lindex $args 1];
283 # Prepend $srdir/$subdir if missing.
284 if ![string match "*/*" $src] {
285 set src "$srcdir/$subdir/$src"
288 # Check for alternate driver.
289 if [file exists [file rootname $src].cexp] {
290 verbose "Using alternate driver [file rootname [file tail $src]].cexp" 2
292 catch "set done_p \[source [file rootname $src].cexp\]"
298 # Look for a loop within the source code - if we don't find one,
299 # don't pass -funroll[-all]-loops.
300 global torture_with_loops torture_without_loops
301 if [expr [search_for $src "do *\[0-9\]"]+[search_for $src "end *do"]] then {
302 set option_list $torture_with_loops
304 set option_list $torture_without_loops
307 # loop through all the options
308 foreach option $option_list {
309 # torture_compile_xfail is set by the .cexp script (if present)
310 if [info exists torture_compile_xfail] {
311 setup_xfail $torture_compile_xfail
314 objc-torture-compile $src "$option $options"