From 32153b58a9669c8dd51ee7b3170858c884e69bb3 Mon Sep 17 00:00:00 2001 From: Michal Karm Babacek Date: Thu, 15 Aug 2024 15:14:25 +0200 Subject: [PATCH 1/3] Test for static libs: add libsvm_container --- .../tests/integration/AppReproducersTest.java | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/testsuite/src/it/java/org/graalvm/tests/integration/AppReproducersTest.java b/testsuite/src/it/java/org/graalvm/tests/integration/AppReproducersTest.java index e728e07..07d7991 100644 --- a/testsuite/src/it/java/org/graalvm/tests/integration/AppReproducersTest.java +++ b/testsuite/src/it/java/org/graalvm/tests/integration/AppReproducersTest.java @@ -610,31 +610,40 @@ public void imageioAWT(TestInfo testInfo, Apps app) throws IOException, Interrup // Test static libs in the executable final File executable = new File(appDir.getAbsolutePath() + File.separator + "target", "imageio"); - Set expected = Set.of("libawt.a", "libawt_headless.a", "libfdlibm.a", "libfontmanager.a", "libjava.a", "libjavajpeg.a", "libjvm.a", "liblcms.a", "liblibchelper.a", "libnet.a", "libnio.a", "libzip.a"); + final Set expected = new HashSet<>(); + expected.add("libawt.a"); + expected.add("libawt_headless.a"); + expected.add("libfdlibm.a"); + expected.add("libfontmanager.a"); + expected.add("libjava.a"); + expected.add("libjavajpeg.a"); + expected.add("libjvm.a"); + expected.add("liblcms.a"); + expected.add("liblibchelper.a"); + expected.add("libnet.a"); + expected.add("libnio.a"); + expected.add("libzip.a"); + if (UsedVersion.getVersion(inContainer).compareTo(Version.parse("24.2")) >= 0) { + expected.add("libsvm_container.a"); + } if (UsedVersion.getVersion(inContainer).compareTo(Version.parse("23.0")) >= 0) { // The set of static libs for imageio is smaller beginning with Mandrel 23+ as // it has dynamic AWT support. - Set modifiable = new HashSet<>(expected); - modifiable.remove("libawt_headless.a"); - modifiable.remove("libfontmanager.a"); - modifiable.remove("libjavajpeg.a"); - modifiable.remove("liblcms.a"); - modifiable.remove("libawt.a"); - expected = Collections.unmodifiableSet(modifiable); + expected.remove("libawt_headless.a"); + expected.remove("libfontmanager.a"); + expected.remove("libjavajpeg.a"); + expected.remove("liblcms.a"); + expected.remove("libawt.a"); } if (UsedVersion.jdkFeature(inContainer) >= 21) { // JDK 21 has fdlibm ported to Java. See JDK-8171407 - Set modifiable = new HashSet<>(expected); - modifiable.remove("libfdlibm.a"); - expected = Collections.unmodifiableSet(modifiable); + expected.remove("libfdlibm.a"); } if (UsedVersion.jdkFeature(inContainer) > 11 || (UsedVersion.jdkFeature(inContainer) == 11 && UsedVersion.jdkUpdate(inContainer) > 12)) { // Harfbuzz removed: https://github.com/graalvm/mandrel/issues/286 // NO-OP } else { - Set modifiable = new HashSet<>(expected); - modifiable.add("libharfbuzz.a"); - expected = Collections.unmodifiableSet(modifiable); + expected.add("libharfbuzz.a"); } final Set actual = listStaticLibs(executable); From fae11fa669b70f9635c21efd8bdccd993e9c2431 Mon Sep 17 00:00:00 2001 From: Michal Karm Babacek Date: Fri, 16 Aug 2024 00:46:32 +0200 Subject: [PATCH 2/3] Adds -H:+ForeignAPISupport --- .../tests/integration/AppReproducersTest.java | 19 +++++++++----- .../tests/integration/DebugSymbolsTest.java | 26 ++++--------------- .../integration/utils/AuxiliaryOptions.java | 18 +++++++++++++ .../integration/utils/BuildAndRunCmds.java | 23 +++++++++------- 4 files changed, 50 insertions(+), 36 deletions(-) create mode 100644 testsuite/src/it/java/org/graalvm/tests/integration/utils/AuxiliaryOptions.java diff --git a/testsuite/src/it/java/org/graalvm/tests/integration/AppReproducersTest.java b/testsuite/src/it/java/org/graalvm/tests/integration/AppReproducersTest.java index 07d7991..7ccc5ae 100644 --- a/testsuite/src/it/java/org/graalvm/tests/integration/AppReproducersTest.java +++ b/testsuite/src/it/java/org/graalvm/tests/integration/AppReproducersTest.java @@ -56,11 +56,12 @@ import java.util.stream.Stream; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.DebugCodeInfoUseSourceMappings_23_0; -import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.LockExperimentalVMOptions_23_1; -import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.OmitInlinedMethodDebugLineInfo_23_0; -import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.TrackNodeSourcePosition_23_0; -import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.UnlockExperimentalVMOptions_23_1; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.DebugCodeInfoUseSourceMappings_23_0; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.ForeignAPISupport_24_2; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.LockExperimentalVMOptions_23_1; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.OmitInlinedMethodDebugLineInfo_23_0; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.TrackNodeSourcePosition_23_0; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.UnlockExperimentalVMOptions_23_1; import static org.graalvm.tests.integration.utils.Commands.builderRoutine; import static org.graalvm.tests.integration.utils.Commands.cleanTarget; import static org.graalvm.tests.integration.utils.Commands.cleanup; @@ -524,7 +525,8 @@ public void imageioAWT(TestInfo testInfo, Apps app) throws IOException, Interrup // Build processLog = Path.of(appDir.getAbsolutePath(), "logs", "build-and-run.log").toFile(); - builderRoutine(app, report, cn, mn, appDir, processLog); + builderRoutine(0, app.buildAndRunCmds.cmds.length - 1, + app, report, cn, mn, appDir, processLog, null, getSwitches(app)); // Record images' hashsums as created by a Java process final List errors = new ArrayList<>(12); @@ -1056,6 +1058,11 @@ private static Map getSwitches(Apps app) { switches.put(DebugCodeInfoUseSourceMappings_23_0.token, ""); switches.put(OmitInlinedMethodDebugLineInfo_23_0.token, ""); } + if (version.compareTo(Version.create(24, 2, 0)) >= 0) { + switches.put(ForeignAPISupport_24_2.token, ForeignAPISupport_24_2.replacement); + } else { + switches.put(ForeignAPISupport_24_2.token, ""); + } return switches; } } diff --git a/testsuite/src/it/java/org/graalvm/tests/integration/DebugSymbolsTest.java b/testsuite/src/it/java/org/graalvm/tests/integration/DebugSymbolsTest.java index 90d6ff1..77b07a1 100644 --- a/testsuite/src/it/java/org/graalvm/tests/integration/DebugSymbolsTest.java +++ b/testsuite/src/it/java/org/graalvm/tests/integration/DebugSymbolsTest.java @@ -56,11 +56,11 @@ import java.util.regex.Pattern; import java.util.stream.Stream; -import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.DebugCodeInfoUseSourceMappings_23_0; -import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.LockExperimentalVMOptions_23_1; -import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.OmitInlinedMethodDebugLineInfo_23_0; -import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.TrackNodeSourcePosition_23_0; -import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.UnlockExperimentalVMOptions_23_1; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.DebugCodeInfoUseSourceMappings_23_0; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.LockExperimentalVMOptions_23_1; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.OmitInlinedMethodDebugLineInfo_23_0; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.TrackNodeSourcePosition_23_0; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.UnlockExperimentalVMOptions_23_1; import static org.graalvm.tests.integration.utils.Commands.CMD_DEFAULT_TIMEOUT_MS; import static org.graalvm.tests.integration.utils.Commands.CMD_LONG_TIMEOUT_MS; import static org.graalvm.tests.integration.utils.Commands.CONTAINER_RUNTIME; @@ -99,22 +99,6 @@ public class DebugSymbolsTest { // GOTO i.e. accessing a URL of a debugged test app to trigger a certain code path private static final long GOTO_URL_SLEEP_MS = 50; - public enum DebugOptions { - UnlockExperimentalVMOptions_23_1("", "-H:+UnlockExperimentalVMOptions"), - LockExperimentalVMOptions_23_1("", "-H:-UnlockExperimentalVMOptions"), - TrackNodeSourcePosition_23_0("", "-H:+TrackNodeSourcePosition"), - DebugCodeInfoUseSourceMappings_23_0("", "-H:+DebugCodeInfoUseSourceMappings"), - OmitInlinedMethodDebugLineInfo_23_0("", "-H:+OmitInlinedMethodDebugLineInfo"); - - public final String token; - final String replacement; - - DebugOptions(String token, String replacement) { - this.token = token; - this.replacement = replacement; - } - } - @Test @Tag("debugSymbolsSmoke") @DisabledOnOs({OS.WINDOWS, OS.MAC}) // This targets GCC/GDB toolchain specifically. diff --git a/testsuite/src/it/java/org/graalvm/tests/integration/utils/AuxiliaryOptions.java b/testsuite/src/it/java/org/graalvm/tests/integration/utils/AuxiliaryOptions.java new file mode 100644 index 0000000..a935510 --- /dev/null +++ b/testsuite/src/it/java/org/graalvm/tests/integration/utils/AuxiliaryOptions.java @@ -0,0 +1,18 @@ +package org.graalvm.tests.integration.utils; + +public enum AuxiliaryOptions { + UnlockExperimentalVMOptions_23_1("", "-H:+UnlockExperimentalVMOptions"), + LockExperimentalVMOptions_23_1("", "-H:-UnlockExperimentalVMOptions"), + TrackNodeSourcePosition_23_0("", "-H:+TrackNodeSourcePosition"), + DebugCodeInfoUseSourceMappings_23_0("", "-H:+DebugCodeInfoUseSourceMappings"), + OmitInlinedMethodDebugLineInfo_23_0("", "-H:+OmitInlinedMethodDebugLineInfo"), + ForeignAPISupport_24_2("", "-H:+ForeignAPISupport"); + + public final String token; + public final String replacement; + + AuxiliaryOptions(String token, String replacement) { + this.token = token; + this.replacement = replacement; + } +} diff --git a/testsuite/src/it/java/org/graalvm/tests/integration/utils/BuildAndRunCmds.java b/testsuite/src/it/java/org/graalvm/tests/integration/utils/BuildAndRunCmds.java index 913e84b..838b721 100755 --- a/testsuite/src/it/java/org/graalvm/tests/integration/utils/BuildAndRunCmds.java +++ b/testsuite/src/it/java/org/graalvm/tests/integration/utils/BuildAndRunCmds.java @@ -19,8 +19,6 @@ */ package org.graalvm.tests.integration.utils; -import org.graalvm.tests.integration.DebugSymbolsTest; - import java.io.File; import static org.graalvm.tests.integration.AppReproducersTest.BASE_DIR; @@ -29,6 +27,12 @@ import static org.graalvm.tests.integration.PerfCheckTest.FINAL_NAME_TOKEN; import static org.graalvm.tests.integration.PerfCheckTest.MX_HEAP_MB; import static org.graalvm.tests.integration.PerfCheckTest.NATIVE_IMAGE_XMX_GB; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.DebugCodeInfoUseSourceMappings_23_0; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.ForeignAPISupport_24_2; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.LockExperimentalVMOptions_23_1; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.OmitInlinedMethodDebugLineInfo_23_0; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.TrackNodeSourcePosition_23_0; +import static org.graalvm.tests.integration.utils.AuxiliaryOptions.UnlockExperimentalVMOptions_23_1; import static org.graalvm.tests.integration.utils.Commands.BUILDER_IMAGE; import static org.graalvm.tests.integration.utils.Commands.CONTAINER_RUNTIME; import static org.graalvm.tests.integration.utils.Commands.GRAALVM_BUILD_OUTPUT_JSON_FILE; @@ -209,7 +213,8 @@ public enum BuildAndRunCmds { new String[]{"mvn", "clean", "package"}, new String[]{"java", "-Djava.awt.headless=true", "-agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image", "-jar", "target/imageio.jar"}, new String[]{"jar", "uf", "target/imageio.jar", "-C", "src/main/resources/", "META-INF"}, - new String[]{"native-image", "-J-Djava.awt.headless=true", "--no-fallback", "-jar", "target/imageio.jar", "target/imageio"}, + new String[]{"native-image", UnlockExperimentalVMOptions_23_1.token, ForeignAPISupport_24_2.token, LockExperimentalVMOptions_23_1.token, + "-J-Djava.awt.headless=true", "--no-fallback", "-jar", "target/imageio.jar", "target/imageio"}, new String[]{IS_THIS_WINDOWS ? "target\\imageio.exe" : "./target/imageio", "-Djava.home=.", "-Djava.awt.headless=true"} }), IMAGEIO_BUILDER_IMAGE(new String[][]{ @@ -229,7 +234,7 @@ public enum BuildAndRunCmds { // Native image build itself (jar was updated with properties in the previous step) new String[]{CONTAINER_RUNTIME, "run", IS_THIS_WINDOWS ? "" : "-u", IS_THIS_WINDOWS ? "" : getUnixUIDGID(), "-t", "-v", BASE_DIR + File.separator + "apps" + File.separator + "imageio:/project:z", - BUILDER_IMAGE, + BUILDER_IMAGE, UnlockExperimentalVMOptions_23_1.token, ForeignAPISupport_24_2.token, LockExperimentalVMOptions_23_1.token, "-J-Djava.awt.headless=true", "--no-fallback", "-jar", "target/imageio.jar", "target/imageio"}, // We build a runtime image, ubi 8 minimal based, runtime dependencies installed new String[]{CONTAINER_RUNTIME, "build", "--network=host", "-t", ContainerNames.IMAGEIO_BUILDER_IMAGE.name, "."}, @@ -246,12 +251,12 @@ public enum BuildAndRunCmds { : new String[]{"unzip", "test_data.txt.zip", "-d", "target"}, - new String[] { "native-image", DebugSymbolsTest.DebugOptions.UnlockExperimentalVMOptions_23_1.token, + new String[] { "native-image", UnlockExperimentalVMOptions_23_1.token, "-H:GenerateDebugInfo=" + (IS_THIS_MACOS ? "0" : "1"), "-H:+PreserveFramePointer", "-H:-DeleteLocalSymbols", - DebugSymbolsTest.DebugOptions.TrackNodeSourcePosition_23_0.token, - DebugSymbolsTest.DebugOptions.DebugCodeInfoUseSourceMappings_23_0.token, - DebugSymbolsTest.DebugOptions.OmitInlinedMethodDebugLineInfo_23_0.token, - DebugSymbolsTest.DebugOptions.LockExperimentalVMOptions_23_1.token, + TrackNodeSourcePosition_23_0.token, + DebugCodeInfoUseSourceMappings_23_0.token, + OmitInlinedMethodDebugLineInfo_23_0.token, + LockExperimentalVMOptions_23_1.token, "-jar", "target/debug-symbols-smoke.jar", "target/debug-symbols-smoke" }, new String[]{"java", "-jar", "./target/debug-symbols-smoke.jar"}, new String[]{IS_THIS_WINDOWS ? "target\\debug-symbols-smoke.exe" : "./target/debug-symbols-smoke"} From a21827766e0c959add6a202b0c6a3504d2b6ddfc Mon Sep 17 00:00:00 2001 From: Michal Karm Babacek Date: Sat, 17 Aug 2024 16:37:13 +0200 Subject: [PATCH 3/3] Watning, remove when mandrel/issues/760 backported --- .../graalvm/tests/integration/utils/WhitelistLogLines.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/testsuite/src/it/java/org/graalvm/tests/integration/utils/WhitelistLogLines.java b/testsuite/src/it/java/org/graalvm/tests/integration/utils/WhitelistLogLines.java index ca91d08..e9afd84 100755 --- a/testsuite/src/it/java/org/graalvm/tests/integration/utils/WhitelistLogLines.java +++ b/testsuite/src/it/java/org/graalvm/tests/integration/utils/WhitelistLogLines.java @@ -83,7 +83,9 @@ public Pattern[] get(boolean inContainer) { // org.jfree.jfreesvg reflectively accesses com.orsoncharts.Chart3DHints which is not on the classpath Pattern.compile("Warning: Could not resolve .*com.orsoncharts.Chart3DHints for reflection configuration. Reason: java.lang.ClassNotFoundException: com.orsoncharts.Chart3DHints."), // The java agent erroneously produces a reflection config mentioning this constructor, which doesn't exist - Pattern.compile("Warning: Method sun\\.security\\.provider\\.NativePRNG\\.\\(SecureRandomParameters\\) not found.") + Pattern.compile("Warning: Method sun\\.security\\.provider\\.NativePRNG\\.\\(SecureRandomParameters\\) not found."), + // https://github.com/graalvm/mandrel/issues/760 + Pattern.compile(".*Warning: Option 'DynamicProxyConfigurationResources' is deprecated.*"), }; } },