target-supports-dg.exp (testname-for-summary): New.
authorJanis Johnson <janisjo@codesourcery.com>
Tue, 26 Jun 2012 03:10:43 +0000 (03:10 +0000)
committerJanis Johnson <janis@gcc.gnu.org>
Tue, 26 Jun 2012 03:10:43 +0000 (03:10 +0000)
* lib/target-supports-dg.exp (testname-for-summary): New.
* lib/profopt.exp (profopt_execute): Define testname_with_flags.
* lib/gcc-dg.exp (cleanup-coverage-files, cleanup-repo-notes,
cleanup-stack-usage, cleanup-dump, cleanup-saved-temps, scan-module,
scan-module-absence, output-exists, output-exists-not: Use
testname-for-summary.
(dg-test): Clean up testname_with_flags.
* lib/scanasm.exp (scan-assembler, scan-assembler-not, scan-hidden,
scan-not-hidden, scan-file, scan-file-not, scan-stack-usage,
scan-stack-usage-not, scan-assembler-times, scan-assembler-dem,
scan-assembler-dem-not, object-size: Use testname-for-summary.
* lib/gcov.exp (run-gcov): Likewise.
* lib/scandump.exp (scan-dump, scan-dump-times, scan-dump-not,
scan-dump-dem, scan-dump-dem-note): Likewise.

From-SVN: r188972

gcc/testsuite/ChangeLog
gcc/testsuite/lib/gcc-dg.exp
gcc/testsuite/lib/gcov.exp
gcc/testsuite/lib/profopt.exp
gcc/testsuite/lib/scanasm.exp
gcc/testsuite/lib/scandump.exp
gcc/testsuite/lib/target-supports-dg.exp

index a8416dce09925290d42b631db01665cf4a12b0b4..b4f21e7493e1fdcc6e53a28500be6aba086da900 100644 (file)
@@ -1,5 +1,20 @@
 2012-06-25  Janis Johnson  <janisjo@codesourcery.com>
 
+       * lib/target-supports-dg.exp (testname-for-summary): New.
+       * lib/profopt.exp (profopt_execute): Define testname_with_flags.
+       * lib/gcc-dg.exp (cleanup-coverage-files, cleanup-repo-notes,
+       cleanup-stack-usage, cleanup-dump, cleanup-saved-temps, scan-module,
+       scan-module-absence, output-exists, output-exists-not: Use
+       testname-for-summary.
+       (dg-test): Clean up testname_with_flags.
+       * lib/scanasm.exp (scan-assembler, scan-assembler-not, scan-hidden,
+       scan-not-hidden, scan-file, scan-file-not, scan-stack-usage,
+       scan-stack-usage-not, scan-assembler-times, scan-assembler-dem,
+       scan-assembler-dem-not, object-size: Use testname-for-summary.
+       * lib/gcov.exp (run-gcov): Likewise.
+       * lib/scandump.exp (scan-dump, scan-dump-times, scan-dump-not,
+       scan-dump-dem, scan-dump-dem-note): Likewise.
+
        * lib/profopt.exp: Make prof_option_list local to profopt-execute.
        * g++.dg/tree-prof/tree-prof.exp (PROFOPT_OPTIONS): Define after
        including profopt.opt; save and restore existing value.
index 4666edec8be6075b6c9bcd5840cedc2c13571cfa..3b9f9c0a514c176f139b2a4f682775e1622b1353 100644 (file)
@@ -433,10 +433,7 @@ proc cleanup-profile-file { } {
 
 # Remove compiler-generated coverage files for the current test.
 proc cleanup-coverage-files { } {
-    # This assumes that we are two frames down from dg-test or some other proc
-    # that stores the filename of the testcase in a local variable "name".
-    # A cleaner solution would require a new DejaGnu release.
-    upvar 2 name testcase
+    set testcase [testname-for-summary]
     # The name might include a list of options; extract the file name.
     set testcase [lindex $testcase 0]
     remove-build-file "[file rootname [file tail $testcase]].gc??"
@@ -451,10 +448,7 @@ proc cleanup-coverage-files { } {
 
 # Remove compiler-generated files from -repo for the current test.
 proc cleanup-repo-files { } {
-    # This assumes that we are two frames down from dg-test or some other proc
-    # that stores the filename of the testcase in a local variable "name".
-    # A cleaner solution would require a new DejaGnu release.
-    upvar 2 name testcase
+    set testcase [testname-for-summary]
     # The name might include a list of options; extract the file name.
     set testcase [lindex $testcase 0]
     remove-build-file "[file rootname [file tail $testcase]].o"
@@ -492,10 +486,7 @@ proc cleanup-ipa-dump { suffix } {
 
 # Remove a stack usage file for the current test.
 proc cleanup-stack-usage { } {
-    # This assumes that we are two frames down from dg-test or some other proc
-    # that stores the filename of the testcase in a local variable "name".
-    # A cleaner solution would require a new DejaGnu release.
-    upvar 2 name testcase
+    set testcase [testname-for-summary]
     # The name might include a list of options; extract the file name.
     set testcase [lindex $testcase 0]
     remove-build-file "[file rootname [file tail $testcase]].su"
@@ -510,10 +501,7 @@ proc cleanup-stack-usage { } {
 
 # Remove all dump files with the provided suffix.
 proc cleanup-dump { suffix } {
-    # This assumes that we are three frames down from dg-test or some other
-    # proc that stores the filename of the testcase in a local variable
-    # "name".  A cleaner solution would require a new DejaGnu release.
-    upvar 3 name testcase
+    set testcase [testname-for-summary]
     # The name might include a list of options; extract the file name.
     set src [file tail [lindex $testcase 0]]
     remove-build-file "[file tail $src].$suffix"
@@ -550,10 +538,7 @@ proc cleanup-saved-temps { args } {
        }
     }
 
-    # This assumes that we are two frames down from dg-test or some other proc
-    # that stores the filename of the testcase in a local variable "name".
-    # A cleaner solution would require a new DejaGnu release.
-    upvar 2 name testcase
+    set testcase [testname-for-summary]
     # The name might include a list of options; extract the file name.
     set testcase [lindex $testcase 0]
     foreach suffix $suffixes {
@@ -584,7 +569,7 @@ proc scan-module { args } {
     set text [read $fd]
     close $fd
 
-    upvar 2 name testcase
+    set testcase [testname-for-summary]
     if [regexp -- [lindex $args 1] $text] {
       pass "$testcase scan-module [lindex $args 1]"
     } else {
@@ -602,7 +587,7 @@ proc scan-module-absence { args } {
     set text [read $fd]
     close $fd
 
-    upvar 2 name testcase
+    set testcase [testname-for-summary]
     if [regexp -- [lindex $args 1] $text] {
       fail "$testcase scan-module [lindex $args 1]"
     } else {
@@ -622,8 +607,8 @@ proc output-exists { args } {
        }
     }
 
-    # Access variables from gcc-dg-test-1.
-    upvar 2 name testcase
+    set testcase [testname-for-summary]
+    # Access variable from gcc-dg-test-1.
     upvar 2 output_file output_file
 
     if [file exists $output_file] {
@@ -645,8 +630,8 @@ proc output-exists-not { args } {
        }
     }
 
-    # Access variables from gcc-dg-test-1.
-    upvar 2 name testcase
+    set testcase [testname-for-summary]
+    # Access variable from gcc-dg-test-1.
     upvar 2 output_file output_file
 
     if [file exists $output_file] {
@@ -674,6 +659,7 @@ if { [info procs saved-dg-test] == [list] } {
        global errorInfo
        global compiler_conditional_xfail_data
        global shouldfail
+       global testname_with_flags
 
        if { [ catch { eval saved-dg-test $args } errmsg ] } {
            set saved_info $errorInfo
@@ -684,6 +670,9 @@ if { [info procs saved-dg-test] == [list] } {
            if [info exists compiler_conditional_xfail_data] {
                unset compiler_conditional_xfail_data
            }
+           if [info exists testname_with_flags] {
+               unset testname_with_flags
+           }
            unset_timeout_vars
            error $errmsg $saved_info
        }
@@ -695,6 +684,9 @@ if { [info procs saved-dg-test] == [list] } {
        if [info exists compiler_conditional_xfail_data] {
            unset compiler_conditional_xfail_data
        }
+       if [info exists testname_with_flags] {
+           unset testname_with_flags
+       }
     }
 }
 
index 601330b1ff602b6f2fe802a527af4aa7013ca272..1cf93a718a67dc784689acee634e85b69e7dcdbd 100644 (file)
@@ -265,8 +265,7 @@ proc run-gcov { args } {
        }
     }
 
-    # Get the test name, including options that make it unique, from gnu-test 2 levels up.
-    upvar 2 name testname
+    set testname [testname-for-summary]
 
     # Extract the test file name from the arguments.
     set testcase [lindex $gcov_args end]
index f0dbee720e589692639d0d6a4c860360b92e0129..b74b7cae1e70fc743cdccb39fb5e742f7e3eae6d 100644 (file)
@@ -217,6 +217,7 @@ proc profopt-execute { src } {
     global tool profile_option feedback_option prof_ext perf_ext perf_delta
     global generate_final_code use_final_code
     global verbose
+    global testname_with_flags
 
     if ![info exists profile_option] {
         error "No profile option specified for first compile."
@@ -240,6 +241,12 @@ proc profopt-execute { src } {
        set testcase "[file tail [file dirname $src]]/[file tail $src]"
     }
 
+    # Several procedures access the name of the test with torture flags,
+    # normally defined in dg-test.  Profile optimization tests don't
+    # use dg-test, so define it here to make it accessible via
+    # testname-for-summary.
+    set testname_with_flags $testcase
+
     set executable $tmpdir/[file tail [file rootname $src].x]
     set basename [file tail $testcase]
     set base [file rootname $basename]
@@ -272,6 +279,7 @@ proc profopt-execute { src } {
        set extra_flags [profopt-get-options $src]
        if { [lindex ${dg-do-what} 1 ] == "N" } {
            unsupported "$src"
+           unset testname_with_flags
            verbose "$src not supported on this target, skipping it" 3
            return
        }
@@ -437,4 +445,5 @@ proc profopt-execute { src } {
            remote_file build delete $execname3
        }
     }
+    unset testname_with_flags
 }
index ebd3c611da609308a154350c22c0f181564f9553..51c19d3ade1c3f3af1d8161ced44bd159723baef 100644 (file)
@@ -78,10 +78,7 @@ proc dg-scan { name positive testcase output_file orig_args } {
 # dg-scan for details.
 
 proc scan-assembler { args } {
-    upvar 2 name testcase
-    if { [llength $testcase] > 1 } {
-       set testcase "$testcase "
-    }
+    set testcase [testname-for-summary]
     set output_file "[file rootname [file tail $testcase]].s"
     dg-scan "scan-assembler" 1 $testcase $output_file $args
 }
@@ -95,10 +92,7 @@ proc scan-assembler_required_options { args } {
 # compiler.  See dg-scan for details.
 
 proc scan-assembler-not { args } {
-    upvar 2 name testcase
-    if { [llength $testcase] > 1 } {
-       set testcase "$testcase "
-    }
+    set testcase [testname-for-summary]
     set output_file "[file rootname [file tail $testcase]].s"
 
     dg-scan "scan-assembler-not" 0 $testcase $output_file $args
@@ -128,10 +122,7 @@ proc hidden-scan-for { symbol } {
 # produced by the compiler.
 
 proc scan-hidden { args } {
-    upvar 2 name testcase
-    if { [llength $testcase] > 1 } {
-       set testcase "$testcase "
-    }
+    set testcase [testname-for-summary]
     set output_file "[file rootname [file tail $testcase]].s"
 
     set symbol [lindex $args 0]
@@ -147,10 +138,7 @@ proc scan-hidden { args } {
 # produced by the compiler.
 
 proc scan-not-hidden { args } {
-    upvar 2 name testcase
-    if { [llength $testcase] > 1 } {
-       set testcase "$testcase "
-    }
+    set testcase [testname-for-summary]
     set output_file "[file rootname [file tail $testcase]].s"
 
     set symbol [lindex $args 0]
@@ -164,10 +152,7 @@ proc scan-not-hidden { args } {
 # Look for a pattern in OUTPUT_FILE.  See dg-scan for details.
 
 proc scan-file { output_file args } {
-    upvar 2 name testcase
-    if { [llength $testcase] > 1 } {
-       set testcase "$testcase "
-    }
+    set testcase [testname-for-summary]
     dg-scan "scan-file" 1 $testcase $output_file $args
 }
 
@@ -175,10 +160,7 @@ proc scan-file { output_file args } {
 # for details.
 
 proc scan-file-not { output_file args } {
-    upvar 2 name testcase
-    if { [llength $testcase] > 1 } {
-       set testcase "$testcase "
-    }
+    set testcase [testname-for-summary]
     dg-scan "scan-file-not" 0 $testcase $output_file $args
 }
 
@@ -186,10 +168,7 @@ proc scan-file-not { output_file args } {
 # dg-scan for details.
 
 proc scan-stack-usage { args } {
-    upvar 2 name testcase
-    if { [llength $testcase] > 1 } {
-       set testcase "$testcase "
-    }
+    set testcase [testname-for-summary]
     set output_file "[file rootname [file tail $testcase]].su"
 
     dg-scan "scan-file" 1 $testcase $output_file $args
@@ -199,10 +178,7 @@ proc scan-stack-usage { args } {
 # compiler.  See dg-scan for details.
 
 proc scan-stack-usage-not { args } {
-    upvar 2 name testcase
-    if { [llength $testcase] > 1 } {
-       set testcase "$testcase "
-    }
+    set testcase [testname-for-summary]
     set output_file "[file rootname [file tail $testcase]].su"
 
     dg-scan "scan-file-not" 0 $testcase $output_file $args
@@ -227,14 +203,7 @@ proc scan-assembler-times { args } {
        }
     }
 
-    # This assumes that we are two frames down from dg-test, and that
-    # it still stores the filename of the testcase in a local variable "name".
-    # A cleaner solution would require a new dejagnu release.
-    upvar 2 name testcase
-    if { [llength $testcase] > 1 } {
-       set testcase "$testcase "
-    }
-
+    set testcase [testname-for-summary]
     set pattern [lindex $args 0]
     set pp_pattern [make_pattern_printable $pattern]
 
@@ -292,10 +261,7 @@ proc scan-assembler-dem { args } {
        verbose -log "c++filt is $cxxfilt"
     }
 
-    upvar 2 name testcase
-    if { [llength $testcase] > 1 } {
-       set testcase "$testcase "
-    }
+    set testcase [testname-for-summary]
     set pattern [lindex $args 0]
     set pp_pattern [make_pattern_printable $pattern]
     set output_file "[file rootname [file tail $testcase]].s"
@@ -349,10 +315,7 @@ proc scan-assembler-dem-not { args } {
        verbose -log "c++filt is $cxxfilt"
     }
 
-    upvar 2 name testcase
-    if { [llength $testcase] > 1 } {
-       set testcase "$testcase "
-    }
+    set testcase [testname-for-summary]
     set pattern [lindex $args 0]
     set pp_pattern [make_pattern_printable $pattern]
     set output_file "[file rootname [file tail $testcase]].s"
@@ -407,11 +370,7 @@ proc object-size { args } {
        verbose -log "size is $size"
     }
 
-    upvar 2 name testcase
-    if { [llength $testcase] > 1 } {
-       set testcase "$testcase "
-    }
-
+    set testcase [testname-for-summary]
     set what [lindex $args 0]
     set where [lsearch { text data bss total } $what]
     if { $where == -1 } {
index 7cde2a23ecf1456f93ca630cd76694e513fd891b..80b554bf09ef5d560c0affa3f052931d72f497c2 100644 (file)
@@ -45,10 +45,7 @@ proc scan-dump { args } {
         }
     }
 
-    # This assumes that we are three frames down from dg-test, and that
-    # it still stores the filename of the testcase in a local variable "name".
-    # A cleaner solution would require a new DejaGnu release.
-    upvar 3 name testcase
+    set testcase [testname-for-summary]
 
     set suf [dump-suffix [lindex $args 2]]
     set testname "$testcase scan-[lindex $args 0]-dump $suf \"[lindex $args 1]\""
@@ -88,11 +85,7 @@ proc scan-dump-times { args } {
        }
     }
 
-    # This assumes that we are three frames down from dg-test, and that
-    # it still stores the filename of the testcase in a local variable "name".
-    # A cleaner solution would require a new DejaGnu release.
-    upvar 3 name testcase
-
+    set testcase [testname-for-summary]
     set suf [dump-suffix [lindex $args 3]]
     set printable_pattern [make_pattern_printable [lindex $args 1]]
     set testname "$testcase scan-[lindex $args 0]-dump-times $suf \"$printable_pattern\" [lindex $args 2]"
@@ -132,11 +125,7 @@ proc scan-dump-not { args } {
        }
     }
 
-    # This assumes that we are three frames down from dg-test, and that
-    # it still stores the filename of the testcase in a local variable "name".
-    # A cleaner solution would require a new DejaGnu release.
-    upvar 3 name testcase
-
+    set testcase [testname-for-summary]
     set suf [dump-suffix [lindex $args 2]]
     set testname "$testcase scan-[lindex $args 0]-dump-not $suf \"[lindex $args 1]\""
     set src [file tail [lindex $testcase 0]]
@@ -188,7 +177,7 @@ proc scan-dump-dem { args } {
        verbose -log "c++filt is $cxxfilt"
     }
 
-    upvar 3 name testcase
+    set testcase [testname-for-summary]
     set suf [dump-suffix [lindex $args 2]]
     set testname "$testcase scan-[lindex $args 0]-dump-dem $suf \"[lindex $args 1]\""
     set src [file tail [lindex $testcase 0]]
@@ -239,8 +228,7 @@ proc scan-dump-dem-not { args } {
        verbose -log "c++filt is $cxxfilt"
     }
 
-    upvar 3 name testcase
-
+    set testcase [testname-for-summary]
     set suf [dump-suffix [lindex $args 2]]
     set testname "$testcase scan-[lindex $args 0]-dump-dem-not $suf \"[lindex $args 1]\""
     set src [file tail [lindex $testcase 0]]
index a8f0a69a2e867439b2887e73faeda0b02eae09f4..2f6c4c2ce8359faa9f1fe5c76d84e32a1118916d 100644 (file)
@@ -31,6 +31,34 @@ proc current_compiler_flags { } {
     return "$flags1 $flags2"
 }
 
+# DejaGnu's dg-test defines a test name that includes torture options
+# which is used in most pass/fail messages.  Grab a copy of it.
+
+proc testname-for-summary { } {
+    global testname_with_flags
+
+    # A variable called "name" is too generic, so identify dg-test by
+    # the existence of dg-extra-tool-flags.
+    if ![info exists testname_with_flags] {
+       set frames 2
+       while { ![info exists flags] } {
+           set frames [expr $frames + 1]
+           upvar $frames dg-extra-tool-flags flags
+       }
+
+       # We've got the stack level for dg-test; get the variable we want.
+       upvar $frames name name
+       set testname_with_flags $name
+
+       # If there are flags, add an extra space to improve readability of
+       # the test summary.
+       if { [llength $testname_with_flags] > 1 } {
+           set testname_with_flags "$testname_with_flags "
+       }
+    }
+    return "$testname_with_flags"
+}
+
 # If this target does not support weak symbols, skip this test.
 
 proc dg-require-weak { args } {