aboutsummaryrefslogtreecommitdiff
path: root/libjava/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/testsuite')
-rw-r--r--libjava/testsuite/Makefile.in4
-rw-r--r--libjava/testsuite/lib/libjava.exp4
-rw-r--r--libjava/testsuite/libjava.jni/jni.exp114
-rw-r--r--libjava/testsuite/libjava.lang/PR20056.java13
-rw-r--r--libjava/testsuite/libjava.lang/PR20056.out1
-rw-r--r--libjava/testsuite/libjava.lang/bytearray.java10
-rw-r--r--libjava/testsuite/libjava.lang/bytearray.out2
7 files changed, 140 insertions, 8 deletions
diff --git a/libjava/testsuite/Makefile.in b/libjava/testsuite/Makefile.in
index 4ba07e5c49b..36fca714370 100644
--- a/libjava/testsuite/Makefile.in
+++ b/libjava/testsuite/Makefile.in
@@ -80,7 +80,6 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CHECKREFSPEC = @CHECKREFSPEC@
CLASSPATH_SEPARATOR = @CLASSPATH_SEPARATOR@
-COMPPATH = @COMPPATH@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
@@ -125,6 +124,9 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTERPRETER = @INTERPRETER@
+JAVA_HOME = @JAVA_HOME@
+JAVA_HOME_SET_FALSE = @JAVA_HOME_SET_FALSE@
+JAVA_HOME_SET_TRUE = @JAVA_HOME_SET_TRUE@
JC1GCSPEC = @JC1GCSPEC@
LDFLAGS = @LDFLAGS@
LIBART_CFLAGS = @LIBART_CFLAGS@
diff --git a/libjava/testsuite/lib/libjava.exp b/libjava/testsuite/lib/libjava.exp
index 443259d712c..b3a16f67169 100644
--- a/libjava/testsuite/lib/libjava.exp
+++ b/libjava/testsuite/lib/libjava.exp
@@ -197,8 +197,8 @@ proc libjava_init { args } {
# Finally, add the gcc build directory so that we can find the
# shared libgcc. This, like much of dejagnu, is hideous.
set libjava_libgcc_s_path {}
-
- if { [string match "powerpc-*-darwin*" $target_triplet] } {
+
+ if { [istarget "*-*-darwin*"] } {
set so_extension "dylib"
} else {
set so_extension "so"
diff --git a/libjava/testsuite/libjava.jni/jni.exp b/libjava/testsuite/libjava.jni/jni.exp
index cbd90ca28cb..201daaca713 100644
--- a/libjava/testsuite/libjava.jni/jni.exp
+++ b/libjava/testsuite/libjava.jni/jni.exp
@@ -14,7 +14,7 @@ proc gcj_jni_compile_c_to_so {file {options {}}} {
# so we check against powerpc-apple-darwin and set them to
# dylib, else we assume it's .so
- if { [ regexp {powerpc-apple-darwin} $host_triplet] } {
+ if { [istarget "*-*-darwin*"] } {
set so_extension "dylib"
set so_flag "-dynamiclib"
} else {
@@ -77,10 +77,10 @@ proc gcj_jni_test_one {file} {
global INTERPRETER
# apple uses a different extension for shared/dynamic libraries
-# so we check against powerpc-apple-darwin and set them to
+# so we check against powerpc-apple-darwin and set them to
# dylib, else we assume it's .so
- if { [ regexp {powerpc-apple-darwin} $host_triplet] } {
+ if { [istarget "*-*-darwin*"] } {
set so_extension "dylib"
} else {
set so_extension "so"
@@ -134,12 +134,12 @@ proc gcj_jni_test_one {file} {
# Darwin does not yet have a libgcc_s.dylib library.
# So we add it here. If the libgcc_s is installed, the libstdc++
# would pick it up.
- if { [ regexp {powerpc-apple-darwin} $host_triplet] } {
+ if { [istarget "*-*-darwin*"] } {
lappend cxxflaglist "-lgcc_s -lstdc++"
} else {
lappend cxxflaglist "-lstdc++"
}
-
+
set cxxflags [join $cxxflaglist]
}
@@ -181,6 +181,103 @@ proc gcj_jni_test_one {file} {
return 1
}
+# Compile a single C file and produce a binary. OPTIONS is a list of
+# options to pass to the compiler. Returns 0 on failure, 1 on
+# success.
+proc gcj_jni_invocation_compile_c_to_binary {file {options {}}} {
+ global srcdir
+ global host_triplet
+ verbose "options: $options"
+ set options_cxx $options
+ set options ""
+
+ set filename [file tail $file]
+ set name [file rootname $filename]
+
+ # Set some darwin specific options
+ if { [istarget "*-*-darwin*"] } {
+ lappend options "additional_flags=-multiply_defined suppress"
+ }
+ # Find the generated header.
+ lappend options "additional_flags=-I. -I.."
+
+ # 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 $name executable $options]]
+ if {$x != ""} {
+ verbose "target_compile failed: $x" 2
+ fail "$filename compilation"
+ return 0
+ }
+
+ pass "$filename compilation"
+ return 1
+}
+
+# Do all the work for a single invocation API test. Return 0 on
+# failure.
+proc gcj_jni_invocation_test_one {file} {
+ global runtests
+ global host_triplet
+ global INTERPRETER
+
+ # The base name. We use it for several purposes.
+ set main [file rootname [file tail $file]]
+ if {! [runtest_file_p $runtests $main]} {
+ # Simply skip it.
+ return 1
+ }
+
+ if {! [bytecompile_file $file [pwd]]} {
+ fail "bytecompile $file"
+ # FIXME - should use `untested' on all remaining tests.
+ # But that is hard.
+ return 0
+ }
+ pass "bytecompile $file"
+
+ set cfile [file rootname $file].c
+ # Darwin needs -liconv linked, otherwise we get some unresolved.
+ # Also, like in the cxxtest we need to add -lgcc_s since Darwin
+ # has no libgcc_s.dylib installed yet.
+ if { [istarget "*-*-darwin*"] } {
+ set cxxflags "-L../.libs -lgcc_s -lgcj -liconv"
+ } else {
+ set cxxflags "-L../.libs -lgcj"
+ }
+
+ if { [istarget "*-*-solaris*"] } {
+ lappend cxxflags "-lsocket"
+ }
+
+ if {! [gcj_jni_invocation_compile_c_to_binary $cfile $cxxflags]} {
+ # FIXME
+ return 0
+ }
+
+ set resultfile [file rootname $file].out
+
+ if {! [gcj_invoke $main $resultfile ""]} {
+ # FIXME
+ return 0
+ }
+
+ # We purposely ignore errors here; we still want to run the other
+ # appropriate tests.
+ set errname [file rootname [file tail $file]]
+
+ # When we succeed we remove all our clutter.
+ eval gcj_cleanup [glob -nocomplain -- ${main}.*] \
+ [list $main]
+
+ return 1
+}
+
# Run the JNI tests.
proc gcj_jni_run {} {
global srcdir subdir
@@ -193,6 +290,13 @@ proc gcj_jni_run {} {
foreach x $srcfiles {
gcj_jni_test_one $x
}
+
+ # Run JNI invocation API tests
+ catch { lsort [glob -nocomplain ${srcdir}/${subdir}/invocation/*.java] } srcfiles
+
+ foreach x $srcfiles {
+ gcj_jni_invocation_test_one $x
+ }
} else {
verbose "JNI tests not run in cross-compilation environment"
}
diff --git a/libjava/testsuite/libjava.lang/PR20056.java b/libjava/testsuite/libjava.lang/PR20056.java
new file mode 100644
index 00000000000..f73eb7f048b
--- /dev/null
+++ b/libjava/testsuite/libjava.lang/PR20056.java
@@ -0,0 +1,13 @@
+public class PR20056 {
+ int x;
+ PR20056(int x) {}
+ PR20056(PR20056 f) {
+ // The verifier rejected the generated code in this case.
+ this(f.x = 0);
+ }
+
+ public static void main(String[] args)
+ {
+ System.out.println("maude");
+ }
+}
diff --git a/libjava/testsuite/libjava.lang/PR20056.out b/libjava/testsuite/libjava.lang/PR20056.out
new file mode 100644
index 00000000000..b3668c4d4d6
--- /dev/null
+++ b/libjava/testsuite/libjava.lang/PR20056.out
@@ -0,0 +1 @@
+maude
diff --git a/libjava/testsuite/libjava.lang/bytearray.java b/libjava/testsuite/libjava.lang/bytearray.java
new file mode 100644
index 00000000000..88fdc9af014
--- /dev/null
+++ b/libjava/testsuite/libjava.lang/bytearray.java
@@ -0,0 +1,10 @@
+public class bytearray
+{
+ public static void main (String[] argv) throws Throwable {
+ Class c = Class.forName ("[Ljava.lang.String;");
+ c = Class.forName ("[B");
+ System.out.println (c);
+ c = ClassLoader.getSystemClassLoader().loadClass ("[[Ljava.lang.String;");
+ System.out.println (c);
+ }
+}
diff --git a/libjava/testsuite/libjava.lang/bytearray.out b/libjava/testsuite/libjava.lang/bytearray.out
new file mode 100644
index 00000000000..520d568e9b0
--- /dev/null
+++ b/libjava/testsuite/libjava.lang/bytearray.out
@@ -0,0 +1,2 @@
+class [B
+class [[Ljava.lang.String;