Skip to content

Commit

Permalink
Adds -H:+ForeignAPISupport
Browse files Browse the repository at this point in the history
  • Loading branch information
Karm committed Aug 15, 2024
1 parent 32153b5 commit fae11fa
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> errors = new ArrayList<>(12);
Expand Down Expand Up @@ -1056,6 +1058,11 @@ private static Map<String, String> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("<DEBUG_FLAGS_23_1_a>", "-H:+UnlockExperimentalVMOptions"),
LockExperimentalVMOptions_23_1("<DEBUG_FLAGS_23_1_b>", "-H:-UnlockExperimentalVMOptions"),
TrackNodeSourcePosition_23_0("<DEBUG_FLAGS_23_0_a>", "-H:+TrackNodeSourcePosition"),
DebugCodeInfoUseSourceMappings_23_0("<DEBUG_FLAGS_23_0_b>", "-H:+DebugCodeInfoUseSourceMappings"),
OmitInlinedMethodDebugLineInfo_23_0("<DEBUG_FLAGS_23_0_c>", "-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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.graalvm.tests.integration.utils;

public enum AuxiliaryOptions {
UnlockExperimentalVMOptions_23_1("<DEBUG_FLAGS_23_1_a>", "-H:+UnlockExperimentalVMOptions"),
LockExperimentalVMOptions_23_1("<DEBUG_FLAGS_23_1_b>", "-H:-UnlockExperimentalVMOptions"),
TrackNodeSourcePosition_23_0("<DEBUG_FLAGS_23_0_a>", "-H:+TrackNodeSourcePosition"),
DebugCodeInfoUseSourceMappings_23_0("<DEBUG_FLAGS_23_0_b>", "-H:+DebugCodeInfoUseSourceMappings"),
OmitInlinedMethodDebugLineInfo_23_0("<DEBUG_FLAGS_23_0_c>", "-H:+OmitInlinedMethodDebugLineInfo"),
ForeignAPISupport_24_2("<FFAPI>", "-H:+ForeignAPISupport");

public final String token;
public final String replacement;

AuxiliaryOptions(String token, String replacement) {
this.token = token;
this.replacement = replacement;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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[][]{
Expand All @@ -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, "."},
Expand All @@ -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"}
Expand Down

0 comments on commit fae11fa

Please sign in to comment.