Fix expected messages in test
[official-gcc.git] / libjava / testsuite / libjava.jvmti / jvmti-interp.exp
blob62c82e92afc1616fbf07034360c153bfabf8b9bf
1 # 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.
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 ""
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.
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"
36 # ARM C++ emits an ABI warning for varargs.
37 if { [istarget "arm*"] } {
38 lappend options "additional_flags=-Wno-abi"
41 set filename [file tail $file]
42 set name [file rootname $filename]
43 set soname lib${name}.${so_extension}
45 lappend options "additional_flags=${so_flag} -fPIC"
46 # Find the generated header.
47 lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir"
49 # Ensure that the generated header has correct prototypes.
50 set cfile [file rootname $file].c
51 if { [file exists $cfile] } {
52 # This option is only valid for C sources.
53 lappend options "additional_flags=-Wmissing-prototypes"
56 # Find jni.h and jni_md.h.
57 lappend options "additional_flags=-I$srcdir/../include \
58 -I$srcdir/../classpath/include -fdollars-in-identifiers"
60 # Append C++ options
61 lappend options "additional_flags=$options_cxx"
63 set x [libjava_prune_warnings \
64 [target_compile $file $soname executable $options]]
65 if {$x != ""} {
66 verbose "target_compile failed: $x" 2
67 fail "$filename compilation"
68 return 0
71 pass "$filename compilation"
72 return 1
75 # Do all the work for a single JVMTI test. Return 0 on failure.
76 proc gij_jvmti_test_one {file} {
77 global runtests
79 # The base name. We use it for several purposes.
80 set main [file rootname [file tail $file]]
81 if {! [runtest_file_p $runtests $main] } {
82 # Simply skip it.
83 return 1
86 # if {! [bytecompile_file $file [pwd]] } {
87 # fail "bytecompile $file"
88 # # FIXME - should use `untested' on all remaining tests.
89 # # But that is hard.
90 # return 0
91 # }
92 # pass "bytecompile $file"
94 # if {! [gcj_jvmti_build_headers $file] } {
95 # # FIXME
96 # return 0
97 # }
99 set cfile [file join [file dirname $file] nat$main.c]
100 set cxxflags ""
101 set cxxldlibflags {}
102 # If there is no `.c' file, assume there is a `.cc' file.
103 if {! [file exists $cfile] } {
104 set cfile [file join [file dirname $file] nat$main.cc]
106 set cxxflaglist {}
107 foreach arg [split [libjava_find_lib libstdc++-v3/src stdc++] " "] {
108 switch -glob -- $arg {
109 "-L*" {
110 set arg [string range $arg 2 end]
111 lappend cxxldlibflags $arg
112 # Strip the `.libs' directory; we link with libtool which
113 # doesn't need it.
114 set arg "-L[file dirname $arg]"
118 lappend cxxflaglist $arg
119 # In case the libstdc++ is not installed yet, we pass the build
120 # directory of it to the cxxflaglist.
121 lappend cxxflaglist "-L$cxxldlibflags"
123 # If you're building the compiler with --prefix set to a place
124 # where it's not yet installed, then the linker won't be able to
125 # find the libgcc used by libgcj.dylib/libstdc++.dylib. We could pass
126 # the -dylib_file option, but that's complicated, and it's much easier
127 # to just make the linker find libgcc using -L options.
128 if { [istarget "*-*-darwin*"] } {
129 lappend cxxflaglist "-shared-libgcc -lstdc++"
130 } else {
131 lappend cxxflaglist "-lstdc++"
133 set cxxflags [join $cxxflaglist]
136 if {! [gcj_jni_compile_c_to_so $cfile $cxxflags] } {
137 # FIXME
138 return 0
141 libjava_arguments
143 set jarfile [file join [file dirname $file] $main.jar]
144 set gij_flags {-agentlib:dummyagent}
145 if {! [exec_gij $jarfile [file rootname $file].out $cxxldlibflags $gij_flags] } {
146 return 0
149 # When we succeed we remove all our clutter.
150 eval gcj_cleanup [glob -nocomplain -- ${main}.*] \
151 [list $main.class libnat$main.so]
153 return 1
156 # Run the JVMTI tests.
157 proc gij_jvmti_run {} {
158 global srcdir subdir
159 global build_triplet host_triplet
161 # For now we only test JVMTI on native builds.
162 if {$build_triplet == $host_triplet} {
164 # Build our dummy JVMTI agent library
165 if {![gcj_jni_compile_c_to_so [file join $srcdir $subdir dummyagent.c]]} {
166 fail "compiling dummy JVMTI agent"
167 } else {
168 pass "compiling dummy JVMTI agent"
170 catch {lsort [glob -nocomplain ${srcdir}/${subdir}/interp/*.jar]} \
171 srcfiles
173 foreach x $srcfiles {
174 gij_jvmti_test_one $x
177 gcj_cleanup libdummyagent.so
179 } else {
180 verbose "JVMTI tests not run in cross-compilation environment"
184 gij_jvmti_run