Skip to content

Commit

Permalink
Enable Jtreg test suites for FFI on Power & zLinux in JDK21
Browse files Browse the repository at this point in the history
The changes add Power & zLinux support to these
Jtreg test suites in JDK21 plus a few compilation
fixes in the test cases to ensure they are executed
correctly on all supported platforms.

Note:
The PR is part of the FFI work at
eclipse-openj9/openj9#16951

Signed-off-by: Cheng Jin <jincheng@ca.ibm.com>
  • Loading branch information
ChengJin01 committed Jun 14, 2023
1 parent c4dad2b commit 3518cf5
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 5 deletions.
7 changes: 7 additions & 0 deletions test/jdk/java/foreign/TestAddressDereference.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @enablePreview
* @library ../ /test/lib
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @run testng/othervm --enable-native-access=ALL-UNNAMED TestAddressDereference
*/

Expand Down
7 changes: 4 additions & 3 deletions test/jdk/java/foreign/TestClassLoaderFindNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2022, 2022 All Rights Reserved
* (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved
* ===========================================================================
*/

Expand All @@ -40,6 +40,7 @@
import org.testng.annotations.Test;

import static java.lang.foreign.ValueLayout.JAVA_BYTE;
import static java.lang.foreign.ValueLayout.JAVA_INT;
import static org.testng.Assert.*;

// FYI this test is run on 64-bit platforms only for now,
Expand All @@ -64,13 +65,13 @@ public void testInvalidSymbolLookup() {

@Test
public void testVariableSymbolLookup() {
MemorySegment segment = SymbolLookup.loaderLookup().find("c").get().reinterpret(1);
MemorySegment segment = SymbolLookup.loaderLookup().find("c").get().reinterpret(JAVA_INT.byteSize());
/* JAVA_INT applies to both Little-Endian and Big-Endian
* platforms given the one-byte int value is stored at the
* highest address(offset 3) of the int type in native on
* the Big-Endian platforms.
* See libLookupTest.c
*/
assertEquals(segment.get(ValueLayout.JAVA_INT, 0), 42);
assertEquals(segment.get(JAVA_INT, 0), 42);
}
}
7 changes: 7 additions & 0 deletions test/jdk/java/foreign/TestIntrinsics.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @enablePreview
* @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="aarch64" | os.arch=="riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @run testng/othervm
* -Djdk.internal.foreign.DowncallLinker.USE_SPEC=true
* --enable-native-access=ALL-UNNAMED
Expand Down
7 changes: 7 additions & 0 deletions test/jdk/java/foreign/TestLinker.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @enablePreview
* @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="aarch64" | os.arch=="riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @run testng TestLinker
*/

Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/foreign/TestVarArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2022, 2022 All Rights Reserved
* (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved
* ===========================================================================
*/

Expand Down Expand Up @@ -192,7 +192,7 @@ private static void check(int index, MemorySegment ptr, List<Arg> args) {
* address in java on the Big-Endian(BE) platforms such as AIX.
*/
if (isAixOS && (layout instanceof ValueLayout) && (((ValueLayout)layout).carrier() == float.class)) {
MemorySegment doubleSegmt = MemorySegment.ofAddress(ptr, JAVA_DOUBLE.byteSize(), session);
MemorySegment doubleSegmt = MemorySegment.ofAddress(ptr.address()).reinterpret(JAVA_DOUBLE.byteSize());
seg.set(JAVA_FLOAT, 0, (float)doubleSegmt.get(JAVA_DOUBLE, 0));
}
Object obj = getter.invoke(seg);
Expand Down
8 changes: 8 additions & 0 deletions test/jdk/java/foreign/arraystructs/TestArrayStructs.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test id=specialized
* @enablePreview
* @library ../
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @modules java.base/jdk.internal.foreign
* @run testng/othervm
* --enable-native-access=ALL-UNNAMED
Expand All @@ -39,6 +46,7 @@
* @enablePreview
* @library ../
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @modules java.base/jdk.internal.foreign
* @run testng/othervm
* --enable-native-access=ALL-UNNAMED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @enablePreview
* @library ../ /test/lib
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @run testng/othervm --enable-native-access=ALL-UNNAMED TestCaptureCallState
*/

Expand Down
7 changes: 7 additions & 0 deletions test/jdk/java/foreign/dontrelease/TestDontRelease.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @enablePreview
* @library ../ /test/lib
* @modules java.base/jdk.internal.ref java.base/jdk.internal.foreign
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @run testng/othervm --enable-native-access=ALL-UNNAMED TestDontRelease
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @enablePreview
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @requires !vm.musl
*
* @library /test/lib
Expand Down
7 changes: 7 additions & 0 deletions test/jdk/java/foreign/largestub/TestLargeStub.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @enablePreview
* @library ../
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @modules java.base/jdk.internal.foreign
* @run testng/othervm --enable-native-access=ALL-UNNAMED TestLargeStub
*/
Expand Down
7 changes: 7 additions & 0 deletions test/jdk/java/foreign/nested/TestNested.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @enablePreview
* @library ../ /test/lib
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @requires vm.flavor != "zero"
* @build NativeTestHelper
* @run testng/othervm --enable-native-access=ALL-UNNAMED TestNested
Expand Down
7 changes: 7 additions & 0 deletions test/jdk/java/foreign/normalize/TestNormalize.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @enablePreview
* @library ../
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @run testng/othervm
* --enable-native-access=ALL-UNNAMED
* -Xbatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @enablePreview
* @library ../ /test/lib
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @run testng/othervm --enable-native-access=ALL-UNNAMED TestPassHeapSegment
*/

Expand Down
7 changes: 7 additions & 0 deletions test/jdk/java/foreign/trivial/TestTrivial.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @enablePreview
* @library ../ /test/lib
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @run testng/othervm --enable-native-access=ALL-UNNAMED TestTrivial
*/

Expand Down
7 changes: 7 additions & 0 deletions test/jdk/java/foreign/trivial/TestTrivialUpcall.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @enablePreview
* @library ../ /test/lib
* @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64" | os.arch == "riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @requires vm.flavor != "zero"
* @run testng/othervm --enable-native-access=ALL-UNNAMED TestTrivialUpcall
*/
Expand Down
7 changes: 7 additions & 0 deletions test/jdk/java/foreign/virtual/TestVirtualCalls.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
* ===========================================================================
*/

/*
* @test
* @enablePreview
* @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="aarch64" | os.arch=="riscv64"
* | os.arch == "ppc64" | os.arch == "ppc64le" | os.arch == "s390x"
* @library ../
* @run testng/othervm
* --enable-native-access=ALL-UNNAMED
Expand Down

0 comments on commit 3518cf5

Please sign in to comment.