This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: Run JNI tests using interpreter


There are some JNI problems that potentially show up only when using the interpreter. So, it makes sense that we run the jni test suite using the interpreter in addition to native. This patch adds the neccessary code to jni.exp.

One problem showed up, in that jni.exp was appending c++ flags (-lstdc++) to the main binary of c++ JNI test cases, and not the JNI shared library itself. This worked for native tests but isn't really correct, since its the .so which has the c++ lib dependency. Of course it broke when trying to run with the interpreter because gij is not linked with libstdc++.

Tom, does this patch look ok to you?

Bryce


2004-05-05  Bryce McKinlay  <mckinlay@redhat.com>

	Run the jni tests using the interpreter.
	* testsuite/libjava.jni/jni.exp (gcj_jni_compile_c_to_so): Append
	options_cxx to shared lib compile command.
	(gcj_jni_test_one): Pass cxxflags to gcj_jni_compile_c_to_so, so
	they are used to link the shared lib, not the main binary.
	Use libjava_invoke to run gij.

Index: jni.exp
===================================================================
RCS file: /cvs/gcc/gcc/libjava/testsuite/libjava.jni/jni.exp,v
retrieving revision 1.12
diff -u -r1.12 jni.exp
--- jni.exp	30 Apr 2004 18:19:37 -0000	1.12
+++ jni.exp	5 May 2004 22:18:15 -0000
@@ -39,6 +39,9 @@
   # Find jni.h.
   lappend options "additional_flags=-I$srcdir/../include"
 
+  # Append C++ options
+  lappend options "additional_flags=$options_cxx"
+
   set x [libjava_prune_warnings \
 	   [target_compile $file $soname executable $options]]
   if {$x != ""} {
@@ -71,6 +74,7 @@
 proc gcj_jni_test_one {file} {
   global runtests
   global host_triplet
+  global INTERPRETER
 
 # apple uses a different extension for shared/dynamic libraries
 # so we check against powerpc-apple-darwin and set them to 
@@ -128,23 +132,36 @@
     set cxxflags [join $cxxflaglist]
   }
 
-  if {! [gcj_jni_compile_c_to_so $cfile]} {
+  if {! [gcj_jni_compile_c_to_so $cfile $cxxflags]} {
     # FIXME
     return 0
   }
 
   # We use -l$main because the .so is named the same as the main
   # program.
-  set args [list "additional_flags=-fjni -L. -l$main $cxxflags"]
+  set args [list "additional_flags=-fjni -L. -l$main"]
   if {! [gcj_link $main $main $file $args]} {
     # FIXME
     return 0
   }
 
-  if {! [gcj_invoke $main [file rootname $file].out $cxxldlibflags]} {
+  set resultfile [file rootname $file].out
+
+  if {! [gcj_invoke $main $resultfile $cxxldlibflags]} {
     # FIXME
     return 0
   }
+  
+  # We purposely ignore errors here; we still want to run the other
+  # appropriate tests.
+  set errname [file rootname [file tail $file]]
+  set gij [libjava_find_gij]
+  # libjava_find_gij will return `gij' if it couldn't find the
+  # program; in this case we want to skip the test.
+  if {$INTERPRETER == "yes" && $gij != "gij"} {
+      libjava_invoke $errname "gij test" opts $gij \
+	"" $resultfile $main
+  }  
 
   # When we succeed we remove all our clutter.
   eval gcj_cleanup [glob -nocomplain -- ${main}.*] [list $main lib${main}.${so_extension}]

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]