Search in sources :

Example 11 with CaptureNativeOutput

use of com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput in project graal by oracle.

the class CaptureOutputTest method testErrCapturing.

@Test
public void testErrCapturing() throws IOException {
    String string = "Testoutput";
    String captured;
    try (CaptureOutput out = new CaptureNativeOutput()) {
        System.err.print(string);
        captured = out.getStdErr();
    }
    System.err.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 12 with CaptureNativeOutput

use of com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput in project graal by oracle.

the class BaseSulongOnlyHarness method test.

@Test
public void test() throws IOException {
    ProcessResult out = ProcessUtil.executeSulongTestMain(getPath().toAbsolutePath().toFile(), getConfiguration().args, getContextOptions(), c -> new CaptureNativeOutput());
    int sulongResult = out.getReturnValue();
    String sulongStdOut = out.getStdOutput();
    if (sulongResult != (sulongResult & 0xFF)) {
        Assert.fail("Broken unittest " + getPath() + ". Test exits with invalid value (" + sulongResult + ").");
    }
    String testName = getPath().getFileName().toString();
    Assert.assertEquals(testName + " failed. Posix return value missmatch.", getConfiguration().expectedPosixReturn, sulongResult);
    if (getConfiguration().expectedOutput != null) {
        Assert.assertEquals(testName + " failed. Output (stdout) missmatch.", getConfiguration().expectedOutput, sulongStdOut);
    }
}
Also used : CaptureNativeOutput(com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput) ProcessResult(com.oracle.truffle.llvm.tests.util.ProcessUtil.ProcessResult) 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