OSDN Git Service

Scan "lea\[lq\]?\[ \t\]" instead of "lea\[ \t\]".
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / objc-torture.exp
index 4d52a3d..0b6362b 100644 (file)
@@ -1,8 +1,9 @@
-# Copyright (C) 1992-1998, 1999, 2000 Free Software Foundation, Inc.
+# Copyright (C) 1992-1998, 1999, 2000, 2007, 2008
+# 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
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
 # 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
 
 # This file was written by Rob Savoye. (rob@cygnus.com)
 
 load_lib file-format.exp
+load_lib target-supports.exp
 
-# The default option list can be overridden by
-# TORTURE_OPTIONS="{ { list1 } ... { listN } }"
+# Make sure that the runtime list is re-evaluated for each multilib.
+proc objc-set-runtime-options { dowhat args } {
+    global OBJC_RUNTIME_OPTIONS
+    if ![info exists OBJC_RUNTIME_OPTIONS] {
+       set rtlist [list "-fgnu-runtime" "-fnext-runtime" ]
+    } else {
+       set rtlist [list "-fgnu-runtime" "-fnext-runtime" ]
+       foreach other $OBJC_RUNTIME_OPTIONS {
+           # Don't do tests twice...
+           if { ( $other == "-fnext-runtime"  || $other == "-fgnu-runtime" ) } {
+               continue
+           }
+           lappend rtlist $other
+       }
+    }
 
-if ![info exists OBJC_RUNTIME_OPTIONS] {
-  set OBJC_RUNTIME_OPTIONS ""
-  foreach type {-fgnu-runtime -fnext-runtime} {
-    global srcdir subdir
+    set OBJC_RUNTIME_OPTIONS ""
 
-    set comp_output [objc_target_compile \
-    "$srcdir/$subdir/trivial.m" "trivial.exe" executable "additional_flags=$type"]
+    foreach type $rtlist {
+       global srcdir subdir target_triplet tmpdir
 
-    # If we get any error, then we failed
-    if ![string match "" $comp_output] then {
-      continue;
+       set options "additional_flags=$type"
+       if [info exists args] {
+           lappend options $args
+       }
+       verbose "options $options"
+       set test_obj "trivial.exe"
+       set comp_output [objc_target_compile \
+       "$srcdir/$subdir/trivial.m" $test_obj executable $options]
+
+       # If we get any error, then we failed.
+       if ![string match "" $comp_output] then {
+           remote_file build delete $test_obj
+           continue;
+       }
+       if [info exists dowhat] {
+           if { $dowhat == "execute" } {
+               set result [objc_load "$tmpdir/$test_obj" "" ""]
+               set status [lindex $result 0]
+               set output [lindex $result 1]
+               if { $status != "pass" } {
+                   remote_file build delete $test_obj
+                   verbose -log "trivial execute failed with $status $output"
+                   continue;
+               }
+           }
+       }
+       remote_file build delete $test_obj
+       lappend OBJC_RUNTIME_OPTIONS $type
     }
-    lappend OBJC_RUNTIME_OPTIONS $type
-  }
+
+    verbose -log "Using the following runtimes: $OBJC_RUNTIME_OPTIONS"
 }
-verbose -log "Using the following runtimes: $OBJC_RUNTIME_OPTIONS"
 
+# The default option list can be overridden by
+# TORTURE_OPTIONS="{ { list1 } ... { listN } }"
 
-if ![info exists TORTURE_OPTIONS] {
+if [info exists TORTURE_OPTIONS] {
+    set OBJC_TORTURE_OPTIONS $TORTURE_OPTIONS
+} else {
     # It is theoretically beneficial to group all of the O2/O3 options together,
     # as in many cases the compiler will generate identical executables for
     # all of them--and the objc-torture testsuite will skip testing identical
@@ -47,7 +87,7 @@ if ![info exists TORTURE_OPTIONS] {
     # Also note that -finline-functions is explicitly included in one of the
     # items below, even though -O3 is also specified, because some ports may
     # choose to disable inlining functions by default, even when optimizing.
-    set TORTURE_OPTIONS [list \
+    set OBJC_TORTURE_OPTIONS [list \
        " -O0 " \
        " -O1 " \
        " -O2 " \
@@ -58,23 +98,11 @@ if ![info exists TORTURE_OPTIONS] {
        " -Os " ]
 }
 
-
-# Split TORTURE_OPTIONS into two choices: one for testcases with loops and
-# one for testcases without loops. Add in the objc runtime options also.
-
-set torture_with_loops ""
-set torture_without_loops ""
-foreach objc_option $OBJC_RUNTIME_OPTIONS {
-  foreach option $TORTURE_OPTIONS {
-  
-    if ![string match "*loop*" $option] {
-       lappend torture_without_loops "$option $objc_option"
-    }
-    lappend torture_with_loops "$option $objc_option"
-  }
+if [info exists ADDITIONAL_TORTURE_OPTIONS] {
+    set OBJC_TORTURE_OPTIONS \
+       [concat $OBJC_TORTURE_OPTIONS $ADDITIONAL_TORTURE_OPTIONS]
 }
 
-
 #
 # objc-torture-compile -- runs the Tege OBJC-torture test
 #
@@ -159,6 +187,9 @@ proc objc-torture-execute { src args } {
     set oldstatus "foo"
     foreach option $option_list {
        if { $count > 0 } {
+           if [info exists oldexec] {
+               remote_file build delete $oldexec
+           }
            set oldexec $execname
        }
        set execname "${executable}${count}"
@@ -173,7 +204,7 @@ proc objc-torture-execute { src args } {
        # torture_execute_before_{compile,execute} can be set by the .x script
        # (if present)
        if [info exists torture_eval_before_compile] {
-            set ignore_me [eval $torture_eval_before_compile]
+         set ignore_me [eval $torture_eval_before_compile]
        }
 
        remote_file build delete $execname
@@ -197,6 +228,7 @@ proc objc-torture-execute { src args } {
        if [target_info exists no_long_long] then {
            if [expr [search_for $src "long long"]] then {
                unsupported "$testcase execution, $option"
+               remote_file build delete $execname
                continue
            }
        }
@@ -206,7 +238,7 @@ proc objc-torture-execute { src args } {
        }
 
        if [info exists torture_eval_before_execute] {
-            set ignore_me [eval $torture_eval_before_execute]
+           set ignore_me [eval $torture_eval_before_execute]
        }
 
 
@@ -227,6 +259,7 @@ proc objc-torture-execute { src args } {
        if { ![isnative] && [info exists oldexec] } {
            if { [remote_file build cmp $oldexec $execname] == 0 } {
                set skip 1
+               set status $oldstatus
            }
        }
        if { $skip == 0 } {
@@ -234,16 +267,16 @@ proc objc-torture-execute { src args } {
            set status [lindex $result 0]
            set output [lindex $result 1]
        }
-        if { $oldstatus == "pass" } {
-           remote_file build delete $oldexec
-        }
        $status "$testcase execution, $option"
        set oldstatus $status
+    # for each option
+    } 
+    # tidy up
+    if [info exists execname] {
+       remote_file build delete $execname
     }
-    if [info exists status] {
-       if { $status == "pass" } {
-           remote_file build delete $execname
-       }
+    if [info exists oldexec] {
+       remote_file build delete $oldexec
     }
 }
 
@@ -302,9 +335,9 @@ proc objc-torture { args } {
     # don't pass -funroll[-all]-loops.
     global torture_with_loops torture_without_loops
     if [expr [search_for $src "for*("]+[search_for $src "while*("]] then {
-       set option_list $torture_with_loops
+           set option_list $torture_with_loops
     } else {
-       set option_list $torture_without_loops
+           set option_list $torture_without_loops
     }
 
     # loop through all the options
@@ -316,7 +349,7 @@ proc objc-torture { args } {
 
        # torture_execute_before_compile is set by the .x script (if present)
        if [info exists torture_eval_before_compile] {
-            set ignore_me [eval $torture_eval_before_compile]
+           set ignore_me [eval $torture_eval_before_compile]
        }
 
        objc-torture-compile $src "$option $options"