use of com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput in project graal by oracle.
the class LLVMDebugTestBase method runTest.
@SuppressWarnings("try")
private void runTest(Source source, Source bitcode, Trace trace) throws IOException {
try (CaptureNativeOutput out = new CaptureNativeOutput()) {
try (DebuggerSession session = tester.startSession()) {
trace.requestedBreakpoints().forEach(line -> session.install(buildBreakPoint(source, line)));
if (trace.suspendOnEntry()) {
session.suspendNextExecution();
}
tester.startEval(bitcode);
final BreakInfo info = new BreakInfo();
for (StopRequest bpr : trace) {
final TestCallback expectedEvent = new TestCallback(info, bpr);
do {
tester.expectSuspended(expectedEvent);
} while (!expectedEvent.isDone());
}
tester.expectDone();
}
}
}
use of com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput in project graal by oracle.
the class ToolchainAPITest method testCC.
@Test
public void testCC() throws IOException, InterruptedException {
File src = File.createTempFile(ToolchainAPITest.class.getSimpleName(), ".c");
src.deleteOnExit();
File dst = File.createTempFile(ToolchainAPITest.class.getSimpleName(), ".out");
dst.deleteOnExit();
write(src, HELLO_WORLD_C);
int compileResult = compile("CC", src, dst);
Assert.assertEquals("compiler result", 0, compileResult);
try (CaptureOutput out = new CaptureNativeOutput()) {
int runResult = load(dst).execute().asInt();
Assert.assertEquals("run result", 0, runResult);
Assert.assertEquals("Hello World!", out.getStdOut());
}
}
use of com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput in project graal by oracle.
the class ToolchainAPITest method testCXX.
@Test
public void testCXX() throws IOException, InterruptedException {
File src = File.createTempFile(ToolchainAPITest.class.getSimpleName(), ".cpp");
src.deleteOnExit();
File dst = File.createTempFile(ToolchainAPITest.class.getSimpleName(), ".out");
dst.deleteOnExit();
write(src, HELLO_WORLD_CXX);
int compileResult = compile("CXX", src, dst);
Assert.assertEquals("compiler result", 0, compileResult);
try (CaptureOutput out = new CaptureNativeOutput()) {
int runResult = load(dst).execute().asInt();
Assert.assertEquals("run result", 0, runResult);
Assert.assertEquals("Hello World!", out.getStdOut());
}
}
use of com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput in project graal by oracle.
the class CaptureOutputTest method testOutputCapturing.
@Test
public void testOutputCapturing() throws IOException {
String string = "Testoutput";
String captured;
try (CaptureOutput out = new CaptureNativeOutput()) {
System.out.print(string);
captured = out.getStdOut();
}
System.out.println("MUST NOT BE IN CAPTURE");
assertEquals(string, captured);
}
use of com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput in project graal by oracle.
the class CaptureOutputTest method testBigOutput.
@Test
public void testBigOutput() throws IOException {
StringBuilder result = new StringBuilder();
String capture;
try (CaptureOutput out = new CaptureNativeOutput()) {
for (int i = 0; i < 9000; i++) {
String line = String.format("line %04d\n", i);
System.out.print(line);
result.append(line);
}
capture = out.getStdOut();
}
assertEquals(result.toString(), capture);
}
Aggregations