OSDN Git Service

* lib/gcc-dg.exp (cleanup-ipa-dump): New.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / gcc-dg.exp
index d1a85a8..ab2f189 100644 (file)
@@ -1,4 +1,4 @@
-#   Copyright (C) 1997, 1999, 2000, 2003 Free Software Foundation, Inc.
+#   Copyright (C) 1997, 1999, 2000, 2003, 2004, 2005 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
 load_lib dg.exp
 load_lib file-format.exp
 load_lib target-supports.exp
+load_lib target-supports-dg.exp
 load_lib scanasm.exp
+load_lib scantree.exp
 load_lib prune.exp
+load_lib libgloss.exp
+load_lib target-libpath.exp
+
+# We set LC_ALL and LANG to C so that we get the same error messages as expected.
+setenv LC_ALL C
+setenv LANG C
 
 if ![info exists TORTURE_OPTIONS] {
     # It is theoretically beneficial to group all of the O2/O3 options together,
@@ -39,6 +47,19 @@ if ![info exists TORTURE_OPTIONS] {
        { -Os } ]
 }
 
+global GCC_UNDER_TEST
+if ![info exists GCC_UNDER_TEST] {
+    set GCC_UNDER_TEST "[find_gcc]"
+}
+
+global orig_environment_saved
+
+# This file may be sourced, so don't override environment settings
+# that have been previously setup.
+if { $orig_environment_saved == 0 } {
+    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+    set_ld_library_path_env_vars
+}
 
 # Split TORTURE_OPTIONS into two choices: one for testcases with loops and
 # one for testcases without loops.
@@ -101,7 +122,7 @@ proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
            set output_file "./[file rootname [file tail $prog]].exe"
            # This is the only place where we care if an executable was
            # created or not.  If it was, dg.exp will try to run it.
-           remote_file build delete $output_file;
+           remote_file build delete $output_file
        }
        default {
            perror "$do_what: not a valid dg-do keyword"
@@ -113,13 +134,15 @@ proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
        lappend options "additional_flags=$extra_tool_flags"
     }
 
-    set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options];
+    set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options]
 
     if { $do_what == "repo" } {
        set object_file "$output_file"
        set output_file "[file rootname [file tail $prog]].exe"
-       concat comp_output \
-              [$target_compile "$object_file" "$output_file" "executable" $options]
+       set comp_output \
+           [ concat $comp_output \
+                 [$target_compile "$object_file" "$output_file" \
+                      "executable" $options] ]
     }
 
     return [list $comp_output $output_file]
@@ -260,127 +283,139 @@ proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } {
     }
 }
 
