Skip to content

Commit

Permalink
Update flags for DebugSymbolsSmoke test
Browse files Browse the repository at this point in the history
New defaults coming in 23.1 (and possibly 23.0?)

Closes: Karm#154
  • Loading branch information
zakkak committed May 9, 2023
1 parent 2634ade commit ba73626
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.commons.io.FileUtils;
import org.graalvm.home.Version;
import org.graalvm.tests.integration.utils.Apps;
import org.graalvm.tests.integration.utils.ContainerNames;
import org.graalvm.tests.integration.utils.LogBuilder;
import org.graalvm.tests.integration.utils.Logs;
import org.graalvm.tests.integration.utils.versions.IfMandrelVersion;
Expand Down Expand Up @@ -54,6 +55,9 @@
import java.util.stream.Collectors;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.TrackNodeSourcePosition_23_0;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.DebugCodeInfoUseSourceMappings_23_1_a;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.OmitInlinedMethodDebugLineInfo_23_1_b;
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 @@ -840,9 +844,27 @@ public void nativeJVMTextProcessing(TestInfo testInfo) throws IOException, Inter
// Build
processLog = Path.of(appDir.getAbsolutePath(), "logs", "build-and-run.log").toFile();

Map<String, String> switches;
Version version = UsedVersion.getVersion(app.runtimeContainer != ContainerNames.NONE);
if (version.compareTo(Version.create(23, 1, 0)) >= 0) {
switches = Map.of(
TrackNodeSourcePosition_23_0.token, TrackNodeSourcePosition_23_0.replacement,
DebugCodeInfoUseSourceMappings_23_1_a.token, DebugCodeInfoUseSourceMappings_23_1_a.replacement,
OmitInlinedMethodDebugLineInfo_23_1_b.token, OmitInlinedMethodDebugLineInfo_23_1_b.replacement);
} else if (version.compareTo(Version.create(23, 0, 0)) >= 0) {
switches = Map.of(
TrackNodeSourcePosition_23_0.token, TrackNodeSourcePosition_23_0.replacement,
DebugCodeInfoUseSourceMappings_23_1_a.token, "",
OmitInlinedMethodDebugLineInfo_23_1_b.token, "");
} else {
switches = Map.of(
TrackNodeSourcePosition_23_0.token, "",
DebugCodeInfoUseSourceMappings_23_1_a.token, "",
OmitInlinedMethodDebugLineInfo_23_1_b.token, "");
}
// In this case, the two last commands are used for running the app; one in JVM mode and the other in Native mode.
// We should somehow capture this semantically in an Enum or something. This is fragile...
builderRoutine(app.buildAndRunCmds.cmds.length - 2, app, report, cn, mn, appDir, processLog);
builderRoutine(app.buildAndRunCmds.cmds.length - 2, app, report, cn, mn, appDir, processLog, null, switches);

final File inputData = new File(BASE_DIR + File.separator + app.dir + File.separator + "target" + File.separator + "test_data.txt");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
*/
package org.graalvm.tests.integration;

import org.graalvm.home.Version;
import org.graalvm.tests.integration.utils.Apps;
import org.graalvm.tests.integration.utils.ContainerNames;
import org.graalvm.tests.integration.utils.GDBSession;
import org.graalvm.tests.integration.utils.Logs;
import org.graalvm.tests.integration.utils.WebpageTester;
import org.graalvm.tests.integration.utils.versions.QuarkusVersion;
import org.graalvm.tests.integration.utils.versions.UsedVersion;
import org.jboss.logging.Logger;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
Expand All @@ -49,6 +51,9 @@
import java.util.regex.Pattern;
import java.util.stream.Stream;

