OSDN Git Service

* lib/target-supports.exp (current_target_name): New.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / profopt.exp
index ca62c67..e8a7ac1 100644 (file)
@@ -1,4 +1,4 @@
-#   Copyright (C) 2001 Free Software Foundation, Inc.
+#   Copyright (C) 2001, 2004 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
@@ -27,7 +27,7 @@
 # addition to the profiling and feedback options.
 
 # If perf_ext is defined and the performance value for the
-# profile-directed test run is non-zero then the performance check will
+# profile-directed test run is nonzero then the performance check will
 # be done.
 
 global PROFOPT_OPTIONS perf_delta
@@ -37,12 +37,6 @@ global tool profile_option feedback_option prof_ext
 if ![info exists tool] {
     error "Tools is not specified."
 }
-if ![info exists profile_option] {
-    error "No profile option specified for first compile."
-}
-if ![info exists feedback_option] {
-    error "No feedback option specified for second compile."
-}
 if ![info exists prof_ext] {
     error "No profile data file extension specified."
 }
@@ -66,15 +60,18 @@ if ![info exists PROFOPT_OPTIONS] {
        { -Os } ]
 }
 
-set option_list $PROFOPT_OPTIONS
+set prof_option_list $PROFOPT_OPTIONS
 
 #
 # profopt-cleanup -- remove profiling or performance results files.
 #
-# EXT is the extension of files to remove
+# TESTCASE is the name of the test
+# EXT is the extension of file to remove
 #
-proc profopt-cleanup { ext } {
-    set files [glob -nocomplain *.$ext]
+proc profopt-cleanup { testcase ext } {
+    set basename [file tail $testcase]
+    set base [file rootname $basename]
+    set files [glob -nocomplain $base.$ext]
     if { $files != "" } {
        eval "remote_file build delete $files"
     }
@@ -112,7 +109,7 @@ proc profopt-perf-value { testcase perf_ext optstr } {
        fail "$testcase perf check: file $base.$perf_ext has wrong format, $optstr"
     }
     close $fd
-    profopt-cleanup $perf_ext
+    profopt-cleanup $testcase $perf_ext
     return $val
 }
 
@@ -123,10 +120,17 @@ proc profopt-perf-value { testcase perf_ext optstr } {
 #
 proc profopt-execute { src } {
     global srcdir tmpdir
-    global option_list
+    global prof_option_list
     global tool profile_option feedback_option prof_ext perf_ext perf_delta
     global verbose
 
+    if ![info exists profile_option] {
+        error "No profile option specified for first compile."
+    }
+    if ![info exists feedback_option] {
+        error "No feedback option specified for second compile."
+    }
+
     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
@@ -139,7 +143,7 @@ proc profopt-execute { src } {
     set executable $tmpdir/[file tail [file rootname $src].x]
 
     set count 0
-    foreach option $option_list {
+    foreach option $prof_option_list {
        set execname1 "${executable}${count}1"
        set execname2 "${executable}${count}2"
        set execname3 "${executable}${count}3"
@@ -150,6 +154,12 @@ proc profopt-execute { src } {
        remote_file build delete $execname3
        verbose "Testing $testcase, $option" 1
 
+       # Remove old profiling and performance data files.
+       profopt-cleanup $testcase $prof_ext
+       if [info exists perf_ext] {
+           profopt-cleanup $testcase $perf_ext
+       }
+
        # Compile for profiling.
 
        set options ""
@@ -210,7 +220,7 @@ proc profopt-execute { src } {
        }
 
        # Remove the profiling data files.
-       profopt-cleanup $prof_ext
+       profopt-cleanup $testcase $prof_ext
 
        # If the test is not expected to produce performance data then
        # we're done now.