use of com.oracle.truffle.llvm.tests.util.ProcessUtil.ProcessResult in project graal by oracle.
the class BaseSuiteHarness method test.
@Test
public void test() throws IOException {
assumeNotExcluded();
Path referenceBinary;
ProcessResult referenceResult;
try (Stream<Path> walk = Files.list(getTestDirectory())) {
List<Path> files = walk.filter(getIsExecutableFilter()).collect(Collectors.toList());
// some tests do not compile with certain versions of clang
assumeFalse("reference binary missing", files.isEmpty());
referenceBinary = files.get(0);
referenceResult = runReference(referenceBinary);
}
try (Stream<Path> walk = Files.list(getTestDirectory())) {
List<Path> testCandidates = walk.filter(CommonTestUtils.isFile).filter(getIsSulongFilter()).collect(Collectors.toList());
Assert.assertFalse("candidate list empty", testCandidates.isEmpty());
for (Path candidate : testCandidates) {
runCandidate(referenceBinary, referenceResult, candidate);
}
pass(getTestName());
}
}
use of com.oracle.truffle.llvm.tests.util.ProcessUtil.ProcessResult in project graal by oracle.
the class BaseSuiteHarness method runCandidate.
private void runCandidate(Path referenceBinary, ProcessResult referenceResult, Path candidateBinary) {
if (!filterFileName().test(candidateBinary.getFileName().toString())) {
return;
}
if (!candidateBinary.toAbsolutePath().toFile().exists()) {
throw fail(getTestName(), new AssertionError("File " + candidateBinary.toAbsolutePath().toFile() + " does not exist."));
}
String[] inputArgs = getInputArgs(candidateBinary);
ProcessResult result;
try {
assert engine != null;
result = ProcessUtil.executeSulongTestMainSameEngine(candidateBinary.toAbsolutePath().toFile(), inputArgs, getContextOptions(), getCaptureOutput(), engine);
} catch (Exception e) {
throw fail(getTestName(), new Exception("Candidate binary that failed: " + candidateBinary, e));
}
int sulongRet = result.getReturnValue();
if (sulongRet != (sulongRet & 0xFF)) {
throw fail(getTestName(), new AssertionError("Broken unittest " + getTestDirectory() + ". Test exits with invalid value: " + sulongRet));
}
validateResults(referenceBinary, referenceResult, candidateBinary, result);
}
use of com.oracle.truffle.llvm.tests.util.ProcessUtil.ProcessResult 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);
}
}
Aggregations