Skip to content

Commit 39d29e6

Browse files
committed
[GR-55088] TimeoutTest made stable.
PullRequest: graal/18261
2 parents 81994e7 + b11c1b2 commit 39d29e6

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

tools/src/com.oracle.truffle.tools.chromeinspector.test/src/com/oracle/truffle/tools/chromeinspector/test/DisabledDomainTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package com.oracle.truffle.tools.chromeinspector.test;
2626

2727
import static org.junit.Assert.assertEquals;
28+
import static org.junit.Assert.assertTrue;
2829
import org.junit.Test;
2930

3031
/**
@@ -72,6 +73,9 @@ public void testDisabledDomainsCalls() throws Exception {
7273
assertEquals("{\"result\":{},\"id\":23}", tester.getMessages(true).trim());
7374
tester.sendMessage("{\"id\":24," + profilerMessage);
7475
assertEquals("{\"id\":24,\"error\":{\"code\":-32601,\"message\":\"Domain Profiler is disabled.\"}}", tester.getMessages(true).trim());
76+
tester.sendMessage("{\"id\":30,\"method\":\"Runtime.enable\"}");
77+
tester.sendMessage("{\"id\":31,\"method\":\"Runtime.runIfWaitingForDebugger\"}");
78+
assertTrue(tester.compareReceivedMessages("{\"result\":{},\"id\":30}\n{\"result\":{},\"id\":31}\n"));
7579
tester.finish();
7680
}
7781
// @formatter:on

tools/src/com.oracle.truffle.tools.chromeinspector.test/src/com/oracle/truffle/tools/chromeinspector/test/InspectorTester.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ public void run() {
406406
}
407407
}
408408
if (source != null) {
409+
inspectorContext.waitForRunPermission();
409410
Value value = context.eval(source);
410411
valueFuture.complete(value);
411412
}

tools/src/com.oracle.truffle.tools.chromeinspector.test/src/com/oracle/truffle/tools/chromeinspector/test/ProfilerTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import static org.junit.Assert.assertEquals;
2828
import static org.junit.Assert.assertNotNull;
29+
import static org.junit.Assert.assertTrue;
2930

3031
import java.io.IOException;
3132
import java.util.concurrent.ExecutionException;
@@ -63,6 +64,9 @@ public void testNoSourceProfile() throws InterruptedException, IOException, Exec
6364
assertEquals("{\"result\":{},\"id\":3}", tester.getMessages(true).trim());
6465
tester.sendMessage("{\"id\":4,\"method\":\"Profiler.start\"}");
6566
assertEquals("{\"result\":{},\"id\":4}", tester.getMessages(true).trim());
67+
tester.sendMessage("{\"id\":10,\"method\":\"Runtime.runIfWaitingForDebugger\"}");
68+
assertTrue(tester.compareReceivedMessages("{\"result\":{},\"id\":10}\n" +
69+
"{\"method\":\"Runtime.executionContextCreated\",\"params\":{\"context\":{\"origin\":\"\",\"name\":\"test\",\"id\":1}}}\n"));
6670
tester.eval(source).get();
6771
tester.sendMessage("{\"id\":5,\"method\":\"Profiler.stop\"}");
6872
JSONObject json = new JSONObject(tester.getMessages(true).trim());
@@ -89,6 +93,9 @@ public void testNoSourceCoverage() throws InterruptedException, IOException, Exe
8993
assertEquals("{\"result\":{},\"id\":2}", tester.getMessages(true).trim());
9094
tester.sendMessage("{\"id\":3,\"method\":\"Profiler.startPreciseCoverage\"}");
9195
assertEquals("{\"result\":{},\"id\":3}", tester.getMessages(true).trim());
96+
tester.sendMessage("{\"id\":4,\"method\":\"Runtime.runIfWaitingForDebugger\"}");
97+
assertTrue(tester.compareReceivedMessages("{\"result\":{},\"id\":4}\n" +
98+
"{\"method\":\"Runtime.executionContextCreated\",\"params\":{\"context\":{\"origin\":\"\",\"name\":\"test\",\"id\":1}}}\n"));
9299
tester.eval(source).get();
93100
tester.sendMessage("{\"id\":5,\"method\":\"Profiler.takePreciseCoverage\"}");
94101
// No results in case of no source section

tools/src/com.oracle.truffle.tools.chromeinspector.test/src/com/oracle/truffle/tools/chromeinspector/test/SLInspectProfileTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ public void testCPUProfiler() throws Exception {
8888
tester.sendMessage("{\"id\":4,\"method\":\"Profiler.start\"}");
8989
assertEquals("{\"result\":{},\"id\":4}", tester.getMessages(true).trim());
9090
assertTrue(tester.shouldWaitForClose());
91+
tester.sendMessage("{\"id\":10,\"method\":\"Runtime.runIfWaitingForDebugger\"}");
92+
assertTrue(tester.compareReceivedMessages("{\"result\":{},\"id\":10}\n" +
93+
"{\"method\":\"Runtime.executionContextCreated\",\"params\":{\"context\":{\"origin\":\"\",\"name\":\"test\",\"id\":1}}}\n"));
9194
tester.eval(source).get();
9295
tester.sendMessage("{\"id\":5,\"method\":\"Profiler.stop\"}");
9396
JSONObject json = new JSONObject(tester.getMessages(true).trim());
@@ -118,6 +121,9 @@ public void testCodeCoverage() throws Exception {
118121
assertTrue(tester.shouldWaitForClose());
119122
tester.sendMessage("{\"id\":4,\"method\":\"Profiler.takePreciseCoverage\"}");
120123
assertEquals("{\"result\":{\"result\":[]},\"id\":4}", tester.getMessages(true).trim());
124+
tester.sendMessage("{\"id\":10,\"method\":\"Runtime.runIfWaitingForDebugger\"}");
125+
assertTrue(tester.compareReceivedMessages("{\"result\":{},\"id\":10}\n" +
126+
"{\"method\":\"Runtime.executionContextCreated\",\"params\":{\"context\":{\"origin\":\"\",\"name\":\"test\",\"id\":1}}}\n"));
121127
tester.eval(source).get();
122128
tester.sendMessage("{\"id\":5,\"method\":\"Profiler.takePreciseCoverage\"}");
123129
assertEquals("{\"result\":{\"result\":[{\"scriptId\":\"1\",\"functions\":["
@@ -149,6 +155,9 @@ public void testDetailedCodeCoverage() throws Exception {
149155
assertTrue(tester.shouldWaitForClose());
150156
tester.sendMessage("{\"id\":4,\"method\":\"Profiler.takePreciseCoverage\"}");
151157
assertEquals("{\"result\":{\"result\":[]},\"id\":4}", tester.getMessages(true).trim());
158+
tester.sendMessage("{\"id\":10,\"method\":\"Runtime.runIfWaitingForDebugger\"}");
159+
assertTrue(tester.compareReceivedMessages("{\"result\":{},\"id\":10}\n" +
160+
"{\"method\":\"Runtime.executionContextCreated\",\"params\":{\"context\":{\"origin\":\"\",\"name\":\"test\",\"id\":1}}}\n"));
152161
tester.eval(source).get();
153162
tester.sendMessage("{\"id\":5,\"method\":\"Profiler.takePreciseCoverage\"}");
154163
assertEquals("{\"result\":{\"result\":[{\"scriptId\":\"1\",\"functions\":["
@@ -180,6 +189,9 @@ public void testTypeProfile() throws Exception {
180189
assertTrue(tester.shouldWaitForClose());
181190
tester.sendMessage("{\"id\":4,\"method\":\"Profiler.takeTypeProfile\"}");
182191
assertEquals("{\"result\":{\"result\":[]},\"id\":4}", tester.getMessages(true).trim());
192+
tester.sendMessage("{\"id\":10,\"method\":\"Runtime.runIfWaitingForDebugger\"}");
193+
assertTrue(tester.compareReceivedMessages("{\"result\":{},\"id\":10}\n" +
194+
"{\"method\":\"Runtime.executionContextCreated\",\"params\":{\"context\":{\"origin\":\"\",\"name\":\"test\",\"id\":1}}}\n"));
183195
tester.eval(source).get();
184196
tester.sendMessage("{\"id\":5,\"method\":\"Profiler.takeTypeProfile\"}");
185197
assertEquals("{\"result\":{\"result\":[{\"scriptId\":\"1\",\"entries\":["

tools/src/com.oracle.truffle.tools.chromeinspector.test/src/com/oracle/truffle/tools/chromeinspector/test/TimeoutTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
import org.graalvm.polyglot.Source;
3636

37-
import com.oracle.truffle.api.instrumentation.GenerateWrapper.Ignore;
3837
import com.oracle.truffle.api.instrumentation.test.InstrumentationTestLanguage;
3938

4039
public class TimeoutTest {
@@ -46,13 +45,12 @@ public void tearDown() {
4645

4746
// @formatter:off The default formatting makes unnecessarily big indents and illogical line breaks
4847
@Test
49-
@Ignore //GR-55088 fails transiently
5048
public void testSuspensionTimeout() throws Exception {
5149
String code = "ROOT(STATEMENT)";
5250
Source source = Source.newBuilder(InstrumentationTestLanguage.ID, code, "TestFile").build();
5351
String sourceURI = InspectorTester.getStringURI(source.getURI());
5452
int codeLength = code.length();
55-
InspectorTester tester = InspectorTester.start(new InspectorTester.Options(true).setSuspensionTimeout(1000L));
53+
InspectorTester tester = InspectorTester.start(new InspectorTester.Options(true).setSuspensionTimeout(1L));
5654
ByteArrayOutputStream output = new ByteArrayOutputStream();
5755
tester.setErr(output);
5856
tester.eval(source);
@@ -79,7 +77,7 @@ public void testSuspensionTimeout() throws Exception {
7977
// Do not resume, the suspension timeout breaks it
8078
tester.finish();
8179
String errMessage = new String(output.toByteArray());
82-
assertEquals("Timeout of 1000ms as specified via '--inspect.SuspensionTimeout' was reached. The debugger session is disconnected." + System.lineSeparator(), errMessage);
80+
assertEquals("Timeout of 1ms as specified via '--inspect.SuspensionTimeout' was reached. The debugger session is disconnected." + System.lineSeparator(), errMessage);
8381
}
8482

8583
@Test
@@ -89,7 +87,7 @@ public void testSuspensionTimeoutInInitializer() throws Exception {
8987
InstrumentationTestLanguage.envConfig = Collections.singletonMap("initSource", source);
9088
String sourceURI = InspectorTester.getStringURI(source.getURI());
9189
int codeLength = code.length();
92-
InspectorTester tester = InspectorTester.start(new InspectorTester.Options(true, false, true).setSuspensionTimeout(1000L));
90+
InspectorTester tester = InspectorTester.start(new InspectorTester.Options(true, false, true).setSuspensionTimeout(1L));
9391
ByteArrayOutputStream output = new ByteArrayOutputStream();
9492
tester.setErr(output);
9593
tester.eval(source);
@@ -116,7 +114,7 @@ public void testSuspensionTimeoutInInitializer() throws Exception {
116114
// Do not resume, the suspension timeout breaks it
117115
tester.finish();
118116
String errMessage = new String(output.toByteArray());
119-
assertEquals("Timeout of 1000ms as specified via '--inspect.SuspensionTimeout' was reached. The debugger session is disconnected." + System.lineSeparator(), errMessage);
117+
assertEquals("Timeout of 1ms as specified via '--inspect.SuspensionTimeout' was reached. The debugger session is disconnected." + System.lineSeparator(), errMessage);
120118
}
121119
// @formatter:on
122120
}

0 commit comments

Comments
 (0)