import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.TrackNodeSourcePosition_23_0;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.DebugCodeInfoUseSourceMappings_23_1_a;
import static org.graalvm.tests.integration.DebugSymbolsTest.DebugOptions.OmitInlinedMethodDebugLineInfo_23_1_b;
import static org.graalvm.tests.integration.utils.Commands.CONTAINER_RUNTIME;
import static org.graalvm.tests.integration.utils.Commands.QUARKUS_VERSION;
import static org.graalvm.tests.integration.utils.Commands.builderRoutine;
Expand Down Expand Up @@ -80,6 +85,20 @@ public class DebugSymbolsTest {

public static final String BASE_DIR = getBaseDir();

public enum DebugOptions {
TrackNodeSourcePosition_23_0("<DEBUG_FLAGS_23_0>", "-H:+TrackNodeSourcePosition"),
DebugCodeInfoUseSourceMappings_23_1_a("<DEBUG_FLAGS_23_1_a>", "-H:+DebugCodeInfoUseSourceMappings"),
OmitInlinedMethodDebugLineInfo_23_1_b("<DEBUG_FLAGS_23_1_b>", "-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})
Expand All @@ -99,9 +118,27 @@ public void debugSymbolsSmokeGDB(TestInfo testInfo) throws IOException, Interrup
// Build
processLog = Path.of(appDir.getAbsolutePath(), "logs", "build-and-run.log").toFile();

Map<String, String> switches;
Version version = UsedVersion.getVersion(app.runtimeContainer != ContainerNames.NONE);
if (version.compareTo(Version.create(23, 1, 0)) >= 0) {
switches = Map.of(
TrackNodeSourcePosition_23_0.token, TrackNodeSourcePosition_23_0.replacement,
DebugCodeInfoUseSourceMappings_23_1_a.token, DebugCodeInfoUseSourceMappings_23_1_a.replacement,
OmitInlinedMethodDebugLineInfo_23_1_b.token, OmitInlinedMethodDebugLineInfo_23_1_b.replacement);
} else if (version.compareTo(Version.create(23, 0, 0)) >= 0) {
switches = Map.of(
TrackNodeSourcePosition_23_0.token, TrackNodeSourcePosition_23_0.replacement,
DebugCodeInfoUseSourceMappings_23_1_a.token, "",
OmitInlinedMethodDebugLineInfo_23_1_b.token, "");
} else {
switches = Map.of(
TrackNodeSourcePosition_23_0.token, "",
DebugCodeInfoUseSourceMappings_23_1_a.token, "",
OmitInlinedMethodDebugLineInfo_23_1_b.token, "");
}
// In this case, the two last commands are used for running the app; one in JVM mode and the other in Native mode.
// We should somehow capture this semantically in an Enum or something. This is fragile...
builderRoutine(app.buildAndRunCmds.cmds.length - 2, app, report, cn, mn, appDir, processLog);
builderRoutine(app.buildAndRunCmds.cmds.length - 2, app, report, cn, mn, appDir, processLog, null, switches);

final ProcessBuilder processBuilder = new ProcessBuilder(getRunCommand("gdb", "./target/debug-symbols-smoke"));
final Map<String, String> envA = processBuilder.environment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
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 Down Expand Up @@ -203,9 +205,12 @@ public enum BuildAndRunCmds {
new String[]{"powershell", "-c", "\"Expand-Archive -Path test_data.txt.zip -DestinationPath target -Force\""}
:
new String[]{"unzip", "test_data.txt.zip", "-d", "target"},
new String[]{"native-image", "-H:GenerateDebugInfo=1", "-H:+PreserveFramePointer", "-H:-DeleteLocalSymbols",
"-H:+TrackNodeSourcePosition", // Explicitly added as it is no longer enabled by default starting with GraalVM 23.0
"-jar", "target/debug-symbols-smoke.jar", "target/debug-symbols-smoke"},

new String[]{"native-image", "-H:GenerateDebugInfo=1", "-H:+PreserveFramePointer", "-H:-DeleteLocalSymbols",
DebugSymbolsTest.DebugOptions.TrackNodeSourcePosition_23_0.token,
DebugSymbolsTest.DebugOptions.DebugCodeInfoUseSourceMappings_23_1_a.token,
DebugSymbolsTest.DebugOptions.OmitInlinedMethodDebugLineInfo_23_1_b.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 ba73626

Please sign in to comment.