Skip to content

Commit

Permalink
Workaround graalvm/mandrel#355
Browse files Browse the repository at this point in the history
Closes Karm#81
  • Loading branch information
zakkak committed Apr 8, 2022
1 parent bce2502 commit b75bfd2
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
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;
Expand Down Expand Up @@ -134,7 +133,7 @@ public void debugSymbolsSmokeGDB(TestInfo testInfo) throws IOException, Interrup
3000, 500, TimeUnit.MILLISECONDS),
"GDB session did not start well. Check the names, paths... Content was: " + stringBuffer.toString());

carryOutGDBSession(stringBuffer, GDBSession.DEBUG_SYMBOLS_SMOKE, esvc, writer, report, UsedVersion.getVersion(false));
carryOutGDBSession(stringBuffer, GDBSession.DEBUG_SYMBOLS_SMOKE, esvc, writer, report, false);

writer.write("q\n");
writer.flush();
Expand Down Expand Up @@ -215,7 +214,7 @@ public void debugSymbolsQuarkus(TestInfo testInfo) throws IOException, Interrupt

writer.flush();

carryOutGDBSession(stringBuffer, GDBSession.DEBUG_QUARKUS_FULL_MICROPROFILE, esvc, writer, report, UsedVersion.getVersion(false));
carryOutGDBSession(stringBuffer, GDBSession.DEBUG_QUARKUS_FULL_MICROPROFILE, esvc, writer, report, false);

writer.write("q\n");
writer.flush();
Expand Down Expand Up @@ -319,7 +318,7 @@ public void debugSymbolsQuarkusContainer(TestInfo testInfo) throws IOException,

writer.write("set directories /work/sources\n");
writer.flush();
carryOutGDBSession(stringBuffer, GDBSession.DEBUG_QUARKUS_BUILDER_IMAGE_VERTX, esvc, writer, report, UsedVersion.getVersion(true));
carryOutGDBSession(stringBuffer, GDBSession.DEBUG_QUARKUS_BUILDER_IMAGE_VERTX, esvc, writer, report, true);
writer.write("q\n");
writer.flush();
}
Expand All @@ -346,9 +345,9 @@ public void debugSymbolsQuarkusContainer(TestInfo testInfo) throws IOException,
}