-# If this target does not support weak symbols, skip this test.
-
-proc dg-require-weak { args } {
-    upvar dg-do-what dg-do-what
-    upvar name name
+# Prune any messages matching ARGS[1] (a regexp) from test output.
+proc dg-prune-output { args } {
+    global additional_prunes
 
-    set weak_available [ check_weak_available ]
-    if { $weak_available == -1 } {
-       unresolved "$name"
-    }
-    if { $weak_available != 1 } {
-       set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+    if { [llength $args] != 2 } {
+       error "[lindex $args 1]: need one argument"
        return
     }
-}
-
-# If this target does not support the "visibility" attribute, skip this
-# test.
-
-proc dg-require-visibility { args } {
-    upvar dg-do-what dg-do-what
-    upvar name name
 
-    set visibility_available [ check_visibility_available ]
-    if { $visibility_available == -1 } {
-       unresolved "$name"
-    }
-    if { $visibility_available != 1 } {
-       set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
-       return
-    }
+    lappend additional_prunes [lindex $args 1]
 }
 
-# If this target does not support the "alias" attribute, skip this
-# test.
-
-proc dg-require-alias { args } {
-    upvar dg-do-what dg-do-what
-    upvar name name
-
-    set alias_available [ check_alias_available ]
-    if { $alias_available == -1 } {
-       unresolved "$name"
-    }
-    if { $alias_available < 2 } {
-       set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
-       return
+# Remove files matching the pattern from the build machine.
+proc remove-build-file { pat } {
+    verbose "remove-build-file `$pat'" 2
+    set file_list "[glob -nocomplain $pat]"
+    verbose "remove-build-file `$file_list'" 2
+    foreach output_file $file_list {
+       remote_file build delete $output_file
     }
 }
 
-# If this target's linker does not support the --gc-sections flag,
-# skip this test.
-
-proc dg-require-gc-sections { args } {
-    if { ![ check_gc_sections_available ] } {
-       upvar dg-do-what dg-do-what
-       set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
-       return
+# 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
+    remove-build-file "[file rootname [file tail $testcase]].gc??"
+
+    # Clean up coverage files for additional source files.
+    if [info exists additional_sources] {
+       foreach srcfile $additional_sources {
+           remove-build-file "[file rootname [file tail $srcfile]].gc??"
+       }
     }
 }
 
-# If this target does not support profiling, skip this test.
-
-proc dg-require-profiling { args } {
-    if { ![ check_profiling_available ${args} ] } {
-       upvar dg-do-what dg-do-what
-       set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
-       return
+# 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
+    remove-build-file "[file rootname [file tail $testcase]].o"
+    remove-build-file "[file rootname [file tail $testcase]].rpo"
+
+    # Clean up files for additional source files.
+    if [info exists additional_sources] {
+       foreach srcfile $additional_sources {
+           remove-build-file "[file rootname [file tail $srcfile]].o"
+           remove-build-file "[file rootname [file tail $srcfile]].rpo"
+       }
     }
 }
 
-# If this target does not support DLL attributes skip this test.
-
-proc dg-require-dll { args } {
-    global target_triplet
-    # As a special case, the mcore-*-elf supports dllimport/dllexport.
-    if { [string match "mcore-*-elf" $target_triplet] } {
-       return
-    }
-    # PE/COFF targets support dllimport/dllexport.
-    if { [gcc_target_object_format] == "pe" } {
-       return
+# Remove compiler-generated RTL dump files for the current test.
+#
+# SUFFIX is the filename suffix pattern.
+proc cleanup-rtl-dump { suffix } {
+    # 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
+    remove-build-file "[file tail $testcase].??.$suffix"
+
+    # Clean up dump files for additional source files.
+    if [info exists additional_sources] {
+       foreach srcfile $additional_sources {
+           remove-build-file "[file tail $srcfile].??.$suffix"
+       }
     }
-
-    upvar dg-do-what dg-do-what
-    set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
 }
 
-proc dg-require-iconv { args } {
-    if { ![ check_iconv_available ${args} ] } {
-       upvar dg-do-what dg-do-what
-       set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
-       return
+# Remove a specific tree dump file for the current test.
+#
+# SUFFIX is the file suffix pattern.
+proc cleanup-tree-dump { suffix } {
+    # 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
+    remove-build-file "[file tail $testcase].t??.$suffix"
+
+    # Clean up dump files for additional source files.
+    if [info exists additional_sources] {
+       foreach srcfile $additional_sources {
+           remove-build-file "[file tail $srcfile].t??.$suffix"
+       }
     }
-    return
 }
 
-# Prune any messages matching ARGS[1] (a regexp) from test output.
-proc dg-prune-output { args } {
-    global additional_prunes
-
-    if { [llength $args] != 2 } {
-       error "[lindex $args 1]: need one argument"
-       return
+# Remove a specific ipa dump file for the current test.
+#
+# SUFFIX is the file suffix pattern.
+proc cleanup-ipa-dump { suffix } {
+    # 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
+    remove-build-file "[file tail $testcase].i??.$suffix"
+
+    # Clean up dump files for additional source files.
+    if [info exists additional_sources] {
+       foreach srcfile $additional_sources {
+           remove-build-file "[file tail $srcfile].i??.$suffix"
+       }
     }
-
-    lappend additional_prunes [lindex $args 1]
 }
 
-# Like check_conditional_xfail, but callable from a dg test.
-
-proc dg-xfail-if { args } {
-    set args [lreplace $args 0 0]
-    set selector "target [join [lindex $args 1]]"
-    if { [dg-process-target $selector] == "S" } {
-       global compiler_conditional_xfail_data
-       set compiler_conditional_xfail_data $args
+# Remove files kept by --save-temps for the current test.
+#
+# Currently this is only .i files, but more can be added if there are
+# tests generating them.
+proc cleanup-saved-temps { } {
+    global additional_sources
+
+    # 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
+    remove-build-file "[file rootname [file tail $testcase]].ii"
+    remove-build-file "[file rootname [file tail $testcase]].i"
+
+    # Clean up saved temp files for additional source files.
+    if [info exists additional_sources] {
+       foreach srcfile $additional_sources {
+            remove-build-file "[file rootname [file tail $srcfile]].ii"
+            remove-build-file "[file rootname [file tail $srcfile]].i"
+       }
     }
 }
 
-
 # We need to make sure that additional_* are cleared out after every
 # test.  It is not enough to clear them out *before* the next test run
 # because gcc-target-compile gets run directly from some .exp files
@@ -397,17 +432,25 @@ if { [info procs saved-dg-test] == [list] } {
        global additional_sources
        global additional_prunes
        global errorInfo
+       global compiler_conditional_xfail_data
 
        if { [ catch { eval saved-dg-test $args } errmsg ] } {
            set saved_info $errorInfo
            set additional_files ""
            set additional_sources ""
            set additional_prunes ""
+           if [info exists compiler_conditional_xfail_data] {
+               unset compiler_conditional_xfail_data
+           }
            error $errmsg $saved_info
        }
        set additional_files ""
        set additional_sources ""
        set additional_prunes ""
+       if [info exists compiler_conditional_xfail_data] {
+           unset compiler_conditional_xfail_data
+       }
     }
 }
+
 set additional_prunes ""