use of com.oracle.truffle.llvm.tests.pipe.CaptureOutput in project graal by oracle.
the class PolyglotToolchainTest method testCC.
@Test
public void testCC() throws IOException {
try (CaptureOutput out = new CaptureNativeOutput()) {
testLibrary.getMember("print_cc").execute();
Assert.assertEquals(String.format("CC=%s\n", getToolchain().getToolPath("CC").toString()), out.getStdOut());
}
}
use of com.oracle.truffle.llvm.tests.pipe.CaptureOutput in project graal by oracle.
the class ProcessUtil method executeSulongTestMainSameEngine.
public static ProcessResult executeSulongTestMainSameEngine(File bitcodeFile, String[] args, Map<String, String> options, Function<Context.Builder, CaptureOutput> captureOutput, Engine engine) throws IOException {
if (TestOptions.TEST_AOT_IMAGE == null) {
org.graalvm.polyglot.Source source = org.graalvm.polyglot.Source.newBuilder(LLVMLanguage.ID, bitcodeFile).build();
Builder builder = Context.newBuilder();
try (CaptureOutput out = captureOutput.apply(builder)) {
int result;
try (Context context = builder.engine(engine).arguments(LLVMLanguage.ID, args).options(options).allowAllAccess(true).build()) {
Value main = context.eval(source);
if (!main.canExecute()) {
throw new LLVMLinkerException("No main function found.");
}
result = main.execute().asInt();
}
return new ProcessResult(bitcodeFile.getName(), result, out.getStdErr(), out.getStdOut());
}
} else {
String aotArgs = TestOptions.TEST_AOT_ARGS == null ? "" : TestOptions.TEST_AOT_ARGS + " ";
String cmdline = TestOptions.TEST_AOT_IMAGE + " " + aotArgs + concatOptions(options) + bitcodeFile.getAbsolutePath() + " " + concatCommand(args);
return executeNativeCommand(cmdline);
}
}
use of com.oracle.truffle.llvm.tests.pipe.CaptureOutput in project graal by oracle.
the class PolyglotToolchainTest method testIdentifier.
@Test
public void testIdentifier() throws IOException {
try (CaptureOutput out = new CaptureNativeOutput()) {
testLibrary.getMember("print_id").execute();
Assert.assertEquals(String.format("ID=%s\n", getToolchain().getIdentifier().toString()), out.getStdOut());
}
}
use of com.oracle.truffle.llvm.tests.pipe.CaptureOutput in project graal by oracle.
the class CaptureOutputTest method testOutputCapturing2.
@Test
public void testOutputCapturing2() throws IOException {
String string = "Does it work again?";
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 testErrCapturing2.
@Test
public void testErrCapturing2() throws IOException {
String string = "Does it work again?";
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);
}
Aggregations