From 3518cf5a8adaef7d3199fe95bf071856b4535150 Mon Sep 17 00:00:00 2001 From: ChengJin01 Date: Wed, 14 Jun 2023 18:26:59 -0400 Subject: [PATCH] Enable Jtreg test suites for FFI on Power & zLinux in JDK21 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 --- test/jdk/java/foreign/TestAddressDereference.java | 7 +++++++ test/jdk/java/foreign/TestClassLoaderFindNative.java | 7 ++++--- test/jdk/java/foreign/TestIntrinsics.java | 7 +++++++ test/jdk/java/foreign/TestLinker.java | 7 +++++++ test/jdk/java/foreign/TestVarArgs.java | 4 ++-- test/jdk/java/foreign/arraystructs/TestArrayStructs.java | 8 ++++++++ .../foreign/capturecallstate/TestCaptureCallState.java | 1 + test/jdk/java/foreign/dontrelease/TestDontRelease.java | 7 +++++++ .../enablenativeaccess/TestEnableNativeAccessDynamic.java | 7 +++++++ test/jdk/java/foreign/largestub/TestLargeStub.java | 7 +++++++ test/jdk/java/foreign/nested/TestNested.java | 7 +++++++ test/jdk/java/foreign/normalize/TestNormalize.java | 7 +++++++ .../java/foreign/passheapsegment/TestPassHeapSegment.java | 7 +++++++ test/jdk/java/foreign/trivial/TestTrivial.java | 7 +++++++ test/jdk/java/foreign/trivial/TestTrivialUpcall.java | 7 +++++++ test/jdk/java/foreign/virtual/TestVirtualCalls.java | 7 +++++++ 16 files changed, 99 insertions(+), 5 deletions(-) diff --git a/test/jdk/java/foreign/TestAddressDereference.java b/test/jdk/java/foreign/TestAddressDereference.java index 22a5a9abc39..0bccb31184c 100644 --- a/test/jdk/java/foreign/TestAddressDereference.java +++ b/test/jdk/java/foreign/TestAddressDereference.java @@ -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 */ diff --git a/test/jdk/java/foreign/TestClassLoaderFindNative.java b/test/jdk/java/foreign/TestClassLoaderFindNative.java index 4c2b2c3fec4..5f13b438bb8 100644 --- a/test/jdk/java/foreign/TestClassLoaderFindNative.java +++ b/test/jdk/java/foreign/TestClassLoaderFindNative.java @@ -23,7 +23,7 @@ /* * =========================================================================== - * (c) Copyright IBM Corp. 2022, 2022 All Rights Reserved + * (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved * =========================================================================== */ @@ -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, @@ -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); } } diff --git a/test/jdk/java/foreign/TestIntrinsics.java b/test/jdk/java/foreign/TestIntrinsics.java index b7a239ed7db..2585fabad3d 100644 --- a/test/jdk/java/foreign/TestIntrinsics.java +++ b/test/jdk/java/foreign/TestIntrinsics.java @@ -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 diff --git a/test/jdk/java/foreign/TestLinker.java b/test/jdk/java/foreign/TestLinker.java index f8218fd81a6..0361dce5c2c 100644 --- a/test/jdk/java/foreign/TestLinker.java +++ b/test/jdk/java/foreign/TestLinker.java @@ -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 */ diff --git a/test/jdk/java/foreign/TestVarArgs.java b/test/jdk/java/foreign/TestVarArgs.java index 628b5322594..c46633a451c 100644 --- a/test/jdk/java/foreign/TestVarArgs.java +++ b/test/jdk/java/foreign/TestVarArgs.java @@ -24,7 +24,7 @@ /* * =========================================================================== - * (c) Copyright IBM Corp. 2022, 2022 All Rights Reserved + * (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved * =========================================================================== */ @@ -192,7 +192,7 @@ private static void check(int index, MemorySegment ptr, List 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); diff --git a/test/jdk/java/foreign/arraystructs/TestArrayStructs.java b/test/jdk/java/foreign/arraystructs/TestArrayStructs.java index 7a4761c87c7..96a359876f3 100644 --- a/test/jdk/java/foreign/arraystructs/TestArrayStructs.java +++ b/test/jdk/java/foreign/arraystructs/TestArrayStructs.java @@ -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 @@ -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 diff --git a/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java b/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java index 7d02b71d5b6..1ef55328018 100644 --- a/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java +++ b/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java @@ -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 */ diff --git a/test/jdk/java/foreign/dontrelease/TestDontRelease.java b/test/jdk/java/foreign/dontrelease/TestDontRelease.java index 4a258352b36..e67433d39a8 100644 --- a/test/jdk/java/foreign/dontrelease/TestDontRelease.java +++ b/test/jdk/java/foreign/dontrelease/TestDontRelease.java @@ -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 */ diff --git a/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessDynamic.java b/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessDynamic.java index aef590e966a..eceb37b516c 100644 --- a/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessDynamic.java +++ b/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessDynamic.java @@ -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 diff --git a/test/jdk/java/foreign/largestub/TestLargeStub.java b/test/jdk/java/foreign/largestub/TestLargeStub.java index 74e028ecd8b..3a86d5624b6 100644 --- a/test/jdk/java/foreign/largestub/TestLargeStub.java +++ b/test/jdk/java/foreign/largestub/TestLargeStub.java @@ -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 */ diff --git a/test/jdk/java/foreign/nested/TestNested.java b/test/jdk/java/foreign/nested/TestNested.java index 9868349f990..7d038276dcb 100644 --- a/test/jdk/java/foreign/nested/TestNested.java +++ b/test/jdk/java/foreign/nested/TestNested.java @@ -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 diff --git a/test/jdk/java/foreign/normalize/TestNormalize.java b/test/jdk/java/foreign/normalize/TestNormalize.java index aa8d829d35d..032269b2276 100644 --- a/test/jdk/java/foreign/normalize/TestNormalize.java +++ b/test/jdk/java/foreign/normalize/TestNormalize.java @@ -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 diff --git a/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java b/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java index 0ff28cbc12b..e9e8436806e 100644 --- a/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java +++ b/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java @@ -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 */ diff --git a/test/jdk/java/foreign/trivial/TestTrivial.java b/test/jdk/java/foreign/trivial/TestTrivial.java index 98a89b2b8e7..b382e07924c 100644 --- a/test/jdk/java/foreign/trivial/TestTrivial.java +++ b/test/jdk/java/foreign/trivial/TestTrivial.java @@ -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 */ diff --git a/test/jdk/java/foreign/trivial/TestTrivialUpcall.java b/test/jdk/java/foreign/trivial/TestTrivialUpcall.java index bfba6f260d5..73431722e58 100644 --- a/test/jdk/java/foreign/trivial/TestTrivialUpcall.java +++ b/test/jdk/java/foreign/trivial/TestTrivialUpcall.java @@ -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 */ diff --git a/test/jdk/java/foreign/virtual/TestVirtualCalls.java b/test/jdk/java/foreign/virtual/TestVirtualCalls.java index e660acd4021..dd90f6d3a30 100644 --- a/test/jdk/java/foreign/virtual/TestVirtualCalls.java +++ b/test/jdk/java/foreign/virtual/TestVirtualCalls.java @@ -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