OSDN Git Service

* lib/gcc-dg.exp (cleanup-ipa-dump): New.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / gcc-dg.exp
index 9f55b02..ab2f189 100644 (file)
@@ -52,28 +52,12 @@ if ![info exists GCC_UNDER_TEST] {
     set GCC_UNDER_TEST "[find_gcc]"
 }
 
-global rootme
-global ld_library_path
 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 } {
-    set ld_library_path "${rootme}"
-    set compiler [lindex $GCC_UNDER_TEST 0]
-    if { [is_remote host] == 0 && [which $compiler] != 0 } {
-       foreach i "[exec $compiler --print-multi-lib]" {
-           set mldir ""
-           regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
-           set mldir [string trimright $mldir "\;@"]
-           if { "$mldir" == "." } {
-               continue
-           }
-           if { [llength [glob -nocomplain ${rootme}/${mldir}/libgcc_s*.so.*]] >= 1 } {
-               append ld_library_path ":${rootme}/${mldir}"
-           }
-       }
-    }
+    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
     set_ld_library_path_env_vars
 }
 
@@ -138,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"
@@ -150,7 +134,7 @@ 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"
@@ -311,6 +295,127 @@ proc dg-prune-output { args } {
     lappend additional_prunes [lindex $args 1]
 }
 
+# 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
+    }
+}
+
+# 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??"
+       }
+    }
+}
+
+# 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"
+       }
+    }
+}
+
+# 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"
+       }
+    }
+}
+
+# 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"
+       }
+    }
+}
+
+# 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"
+       }
+    }
+}
+
+# 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