use of com.oracle.truffle.llvm.tests.pipe.CaptureOutput 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.CaptureOutput 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.CaptureOutput 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.CaptureOutput 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);
}
use of com.oracle.truffle.llvm.tests.pipe.CaptureOutput in project graal by oracle.
the class PolyglotToolchainTest method testLDLibraryPath.
@Test
public void testLDLibraryPath() throws IOException {
try (CaptureOutput out = new CaptureNativeOutput()) {
testLibrary.getMember("print_ld_library_path").execute();
Assert.assertEquals(String.format("LD_LIBRARY_PATH=%s\n", getToolchain().getPaths("LD_LIBRARY_PATH").stream().map(TruffleFile::toString).collect(Collectors.joining(":"))), out.getStdOut());
}
}
Aggregations