| 1 |
765 |
jeremybenn |
# Interpreted Tests for JVMTI code.
|
| 2 |
|
|
# These tests are used to test JVMTI functions in a purley interpreted setting
|
| 3 |
|
|
# This file compiles the JNI code into a shared object, then invokes gij to run
|
| 4 |
|
|
# the test.
|
| 5 |
|
|
|
| 6 |
|
|
|
| 7 |
|
|
# Compile a single C file and produce a .so file. OPTIONS is a list
|
| 8 |
|
|
# of options to pass to the compiler. Returns 0 on failure, 1 on
|
| 9 |
|
|
# success.
|
| 10 |
|
|
proc gcj_jni_compile_c_to_so {file {options {}}} {
|
| 11 |
|
|
global srcdir subdir
|
| 12 |
|
|
global host_triplet
|
| 13 |
|
|
verbose "options: $options"
|
| 14 |
|
|
set options_cxx $options
|
| 15 |
|
|
set options ""
|
| 16 |
|
|
|
| 17 |
|
|
# Apple uses a different extension for shared/dynamic libraries
|
| 18 |
|
|
# so we check against powerpc-apple-darwin and set them to
|
| 19 |
|
|
# dylib.
|
| 20 |
|
|
# HP-UX uses sl, so we check this too, otherwise we take so.
|
| 21 |
|
|
|
| 22 |
|
|
if { [istarget "*-*-darwin*"] } {
|
| 23 |
|
|
set so_extension "dylib"
|
| 24 |
|
|
set so_flag "-dynamiclib"
|
| 25 |
|
|
} elseif { [istarget "hppa*-hp-hpux*"] } {
|
| 26 |
|
|
set so_extension "sl"
|
| 27 |
|
|
set so_flag "-shared"
|
| 28 |
|
|
} elseif { [istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"] } {
|
| 29 |
|
|
set so_extension "dll"
|
| 30 |
|
|
set so_flag "-shared"
|
| 31 |
|
|
} else {
|
| 32 |
|
|
set so_extension "so"
|
| 33 |
|
|
set so_flag "-shared"
|
| 34 |
|
|
}
|
| 35 |
|
|
|
| 36 |
|
|
# ARM C++ emits an ABI warning for varargs.
|
| 37 |
|
|
if { [istarget "arm*"] } {
|
| 38 |
|
|
lappend options "additional_flags=-Wno-abi"
|
| 39 |
|
|
}
|
| 40 |
|
|
# Tru64 UNIX requires to be compiled with -pthread.
|
| 41 |
|
|
if { [istarget "alpha*-dec-osf*"] } {
|
| 42 |
|
|
lappend options "additional_flags=-pthread"
|
| 43 |
|
|
}
|
| 44 |
|
|
|
| 45 |
|
|
set filename [file tail $file]
|
| 46 |
|
|
set name [file rootname $filename]
|
| 47 |
|
|
set soname lib${name}.${so_extension}
|
| 48 |
|
|
|
| 49 |
|
|
lappend options "additional_flags=${so_flag} -fPIC"
|
| 50 |
|
|
# Find the generated header.
|
| 51 |
|
|
lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir"
|
| 52 |
|
|
|
| 53 |
|
|
# Ensure that the generated header has correct prototypes.
|
| 54 |
|
|
set cfile [file rootname $file].c
|
| 55 |
|
|
if { [file exists $cfile] } {
|
| 56 |
|
|
# This option is only valid for C sources.
|
| 57 |
|
|
lappend options "additional_flags=-Wmissing-prototypes"
|
| 58 |
|
|
}
|
| 59 |
|
|
|
| 60 |
|
|
# Find jni.h and jni_md.h.
|
| 61 |
|
|
lappend options "additional_flags=-I$srcdir/../include \
|
| 62 |
|
|
-I$srcdir/../classpath/include -fdollars-in-identifiers"
|
| 63 |
|
|
|
| 64 |
|
|
# Append C++ options
|
| 65 |
|
|
lappend options "additional_flags=$options_cxx"
|
| 66 |
|
|
|
| 67 |
|
|
set x [libjava_prune_warnings \
|
| 68 |
|
|
[target_compile $file $soname executable $options]]
|
| 69 |
|
|
if {$x != ""} {
|
| 70 |
|
|
verbose "target_compile failed: $x" 2
|
| 71 |
|
|
fail "$filename compilation"
|
| 72 |
|
|
return 0
|
| 73 |
|
|
}
|
| 74 |
|
|
|
| 75 |
|
|
pass "$filename compilation"
|
| 76 |
|
|
return 1
|
| 77 |
|
|
}
|
| 78 |
|
|
|
| 79 |
|
|
# Do all the work for a single JVMTI test. Return 0 on failure.
|
| 80 |
|
|
proc gij_jvmti_test_one {file} {
|
| 81 |
|
|
global runtests
|
| 82 |
|
|
|
| 83 |
|
|
# The base name. We use it for several purposes.
|
| 84 |
|
|
set main [file rootname [file tail $file]]
|
| 85 |
|
|
if {! [runtest_file_p $runtests $main] } {
|
| 86 |
|
|
# Simply skip it.
|
| 87 |
|
|
return 1
|
| 88 |
|
|
}
|
| 89 |
|
|
|
| 90 |
|
|
# if {! [bytecompile_file $file [pwd]] } {
|
| 91 |
|
|
# fail "bytecompile $file"
|
| 92 |
|
|
# # FIXME - should use `untested' on all remaining tests.
|
| 93 |
|
|
# # But that is hard.
|
| 94 |
|
|
# return 0
|
| 95 |
|
|
# }
|
| 96 |
|
|
# pass "bytecompile $file"
|
| 97 |
|
|
|
| 98 |
|
|
# if {! [gcj_jvmti_build_headers $file] } {
|
| 99 |
|
|
# # FIXME
|
| 100 |
|
|
# return 0
|
| 101 |
|
|
# }
|
| 102 |
|
|
|
| 103 |
|
|
set cfile [file join [file dirname $file] nat$main.c]
|
| 104 |
|
|
set cxxflags ""
|
| 105 |
|
|
set cxxldlibflags {}
|
| 106 |
|
|
# If there is no `.c' file, assume there is a `.cc' file.
|
| 107 |
|
|
if {! [file exists $cfile] } {
|
| 108 |
|
|
set cfile [file join [file dirname $file] nat$main.cc]
|
| 109 |
|
|
|
| 110 |
|
|
set cxxflaglist {}
|
| 111 |
|
|
foreach arg [split [libjava_find_lib libstdc++-v3/src stdc++] " "] {
|
| 112 |
|
|
switch -glob -- $arg {
|
| 113 |
|
|
"-L*" {
|
| 114 |
|
|
set arg [string range $arg 2 end]
|
| 115 |
|
|
lappend cxxldlibflags $arg
|
| 116 |
|
|
# Strip the `.libs' directory; we link with libtool which
|
| 117 |
|
|
# doesn't need it.
|
| 118 |
|
|
set arg "-L[file dirname $arg]"
|
| 119 |
|
|
}
|
| 120 |
|
|
}
|
| 121 |
|
|
|
| 122 |
|
|
lappend cxxflaglist $arg
|
| 123 |
|
|
# In case the libstdc++ is not installed yet, we pass the build
|
| 124 |
|
|
# directory of it to the cxxflaglist.
|
| 125 |
|
|
lappend cxxflaglist "-L$cxxldlibflags"
|
| 126 |
|
|
}
|
| 127 |
|
|
# If you're building the compiler with --prefix set to a place
|
| 128 |
|
|
# where it's not yet installed, then the linker won't be able to
|
| 129 |
|
|
# find the libgcc used by libgcj.dylib/libstdc++.dylib. We could pass
|
| 130 |
|
|
# the -dylib_file option, but that's complicated, and it's much easier
|
| 131 |
|
|
# to just make the linker find libgcc using -L options.
|
| 132 |
|
|
if { [istarget "*-*-darwin*"] } {
|
| 133 |
|
|
lappend cxxflaglist "-shared-libgcc -lstdc++"
|
| 134 |
|
|
} else {
|
| 135 |
|
|
lappend cxxflaglist "-lstdc++"
|
| 136 |
|
|
}
|
| 137 |
|
|
set cxxflags [join $cxxflaglist]
|
| 138 |
|
|
}
|
| 139 |
|
|
|
| 140 |
|
|
if {! [gcj_jni_compile_c_to_so $cfile $cxxflags] } {
|
| 141 |
|
|
# FIXME
|
| 142 |
|
|
return 0
|
| 143 |
|
|
}
|
| 144 |
|
|
|
| 145 |
|
|
libjava_arguments
|
| 146 |
|
|
|
| 147 |
|
|
set jarfile [file join [file dirname $file] $main.jar]
|
| 148 |
|
|
set gij_flags {-agentlib:dummyagent}
|
| 149 |
|
|
if {! [exec_gij $jarfile [file rootname $file].out $cxxldlibflags $gij_flags] } {
|
| 150 |
|
|
return 0
|
| 151 |
|
|
}
|
| 152 |
|
|
|
| 153 |
|
|
# When we succeed we remove all our clutter.
|
| 154 |
|
|
eval gcj_cleanup [glob -nocomplain -- ${main}.*] \
|
| 155 |
|
|
[list $main.class libnat$main.so]
|
| 156 |
|
|
|
| 157 |
|
|
return 1
|
| 158 |
|
|
}
|
| 159 |
|
|
|
| 160 |
|
|
# Run the JVMTI tests.
|
| 161 |
|
|
proc gij_jvmti_run {} {
|
| 162 |
|
|
global srcdir subdir
|
| 163 |
|
|
global build_triplet host_triplet
|
| 164 |
|
|
|
| 165 |
|
|
# For now we only test JVMTI on native builds.
|
| 166 |
|
|
if {$build_triplet == $host_triplet} {
|
| 167 |
|
|
|
| 168 |
|
|
# Build our dummy JVMTI agent library
|
| 169 |
|
|
if {![gcj_jni_compile_c_to_so [file join $srcdir $subdir dummyagent.c]]} {
|
| 170 |
|
|
fail "compiling dummy JVMTI agent"
|
| 171 |
|
|
} else {
|
| 172 |
|
|
pass "compiling dummy JVMTI agent"
|
| 173 |
|
|
|
| 174 |
|
|
catch {lsort [glob -nocomplain ${srcdir}/${subdir}/interp/*.jar]} \
|
| 175 |
|
|
srcfiles
|
| 176 |
|
|
|
| 177 |
|
|
foreach x $srcfiles {
|
| 178 |
|
|
gij_jvmti_test_one $x
|
| 179 |
|
|
}
|
| 180 |
|
|
|
| 181 |
|
|
gcj_cleanup libdummyagent.so
|
| 182 |
|
|
}
|
| 183 |
|
|
} else {
|
| 184 |
|
|
verbose "JVMTI tests not run in cross-compilation environment"
|
| 185 |
|
|
}
|
| 186 |
|
|
}
|
| 187 |
|
|
|
| 188 |
|
|
gij_jvmti_run
|