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.."
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"
20 set x [libjava_prune_warnings \
21 [target_compile $file $oname object $options]]
23 verbose "target_compile failed: $x" 2
24 fail "[file tail $file] compilation"
28 pass "[file tail $file] compilation"
32 # Build header files given name of .java file. Return 0 on failure.
33 proc gcj_jvmti_build_headers {file} {
35 set jvscan [find_jvscan]
37 set class_out [string trim \
38 [libjava_prune_warnings \
39 [lindex [local_exec "$jvscan --encoding=UTF-8 $file --list-class" "" "" 300] 1]]]
40 if {[string match "*parse error*" $class_out]} {
41 fail "$file header generation"
45 foreach file [split $class_out] {
46 set x [string trim [libjava_prune_warnings \
47 [lindex [local_exec "$gcjh $file" "" "" 300] 1]]]
49 verbose "local_exec failed: $x" 2
50 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}/*.java] } srcfiles
114 foreach x $srcfiles {
115 gcj_jvmti_test_one $x
118 verbose "JVMTI tests not run in cross-compilation environment"