1 # Tests for JVMTI code.
3 # Compile a single C++ file and produce a .o file. OPTIONS is a list
4 # of options to pass to the compiler. Returns 0 on failure, 1 on
6 proc gcj_jvmti_compile_cxx_to_o {file {options {}}} {
10 set name [file rootname [file tail $file]]
13 # Find the generated header.
14 lappend options "additional_flags=-g -I. -I.. -fdollars-in-identifiers"
15 # Find libgcj headers.
16 lappend options "additional_flags=-I$srcdir/.."
17 # Find jvmti.h, jvmti_md.h, jvmti-int.h, jvm.h requirements
18 lappend options "additional_flags=-I$srcdir/../include -I$srcdir/../classpath/include -I$objdir/../include -I$objdir/../../boehm-gc/include "
19 # ARM C++ emits an ABI warning for varargs.
20 if { [istarget "arm*"] } {
21 lappend options "additional_flags=-Wno-abi"
24 set x [libjava_prune_warnings \
25 [target_compile $file $oname object $options]]
27 verbose "target_compile failed: $x" 2
28 fail "[file tail $file] compilation"
32 pass "[file tail $file] compilation"
36 # Build header files given name of .java file. Return 0 on failure.
37 proc gcj_jvmti_build_headers {file} {
42 # Currently we only build a header file for the main class from the
43 # .java file. If we need more than this, we'll have to figure
45 set file [file rootname [file tail $file]]
47 set x [string trim [libjava_prune_warnings \
48 [lindex [local_exec "$gcjh -cni -force -classpath .:$libgcj_jar $file" "" "" 300] 1]]]
50 verbose "local_exec failed: $x" 2
51 fail "$file header generation"
55 pass "$file header generation"
59 # Do all the work for a single JVMTI test. Return 0 on failure.
60 proc gcj_jvmti_test_one {file} {
63 # The base name. We use it for several purposes.
64 set main [file rootname [file tail $file]]
65 if {! [runtest_file_p $runtests $main]} {
70 # if {! [bytecompile_file $file [pwd]]} {
71 # fail "bytecompile $file"
72 # # FIXME - should use `untested' on all remaining tests.
76 # pass "bytecompile $file"
78 # if {! [gcj_jvmti_build_headers $file]} {
83 set cfile [file join [file dirname $file] nat$main.cc]
84 if {! [gcj_jvmti_compile_cxx_to_o $cfile]} {
89 if {! [gcj_link $main $main [list $file nat$main.o]]} {
94 if {! [gcj_invoke $main [file rootname $file].out {}]} {
99 # When we succeed we remove all our clutter.
100 eval gcj_cleanup [glob -nocomplain -- ${main}.*] [list $main nat$main.o]
105 # Run the JVMTI tests.
106 proc gcj_jvmti_run {} {
108 global build_triplet host_triplet
110 # For now we only test JVMTI on native builds.
111 if {$build_triplet == $host_triplet} {
112 catch { lsort [glob -nocomplain ${srcdir}/${subdir}/*.jar] } srcfiles
114 foreach x $srcfiles {
115 gcj_jvmti_test_one $x
118 verbose "JVMTI tests not run in cross-compilation environment"