Search in sources :

Example 1 with ProcessResult

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());
    }
}
Also used : Path(java.nio.file.Path) ProcessResult(com.oracle.truffle.llvm.tests.util.ProcessUtil.ProcessResult) Test(org.junit.Test)

Example 2 with ProcessResult

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);
}
Also used : ProcessResult(com.oracle.truffle.llvm.tests.util.ProcessUtil.ProcessResult) AssumptionViolatedException(org.junit.AssumptionViolatedException) IOException(java.io.IOException)

Example 3 with ProcessResult

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

Aggregations

ProcessResult (com.oracle.truffle.llvm.tests.util.ProcessUtil.ProcessResult)3 Test (org.junit.Test)2 CaptureNativeOutput (com.oracle.truffle.llvm.tests.pipe.CaptureNativeOutput)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 AssumptionViolatedException (org.junit.AssumptionViolatedException)1