From 96fac70c2108828baa8fccda37695aaaa034aae3 Mon Sep 17 00:00:00 2001 From: jovsteva Date: Tue, 28 May 2024 08:40:48 +0200 Subject: [PATCH 1/2] Disable TestSocketEvents and TestSocketChannelEvents. --- .../com/oracle/svm/test/jfr/TestSocketChannelEvents.java | 8 ++++++++ .../src/com/oracle/svm/test/jfr/TestSocketEvents.java | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestSocketChannelEvents.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestSocketChannelEvents.java index 379d62c0ee8f..eea7f8171347 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestSocketChannelEvents.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestSocketChannelEvents.java @@ -27,6 +27,7 @@ package com.oracle.svm.test.jfr; import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeTrue; import java.io.IOException; import java.net.InetSocketAddress; @@ -35,8 +36,10 @@ import java.nio.channels.SocketChannel; import java.util.List; +import org.junit.BeforeClass; import org.junit.Test; +import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import jdk.jfr.Recording; import jdk.jfr.consumer.RecordedEvent; @@ -46,6 +49,11 @@ public class TestSocketChannelEvents extends JfrRecordingTest { public static int PORT = 9876; public static String HOST = "127.0.0.1"; + @BeforeClass + public static void checkJavaVersion() { + assumeTrue("skipping JFR socket channel test", JavaVersionUtil.JAVA_SPEC >= 22); + } + @Test public void test() throws Throwable { String[] events = new String[]{"jdk.SocketRead", "jdk.SocketWrite"}; diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestSocketEvents.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestSocketEvents.java index 06b0bc230267..d8ffbf60a9ef 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestSocketEvents.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestSocketEvents.java @@ -27,6 +27,7 @@ package com.oracle.svm.test.jfr; import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeTrue; import java.io.BufferedReader; import java.io.IOException; @@ -36,8 +37,10 @@ import java.net.Socket; import java.util.List; +import org.junit.BeforeClass; import org.junit.Test; +import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import jdk.jfr.Recording; import jdk.jfr.consumer.RecordedEvent; @@ -46,6 +49,11 @@ public class TestSocketEvents extends JfrRecordingTest { public static int PORT = 9876; public static String HOST = "127.0.0.1"; + @BeforeClass + public static void checkJavaVersion() { + assumeTrue("skipping JFR socket test", JavaVersionUtil.JAVA_SPEC >= 22); + } + @Test public void test() throws Throwable { String[] events = new String[]{"jdk.SocketRead", "jdk.SocketWrite"}; From deda8f5e9c94161cb27c8b2054ac9fabb598a68a Mon Sep 17 00:00:00 2001 From: jovsteva Date: Tue, 28 May 2024 17:12:56 +0200 Subject: [PATCH 2/2] Fix a problem with TestContainerEvent on JDK21. --- .../svm/core/jfr/Target_jdk_jfr_internal_JVM_JDK21.java | 7 +++++-- .../src/com/oracle/svm/test/jfr/TestContainerEvent.java | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_JDK21.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_JDK21.java index 66009899f0a4..585a31f45409 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_JDK21.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/Target_jdk_jfr_internal_JVM_JDK21.java @@ -26,6 +26,8 @@ import java.util.List; +import com.oracle.svm.core.heap.PhysicalMemory; +import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.ProcessProperties; import com.oracle.svm.core.Containers; @@ -361,7 +363,8 @@ public boolean isContainerized() { @Substitute public long hostTotalMemory() { - /* Not implemented at the moment. */ - return 0; + // This is intentionally using PhysicalMemorySupport since we are + // interested in the host values (and not the containerized values). + return ImageSingletons.lookup(PhysicalMemory.PhysicalMemorySupport.class).size().rawValue(); } } diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestContainerEvent.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestContainerEvent.java index cd2f1772a4a9..2e8dc49cb770 100644 --- a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestContainerEvent.java +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestContainerEvent.java @@ -30,6 +30,7 @@ import java.util.List; +import jdk.graal.compiler.serviceprovider.JavaVersionUtil; import org.junit.Assume; import org.junit.Test; @@ -66,7 +67,9 @@ private static void validateEvents(List events) { long hostTotalMem = re.getValue("hostTotalMemory"); assertTrue(hostTotalMem > 0); - long hostTotalSwap = re.getValue("hostTotalSwapMemory"); - assertTrue("Host swap not implemented", hostTotalSwap < 0); + if (JavaVersionUtil.JAVA_SPEC >= 23) { + long hostTotalSwap = re.getValue("hostTotalSwapMemory"); + assertTrue("Host swap not implemented", hostTotalSwap < 0); + } } }