summaryrefslogtreecommitdiff
path: root/gcc/testsuite/lib/objc-torture.exp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/lib/objc-torture.exp')
-rwxr-xr-xgcc/testsuite/lib/objc-torture.exp316
1 files changed, 316 insertions, 0 deletions
diff --git a/gcc/testsuite/lib/objc-torture.exp b/gcc/testsuite/lib/objc-torture.exp
new file mode 100755
index 0000000..5eadd48
--- /dev/null
+++ b/gcc/testsuite/lib/objc-torture.exp
@@ -0,0 +1,316 @@
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-dejagnu.prep.ai.mit.edu
+
+# This file was written by Rob Savoye. (rob@cygnus.com)
+
+# The default option list can be overridden by
+# TORTURE_OPTIONS="{ { list1 } ... { listN } }"
+
+if ![info exists TORTURE_OPTIONS] {
+ # FIXME: We should test -g at least once.
+ set TORTURE_OPTIONS [list { -O }]
+}
+
+
+# Split TORTURE_OPTIONS into two choices: one for testcases with loops and
+# one for testcases without loops.
+
+set torture_with_loops $TORTURE_OPTIONS
+set torture_without_loops ""
+foreach option $TORTURE_OPTIONS {
+ if ![string match "*loop*" $option] {
+ lappend torture_without_loops $option
+ }
+}
+
+#
+# objc-torture-compile -- runs the Tege C-torture test
+#
+# SRC is the full pathname of the testcase.
+# OPTION is the specific compiler flag we're testing (eg: -O2).
+#
+proc objc-torture-compile { src option } {
+ global output
+ global srcdir tmpdir
+ global host_triplet
+
+ set output "$tmpdir/[file tail [file rootname $src]].o"
+
+ regsub "^$srcdir/?" $src "" testcase
+ # If we couldn't rip $srcdir out of `src' then just do the best we can.
+ # The point is to reduce the unnecessary noise in the logs. Don't strip
+ # out too much because different testcases with the same name can confuse
+ # `test-tool'.
+ if [string match "/*" $testcase] {
+ set testcase "[file tail [file dirname $src]]/[file tail $src]"
+ }
+
+ verbose "Testing $testcase, $option" 1
+
+ # Run the compiler and analyze the results.
+ set options ""
+ lappend options "additional_flags=-w $option"
+
+ set comp_output [objc_target_compile "$src" "$output" object $options];
+
+ # Set a few common compiler messages.
+ set fatal_signal "*77*: Internal compiler error: program*got fatal signal"
+
+ if [string match "$fatal_signal 6" $comp_output] then {
+ objc_fail $testcase "Got Signal 6, $option"
+ remote_file build delete $output
+ return
+ }
+
+ if [string match "$fatal_signal 11" $comp_output] then {
+ objc_fail $testcase "Got Signal 11, $option"
+ remote_file build delete $output
+ return
+ }
+
+ # We shouldn't get these because of -w, but just in case.
+ if [string match "*77*:*warning:*" $comp_output] then {
+ warning "$testcase: (with warnings) $option"
+ send_log "$comp_output\n"
+ unresolved "$testcase, $option"
+ remote_file build delete $output
+ return
+ }
+
+ set comp_output [prune_warnings $comp_output]
+
+ set unsupported_message [objc_check_unsupported_p $comp_output]
+ if { $unsupported_message != "" } {
+ unsupported "$testcase: $unsupported_message"
+ remote_file build delete $output
+ return
+ }
+
+ # remove any leftover LF/CR to make sure any output is legit
+ regsub -all -- "\[\r\n\]*" $comp_output "" comp_output
+ # If any message remains, we fail.
+ if ![string match "" $comp_output] then {
+ objc_fail $testcase $option
+ remote_file build delete $output
+ return
+ }
+
+ objc_pass $testcase $option
+ remote_file build delete $output
+}
+
+#
+# objc-torture-execute -- utility to compile and execute a testcase
+#
+# SRC is the full pathname of the testcase.
+#
+# If the testcase has an associated .cexp file, we source that to run the
+# test instead. We use .cexp instead of .exp so that the testcase is still
+# controlled by the main .exp driver (this is useful when one wants to only
+# run the compile.exp tests for example - one need only pass compile.exp to
+# dejagnu, and not compile.exp, foo1.exp, foo2.exp, etc.).
+#
+proc objc-torture-execute { src } {
+ global tmpdir tool srcdir output
+
+ # Check for alternate driver.
+ if [file exists [file rootname $src].cexp] {
+ verbose "Using alternate driver [file rootname [file tail $src]].cexp" 2
+ set done_p 0
+ catch "set done_p \[source [file rootname $src].cexp\]"
+ if { $done_p } {
+ return
+ }
+ }
+
+ # Look for a loop within the source code - if we don't find one,
+ # don't pass -funroll[-all]-loops.
+ global torture_with_loops torture_without_loops
+ if [expr [search_for $src "do *\[0-9\]"]+[search_for $src "end *do"]] then {
+ set option_list $torture_with_loops
+ } else {
+ set option_list $torture_without_loops
+ }
+
+ set executable $tmpdir/[file tail [file rootname $src].x]
+
+ regsub "^$srcdir/?" $src "" testcase
+ # If we couldn't rip $srcdir out of `src' then just do the best we can.
+ # The point is to reduce the unnecessary noise in the logs. Don't strip
+ # out too much because different testcases with the same name can confuse
+ # `test-tool'.
+ if [string match "/*" $testcase] {
+ set testcase "[file tail [file dirname $src]]/[file tail $src]"
+ }
+
+ foreach option $option_list {
+ # torture_{compile,execute}_xfail are set by the .cexp script
+ # (if present)
+ if [info exists torture_compile_xfail] {
+ setup_xfail $torture_compile_xfail
+ }
+ remote_file build delete $executable
+ verbose "Testing $testcase, $option" 1
+
+ set options ""
+ lappend options "additional_flags=-w $option -I${srcdir}/../../libobjc"
+ set comp_output [objc_target_compile "$src" "$executable" executable $options];
+
+ # Set a few common compiler messages.
+ set fatal_signal "*77*: Internal compiler error: program*got fatal signal"
+
+ if [string match "$fatal_signal 6" $comp_output] then {
+ objc_fail $testcase "Got Signal 6, $option"
+ remote_file build delete $executable
+ continue
+ }
+
+ if [string match "$fatal_signal 11" $comp_output] then {
+ objc_fail $testcase "Got Signal 11, $option"
+ remote_file build delete $executable
+ continue
+ }
+
+ # We shouldn't get these because of -w, but just in case.
+ if [string match "*77*:*warning:*" $comp_output] then {
+ warning "$testcase: (with warnings) $option"
+ send_log "$comp_output\n"
+ unresolved "$testcase, $option"
+ remote_file build delete $executable
+ continue
+ }
+
+ set comp_output [prune_warnings $comp_output]
+
+ set unsupported_message [objc_check_unsupported_p $comp_output]
+
+ if { $unsupported_message != "" } {
+ unsupported "$testcase: $unsupported_message"
+ continue
+ } elseif ![file exists $executable] {
+ if ![is3way] {
+ fail "$testcase compilation, $option"
+ untested "$testcase execution, $option"
+ continue
+ } else {
+ # FIXME: since we can't test for the existance of a remote
+ # file without short of doing an remote file list, we assume
+ # that since we got no output, it must have compiled.
+ pass "$testcase compilation, $option"
+ }
+ } else {
+ pass "$testcase compilation, $option"
+ }
+
+ # See if this source file uses "long long" types, if it does, and
+ # no_long_long is set, skip execution of the test.
+ if [target_info exists no_long_long] then {
+ if [expr [search_for $src "integer\*8"]] then {
+ untested "$testcase execution, $option"
+ continue
+ }
+ }
+
+ if [info exists torture_execute_xfail] {
+ setup_xfail $torture_execute_xfail
+ }
+
+ set result [objc_load "$executable" "" ""]
+ set status [lindex $result 0];
+ set output [lindex $result 1];
+ if { $status == "pass" } {
+ remote_file build delete $executable
+ }
+ $status "$testcase execution, $option"
+ }
+}
+
+#
+# search_for -- looks for a string match in a file
+#
+proc search_for { file pattern } {
+ set fd [open $file r]
+ while { [gets $fd cur_line]>=0 } {
+ set lower [string tolower $cur_line]
+ if [regexp "$pattern" $lower] then {
+ close $fd
+ return 1
+ }
+ }
+ close $fd
+ return 0
+}
+
+#
+# objc-torture -- the objc-torture testcase source file processor
+#
+# This runs compilation only tests (no execute tests).
+# SRC is the full pathname of the testcase, or just a file name in which case
+# we prepend $srcdir/$subdir.
+#
+# If the testcase has an associated .cexp file, we source that to run the
+# test instead. We use .cexp instead of .exp so that the testcase is still
+# controlled by the main .exp driver (this is useful when one wants to only
+# run the compile.exp tests for example - one need only pass compile.exp to
+# dejagnu, and not compile.exp, foo1.exp, foo2.exp, etc.).
+#
+proc objc-torture { args } {
+ global srcdir subdir
+
+ set src [lindex $args 0];
+ if { [llength $args] > 1 } {
+ set options [lindex $args 1];
+ } else {
+ set options ""
+ }
+
+ # Prepend $srdir/$subdir if missing.
+ if ![string match "*/*" $src] {
+ set src "$srcdir/$subdir/$src"
+ }
+
+ # Check for alternate driver.
+ if [file exists [file rootname $src].cexp] {
+ verbose "Using alternate driver [file rootname [file tail $src]].cexp" 2
+ set done_p 0
+ catch "set done_p \[source [file rootname $src].cexp\]"
+ if { $done_p } {
+ return
+ }
+ }
+
+ # Look for a loop within the source code - if we don't find one,
+ # don't pass -funroll[-all]-loops.
+ global torture_with_loops torture_without_loops
+ if [expr [search_for $src "do *\[0-9\]"]+[search_for $src "end *do"]] then {
+ set option_list $torture_with_loops
+ } else {
+ set option_list $torture_without_loops
+ }
+
+ # loop through all the options
+ foreach option $option_list {
+ # torture_compile_xfail is set by the .cexp script (if present)
+ if [info exists torture_compile_xfail] {
+ setup_xfail $torture_compile_xfail
+ }
+
+ objc-torture-compile $src "$option $options"
+ }
+}