OSDN Git Service

gcc/testsuite:
[pf3gnuchains/gcc-fork.git] / libjava / testsuite / lib / libjava.exp
index a9ec73e..9b45f3c 100644 (file)
@@ -188,6 +188,21 @@ proc libjava_find_lib {dir name} {
     return ""
 }
 
+# Remove a bunch of files.
+proc gcj_cleanup {args} {
+    foreach file $args {
+       if {[string match *.o $file]} {
+           verbose "removing [file rootname $file].lo"
+           file delete -force [file rootname $file].lo
+       }
+       file delete -force -- $file
+       verbose "removing $file"
+    }
+    # It is simplest to do this instead of trying to figure out what
+    # bits in .libs ought to be removed.
+    catch {system "rm -rf .libs"}
+}
+
 # Compute arguments needed for compiler.  MODE is a libtool mode:
 # either compile or link.
 proc libjava_arguments {{mode compile}} {
@@ -321,6 +336,27 @@ proc libjava_arguments {{mode compile}} {
     return $args
 }
 
+# Link a bunch of objects into a program.  MAIN is the name of the
+# class holding `main'.  Return 0 on failure.
+proc gcj_link {program main files {options {}}} {
+    set arguments [libjava_arguments link]
+    if {[llength $options]} {
+       eval lappend arguments $options
+    }
+    lappend arguments "additional_flags=--main=$main"
+    set x [prune_warnings [libjava_tcompile $files $program executable \
+                            $arguments]]
+    if {$x != ""} {
+       verbose "link failure: $x" 2
+       fail "linking $program"
+       setup_xfail "*-*-*"
+       fail "running $program"
+       return 0
+    }
+
+    pass "linking $program"
+    return 1
+}
 
 #
 # Run the test specified by srcfile and resultfile. compile_args and
@@ -383,6 +419,8 @@ proc test_libjava_from_source { options srcfile compile_args inpfile resultfile
        set errname "$errname $compile_args"
     }
 
+    set removeList [list $executable]
+
     set x [prune_warnings \
             [libjava_tcompile $srcfile "$executable" $target $args]]
     if {[info exists opts(xfail-gcj)]} {
@@ -393,6 +431,7 @@ proc test_libjava_from_source { options srcfile compile_args inpfile resultfile
 
        if {[info exists opts(shouldfail)]} {
            pass "$errname compilation from source"
+           eval gcj_cleanup $removeList
            return
        }
 
@@ -419,9 +458,11 @@ proc test_libjava_from_source { options srcfile compile_args inpfile resultfile
            untested "$errname execution from source compiled test"
            untested "$errname output from source compiled test"
        }
+       eval gcj_cleanup $removeList
        return
     }
     if {[info exists opts(no-link)]} {
+       eval gcj_cleanup $removeList
        return
     }
 
@@ -467,6 +508,7 @@ proc test_libjava_from_source { options srcfile compile_args inpfile resultfile
     }
     if { $passed == 1 } {
        pass "$errname output from source compiled test"
+       eval gcj_cleanup $removeList
     } else {
        clone_output "expected was $expected"
        clone_output "output was $output"
@@ -542,6 +584,8 @@ proc test_libjava_from_javac { options srcfile compile_args inpfile resultfile e
     }
     pass "$errname byte compilation"
 
+    set removeList {}
+
     # Find name to use for --main, and name of all class files.
     set jvscan [find_jvscan]
     verbose "jvscan is $jvscan"
@@ -573,6 +617,8 @@ proc test_libjava_from_javac { options srcfile compile_args inpfile resultfile e
        lappend class_files $objdir/$file.class
     }
 
+    eval lappend removeList $class_files
+
     # Usually it is an error for a test program not to have a `main'
     # method.  However, for no-exec tests it is ok.  Treat no-link
     # like no-exec here.
@@ -615,18 +661,20 @@ proc test_libjava_from_javac { options srcfile compile_args inpfile resultfile e
            set executable [file rootname [file tail $c_file]].o
            set x [prune_warnings \
                     [libjava_tcompile $c_file "$executable" $type $args]]
+           lappend removeList $executable
            if {$x != ""} {
                break
            }
        }
     } else {
-       # This is no evil: we de-listify CLASS_FILES so that we can
+       # This is so evil: we de-listify CLASS_FILES so that we can
        # turn around and quote the `$' in it for the shell.  I really
        # hate DejaGNU.  It is so !@#$!@# unpredictable.
        set hack ""
        foreach stupid $class_files {
            set hack "$hack $stupid"
        }
+       lappend removeList $executable
        set x [prune_warnings \
                 [libjava_tcompile $hack "$executable" $type $args]]
     }
@@ -650,6 +698,7 @@ proc test_libjava_from_javac { options srcfile compile_args inpfile resultfile e
            untested "$errname execution from bytecode->native test"
            untested "$errname output from bytecode->native test"
        }
+       eval gcj_cleanup $removeList
        return
     }
 
@@ -662,7 +711,7 @@ proc test_libjava_from_javac { options srcfile compile_args inpfile resultfile e
     $status "$errname execution from bytecode->native test"
     if { $status != "pass" } {
        untested "$errname output from bytecode->native test"
-       return;
+       return
     }
 
     verbose "resultfile is $resultfile"
@@ -695,6 +744,7 @@ proc test_libjava_from_javac { options srcfile compile_args inpfile resultfile e
     }
     if { $passed == 1 } {
        pass "$errname output from bytecode->native test"
+       eval gcj_cleanup $removeList
     } else {
        clone_output "expected was $expected"
        clone_output "output was $output"
@@ -737,6 +787,20 @@ proc default_libjava_version {} {
 proc default_libjava_start { } {
 }
 
+# On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
+# called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
+# (for the 64-bit ABI).  The right way to do this would be to modify
+# unix.exp -- but that's not an option since it's part of DejaGNU
+# proper, so we do it here, by trickery.  We really only need to do 
+# this on IRIX, but it shouldn't hurt to do it anywhere else.
+
+proc ${tool}_set_ld_library_path { name element op } {
+  setenv LD_LIBRARYN32_PATH [getenv LD_LIBRARY_PATH]
+  setenv LD_LIBRARY64_PATH [getenv LD_LIBRARY_PATH]
+}
+
+trace variable env(LD_LIBRARY_PATH) w ${tool}_set_ld_library_path
+
 # Local Variables:
 # tcl-indent-level:4
 # End: