Search in sources :

Example 1 with CaptureNativeOutput

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();
        }
    }
}
Also used : DebuggerSession(com.oracle.truffle.api.debug.DebuggerSession) CaptureNativeOutput(com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput)

Example 2 with CaptureNativeOutput

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());
    }
}
Also used : CaptureOutput(com.oracle.truffle.llvm.tests.pipe.CaptureOutput) CaptureNativeOutput(com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput) TruffleFile(com.oracle.truffle.api.TruffleFile) File(java.io.File) Test(org.junit.Test)

Example 3 with CaptureNativeOutput

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());
    }
}
Also used : CaptureOutput(com.oracle.truffle.llvm.tests.pipe.CaptureOutput) CaptureNativeOutput(com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput) TruffleFile(com.oracle.truffle.api.TruffleFile) File(java.io.File) Test(org.junit.Test)

Example 4 with CaptureNativeOutput

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);
}
Also used : CaptureOutput(com.oracle.truffle.llvm.tests.pipe.CaptureOutput) CaptureNativeOutput(com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput) Test(org.junit.Test)

Example 5 with CaptureNativeOutput

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);
}
Also used : CaptureOutput(com.oracle.truffle.llvm.tests.pipe.CaptureOutput) CaptureNativeOutput(com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput) Test(org.junit.Test)

Aggregations

CaptureNativeOutput (com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput)12 Test (org.junit.Test)11 CaptureOutput (com.oracle.truffle.llvm.tests.pipe.CaptureOutput)10 TruffleFile (com.oracle.truffle.api.TruffleFile)2 File (java.io.File)2 DebuggerSession (com.oracle.truffle.api.debug.DebuggerSession)1 ProcessResult (com.oracle.truffle.llvm.tests.util.ProcessUtil.ProcessResult)1