public static void carryOutGDBSession(StringBuffer stringBuffer, GDBSession gdbSession, ExecutorService esvc,
BufferedWriter writer, StringBuilder report, Version mandrelVersion) {
BufferedWriter writer, StringBuilder report, boolean inContainer) {
final ConcurrentLinkedQueue<String> errorQueue = new ConcurrentLinkedQueue<>();
Stream.of(gdbSession.get(mandrelVersion)).forEach(cp -> {
Stream.of(gdbSession.get(inContainer)).forEach(cp -> {
stringBuffer.delete(0, stringBuffer.length());
try {
if (cp.c.startsWith("GOTO URL")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.graalvm.tests.integration.utils;

import org.graalvm.home.Version;
import org.graalvm.tests.integration.utils.versions.UsedVersion;

import java.util.regex.Pattern;

Expand All @@ -31,14 +32,62 @@
public enum GDBSession {
NONE {
@Override
public CP[] get(Version mandrelVersion) {
public CP[] get(boolean inContainer) {
return new CP[]{};
}
},
DEBUG_SYMBOLS_SMOKE {
@Override
public CP[] get(Version mandrelVersion) {
if (mandrelVersion.compareTo(Version.create(21, 1, 0)) >= 0) {
public CP[] get(boolean inContainer) {
if (UsedVersion.jdkFeature(inContainer) == 17 && UsedVersion.jdkInterim(inContainer) == 0 && UsedVersion.jdkUpdate(inContainer) < 4) {
// workaround graalvm/mandrel#355
return new CP[]{
SHOW_VERSION,
new CP("run < ./test_data_small.txt\n",
Pattern.compile(".*fdc7c50f390c145bc58a0bedbe5e6d2e35177ac73d12e2b23df149ce496a5572.*exited normally.*",
Pattern.DOTALL)),
new CP("info functions .*smoke.*\n",
Pattern.compile(
".*File debug_symbols_smoke/ClassA.java:.*" +
"java.lang.String \\*debug_symbols_smoke.ClassA::toString\\(void\\).*" +
"File debug_symbols_smoke/Main\\$\\$Lambda.*.java:.*" +
"void debug_symbols_smoke.Main..Lambda..*::accept\\(java.lang.Object.*" +
"File debug_symbols_smoke/Main.java:.*" +
"void debug_symbols_smoke.Main::lambda\\$thisIsTheEnd\\$0\\(java.io.ByteArrayOutputStream \\*, debug_symbols_smoke.ClassA \\*\\).*" +
"void debug_symbols_smoke.Main::main\\(java.lang.String\\[\\] \\*\\).*" +
"void debug_symbols_smoke.Main::thisIsTheEnd\\(java.util.List \\*\\).*"
, Pattern.DOTALL)),
new CP("break Main.java:70\n",
Pattern.compile(".*Breakpoint 1 at .*: file debug_symbols_smoke/Main.java, line 70.*",
Pattern.DOTALL)),
new CP("break Main.java:71\n",
Pattern.compile(".*Breakpoint 2 at .*: file debug_symbols_smoke/Main.java, line 71.*",
Pattern.DOTALL)),
new CP("break Main.java:76\n",
Pattern.compile(".*Breakpoint 3 at .*: file debug_symbols_smoke/Main.java, line 76.*",
Pattern.DOTALL)),
new CP("run < ./test_data_small.txt\n",
Pattern.compile(".*Breakpoint 1, .*while \\(sc.hasNextLine\\(\\)\\).*",
Pattern.DOTALL)),
new CP("c\n",
Pattern.compile(".*Breakpoint 3, debug_symbols_smoke.Main::main.*at debug_symbols_smoke/Main.java:76.*String l = sc.nextLine\\(\\);.*",
Pattern.DOTALL)),
new CP("c\n",
Pattern.compile(".*Breakpoint 2, debug_symbols_smoke.Main::main.*at debug_symbols_smoke/Main.java:71.* if \\(myString != null.*",
Pattern.DOTALL)),
new CP("c\n",
Pattern.compile(".*Breakpoint 2, debug_symbols_smoke.Main::main.*at debug_symbols_smoke/Main.java:71.* if \\(myString != null.*",
Pattern.DOTALL)),
new CP("d 2\n",
Pattern.compile(".*", Pattern.DOTALL)),
new CP("c\n",
Pattern.compile(".*fdc7c50f390c145bc58a0bedbe5e6d2e35177ac73d12e2b23df149ce496a5572.*exited normally.*",
Pattern.DOTALL)),
new CP("list ClassA.java:30\n",
Pattern.compile(".*ClassA\\(int myNumber, String myString\\).*",
Pattern.DOTALL)),
};
} else if (UsedVersion.getVersion(inContainer).compareTo(Version.create(21, 1, 0)) >= 0) {
return new CP[]{
SHOW_VERSION,
new CP("run < ./test_data_small.txt\n",
Expand Down Expand Up @@ -136,7 +185,7 @@ public CP[] get(Version mandrelVersion) {
},
DEBUG_QUARKUS_FULL_MICROPROFILE {
@Override
public CP[] get(Version mandrelVersion) {
public CP[] get(boolean inContainer) {
return new CP[]{
SHOW_VERSION,
new CP("b ConfigTestController.java:33\n",
Expand All @@ -157,7 +206,7 @@ public CP[] get(Version mandrelVersion) {
},
DEBUG_QUARKUS_BUILDER_IMAGE_VERTX {
@Override
public CP[] get(Version mandrelVersion) {
public CP[] get(boolean inContainer) {
return new CP[]{
SHOW_VERSION,
new CP("b Fruit.java:48\n",
Expand All @@ -178,5 +227,5 @@ public CP[] get(Version mandrelVersion) {

private static final CP SHOW_VERSION = new CP("show version\n", Pattern.compile(".*", Pattern.DOTALL));

public abstract CP[] get(Version mandrelVersion);
public abstract CP[] get(boolean inContainer);
}

0 comments on commit b75bfd2

Please sign in to comment.