diff options
author | Kyle Galloway <kgallowa@gcc.gnu.org> | 2007-01-25 14:19:05 +0000 |
---|---|---|
committer | Kyle Galloway <kgallowa@gcc.gnu.org> | 2007-01-25 14:19:05 +0000 |
commit | 05296a28103564cf997ab72b5b733cadb74cfe74 (patch) | |
tree | 70a7ee7248f268a6818681493213cb640b51ef17 /libjava/testsuite/libjava.jvmti | |
parent | 6bfcbf0d48e8e9e71abb7302f677ab5bd32286e0 (diff) | |
download | gcc-05296a28103564cf997ab72b5b733cadb74cfe74.zip gcc-05296a28103564cf997ab72b5b733cadb74cfe74.tar.gz gcc-05296a28103564cf997ab72b5b733cadb74cfe74.tar.bz2 |
jvmti-interp.exp: New file.
2007-01-25 Kyle Galloway <kgallowa@redhat.com>
* libjava/testsuite/libjava.jvmti/jvmti-interp.exp: New file.
* libjava/testsuite/libjava.jvmti/interp: New folder.
* libjava/testsuite/lib/libjava.exp (exec_gij): New Method.
From-SVN: r121172
Diffstat (limited to 'libjava/testsuite/libjava.jvmti')
-rw-r--r-- | libjava/testsuite/libjava.jvmti/jvmti-interp.exp | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/libjava/testsuite/libjava.jvmti/jvmti-interp.exp b/libjava/testsuite/libjava.jvmti/jvmti-interp.exp new file mode 100644 index 0000000..0c0fca1 --- /dev/null +++ b/libjava/testsuite/libjava.jvmti/jvmti-interp.exp @@ -0,0 +1,158 @@ +# Interpreted Tests for JVMTI code. +# These tests are used to test JVMTI functions in a purley interpreted setting +# This file compiles the JNI code into a shared object, then invokes gij to run +# the test. + + +# Compile a single C file and produce a .so file. OPTIONS is a list +# of options to pass to the compiler. Returns 0 on failure, 1 on +# success. +proc gcj_jni_compile_c_to_so {file {options {}}} { + global srcdir subdir + global host_triplet + verbose "options: $options" + set options_cxx $options + set options "" + +# Apple uses a different extension for shared/dynamic libraries +# so we check against powerpc-apple-darwin and set them to +# dylib. +# HP-UX uses sl, so we check this too, otherwise we take so. + + if { [istarget "*-*-darwin*"] } { + set so_extension "dylib" + set so_flag "-dynamiclib" + } elseif { [istarget "hppa*-hp-hpux*"] } { + set so_extension "sl" + set so_flag "-shared" + } else { + set so_extension "so" + set so_flag "-shared" + } + + set filename [file tail $file] + set name [file rootname $filename] + set soname lib${name}.${so_extension} + + lappend options "additional_flags=${so_flag} -fPIC" + # Find the generated header. + lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir" + + # Ensure that the generated header has correct prototypes. + set cfile [file rootname $file].c + if { [file exists $cfile] } { + # This option is only valid for C sources. + lappend options "additional_flags=-Wmissing-prototypes" + } + + # Find jni.h and jni_md.h. + lappend options "additional_flags=-I$srcdir/../include \ + -I$srcdir/../classpath/include" + + # Append C++ options + lappend options "additional_flags=$options_cxx" + + set x [libjava_prune_warnings \ + [target_compile $file $soname executable $options]] + if {$x != ""} { + verbose "target_compile failed: $x" 2 + fail "$filename compilation" + return 0 + } + + pass "$filename compilation" + return 1 +} + +# Do all the work for a single JVMTI test. Return 0 on failure. +proc gij_jvmti_test_one {file} { + global runtests + + # The base name. We use it for several purposes. + set main [file rootname [file tail $file]] + if {! [runtest_file_p $runtests $main] } { + # Simply skip it. + return 1 + } + +# if {! [bytecompile_file $file [pwd]] } { +# fail "bytecompile $file" +# # FIXME - should use `untested' on all remaining tests. +# # But that is hard. +# return 0 +# } +# pass "bytecompile $file" + +# if {! [gcj_jvmti_build_headers $file] } { +# # FIXME +# return 0 +# } + + set cfile [file join [file dirname $file] nat$main.c] + set cxxflags "" + set cxxldlibflags {} + # If there is no `.c' file, assume there is a `.cc' file. + if {! [file exists $cfile] } { + set cfile [file join [file dirname $file] nat$main.cc] + + set cxxflaglist {} + foreach arg [split [libjava_find_lib libstdc++-v3/src stdc++] " "] { + switch -glob -- $arg { + "-L*" { + set arg [string range $arg 2 end] + lappend cxxldlibflags $arg + # Strip the `.libs' directory; we link with libtool which + # doesn't need it. + set arg "-L[file dirname $arg]" + } + } + + lappend cxxflaglist $arg + # In case the libstdc++ is not installed yet, we pass the build + # directory of it to the cxxflaglist. + lappend cxxflaglist "-L$cxxldlibflags" + } + + lappend cxxflaglist "-lstdc++" + + set cxxflags [join $cxxflaglist] + } + + if {! [gcj_jni_compile_c_to_so $cfile $cxxflags] } { + # FIXME + return 0 + } + + libjava_arguments + + set jarfile [file join [file dirname $file] $main.jar] + if {! [exec_gij $jarfile [file rootname $file].out {}]} { + return 0 + } + + # When we succeed we remove all our clutter. + eval gcj_cleanup [glob -nocomplain -- ${main}.*] \ + [list $main.class libnat$main.so] + + return 1 +} + +# Run the JVMTI tests. +proc gij_jvmti_run {} { + global srcdir subdir + global build_triplet host_triplet + + # For now we only test JVMTI on native builds. + if {$build_triplet == $host_triplet} { + catch { lsort [glob -nocomplain ${srcdir}/${subdir}/interp/*.jar] \ + } srcfiles + + foreach x $srcfiles { + gij_jvmti_test_one $x + } + } else { + verbose "JVMTI tests not run in cross-compilation environment" + } +} + +gij_jvmti_run |