Search in sources :

Example 6 with ParserCat

use of com.dat3m.dartagnan.parsers.cat.ParserCat in project Dat3M by hernanponcedeleon.

the class PrinterTest method AARCH64toString.

@Test()
public void AARCH64toString() throws Exception {
    Wmm cat = new ParserCat().parse(new File(ResourceHelper.CAT_RESOURCE_PATH + "cat/aarch64.cat"));
    assertNotNull(cat.toString());
}
Also used : Wmm(com.dat3m.dartagnan.wmm.Wmm) ParserCat(com.dat3m.dartagnan.parsers.cat.ParserCat) File(java.io.File) Test(org.junit.Test)

Example 7 with ParserCat

use of com.dat3m.dartagnan.parsers.cat.ParserCat in project Dat3M by hernanponcedeleon.

the class UnusedTestFails method data.

@Parameterized.Parameters(name = "{index}: {0} bound={2}")
public static Iterable<Object[]> data() throws IOException {
    String scCat = GlobalSettings.ATOMIC_AS_LOCK ? "cat/svcomp-locks.cat" : "cat/svcomp.cat";
    Wmm sc = new ParserCat().parse(new File(ResourceHelper.CAT_RESOURCE_PATH + scCat));
    Wmm tso = new ParserCat().parse(new File(ResourceHelper.CAT_RESOURCE_PATH + "cat/tso.cat"));
    Wmm power = new ParserCat().parse(new File(ResourceHelper.CAT_RESOURCE_PATH + "cat/power.cat"));
    Wmm arm = new ParserCat().parse(new File(ResourceHelper.CAT_RESOURCE_PATH + "cat/aarch64.cat"));
    List<Object[]> data = new ArrayList<>();
    return data;
}
Also used : Wmm(com.dat3m.dartagnan.wmm.Wmm) ArrayList(java.util.ArrayList) ParserCat(com.dat3m.dartagnan.parsers.cat.ParserCat) File(java.io.File)

Example 8 with ParserCat

use of com.dat3m.dartagnan.parsers.cat.ParserCat in project Dat3M by hernanponcedeleon.

the class BuildWitnessTest method BuildWriteEncode.

@Test
public void BuildWriteEncode() throws Exception {
    Configuration config = Configuration.builder().setOption(WITNESS_ORIGINAL_PROGRAM_PATH, ResourceHelper.TEST_RESOURCE_PATH + "witness/lazy01-for-witness.bpl").setOption(BOUND, "1").build();
    Program p = new ProgramParser().parse(new File(ResourceHelper.TEST_RESOURCE_PATH + "witness/lazy01-for-witness.bpl"));
    Wmm wmm = new ParserCat().parse(new File(ResourceHelper.CAT_RESOURCE_PATH + "cat/svcomp.cat"));
    VerificationTask task = VerificationTask.builder().withConfig(config).build(p, wmm, EnumSet.of(Property.getDefault()));
    try (SolverContext ctx = TestHelper.createContext();
        ProverEnvironment prover = ctx.newProverEnvironment(ProverOptions.GENERATE_MODELS)) {
        Result res = IncrementalSolver.run(ctx, prover, task);
        WitnessBuilder witnessBuilder = new WitnessBuilder(task, ctx, prover, res);
        config.inject(witnessBuilder);
        WitnessGraph graph = witnessBuilder.build();
        File witnessFile = new File(System.getenv("DAT3M_HOME") + "/output/lazy01-for-witness.graphml");
        // The file should not exist
        assertFalse(witnessFile.exists());
        // Write to file
        graph.write();
        // The file should exist now
        assertTrue(witnessFile.exists());
        // Delete the file
        witnessFile.delete();
        // Create encoding
        BooleanFormula enc = graph.encode(p, ctx);
        BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
        // Check the formula is not trivial
        assertFalse(bmgr.isFalse(enc));
        assertFalse(bmgr.isTrue(enc));
    }
}
Also used : Program(com.dat3m.dartagnan.program.Program) BooleanFormulaManager(org.sosy_lab.java_smt.api.BooleanFormulaManager) Configuration(org.sosy_lab.common.configuration.Configuration) ProgramParser(com.dat3m.dartagnan.parsers.program.ProgramParser) ParserCat(com.dat3m.dartagnan.parsers.cat.ParserCat) Result(com.dat3m.dartagnan.utils.Result) SolverContext(org.sosy_lab.java_smt.api.SolverContext) VerificationTask(com.dat3m.dartagnan.verification.VerificationTask) Wmm(com.dat3m.dartagnan.wmm.Wmm) File(java.io.File) ProverEnvironment(org.sosy_lab.java_smt.api.ProverEnvironment) BooleanFormula(org.sosy_lab.java_smt.api.BooleanFormula) Test(org.junit.Test)

Example 9 with ParserCat

use of com.dat3m.dartagnan.parsers.cat.ParserCat in project Dat3M by hernanponcedeleon.

the class Dat3M method runTest.

private void runTest() {
    UiOptions options = optionsPane.getOptions();
    testResult = null;
    try {
        Editor programEditor = editorsPane.getEditor(EditorCode.PROGRAM);
        Program program = new ProgramParser().parse(programEditor.getEditorPane().getText(), programEditor.getLoadedFormat());
        try {
            Wmm targetModel = new ParserCat().parse(editorsPane.getEditor(EditorCode.TARGET_MM).getEditorPane().getText());
            testResult = new ReachabilityResult(program, targetModel, options);
        } catch (Exception e) {
            String msg = e.getMessage() == null ? "Memory model cannot be parsed" : e.getMessage();
            showError(msg, "Target memory model error");
        }
    } catch (Exception e) {
        String msg = e.getMessage() == null ? "Program cannot be parsed" : e.getMessage();
        Throwable cause = e.getCause();
        if (cause instanceof InputMismatchException) {
            Token token = ((InputMismatchException) cause).getOffendingToken();
            msg = "Problem with \"" + token.getText() + "\" at line " + token.getLine();
        }
        showError(msg, "Program error");
    }
}
Also used : ReachabilityResult(com.dat3m.ui.result.ReachabilityResult) Program(com.dat3m.dartagnan.program.Program) ProgramParser(com.dat3m.dartagnan.parsers.program.ProgramParser) Wmm(com.dat3m.dartagnan.wmm.Wmm) UiOptions(com.dat3m.ui.utils.UiOptions) Token(org.antlr.v4.runtime.Token) ParserCat(com.dat3m.dartagnan.parsers.cat.ParserCat) Editor(com.dat3m.ui.editor.Editor) InputMismatchException(org.antlr.v4.runtime.InputMismatchException) InputMismatchException(org.antlr.v4.runtime.InputMismatchException)

Example 10 with ParserCat

use of com.dat3m.dartagnan.parsers.cat.ParserCat in project Dat3M by hernanponcedeleon.

the class BranchTest method data.

@Parameterized.Parameters(name = "{index}: {0}")
public static Iterable<Object[]> data() throws IOException {
    ImmutableMap<String, Result> expected = readExpectedResults();
    Wmm linuxWmm = new ParserCat().parse(new File(ResourceHelper.CAT_RESOURCE_PATH + "cat/linux-kernel.cat"));
    Wmm aarch64Wmm = new ParserCat().parse(new File(ResourceHelper.CAT_RESOURCE_PATH + "cat/aarch64.cat"));
    List<Object[]> data;
    try (Stream<Path> fileStream = Files.walk(Paths.get(ResourceHelper.TEST_RESOURCE_PATH + "branch/C/"))) {
        data = fileStream.filter(Files::isRegularFile).filter(f -> (f.toString().endsWith("litmus"))).map(f -> new Object[] { f.toString(), expected.get(f.getFileName().toString()), linuxWmm }).collect(Collectors.toList());
    }
    try (Stream<Path> fileStream = Files.walk(Paths.get(ResourceHelper.TEST_RESOURCE_PATH + "branch/AARCH64/"))) {
        data.addAll(fileStream.filter(Files::isRegularFile).filter(f -> (f.toString().endsWith("litmus"))).map(f -> new Object[] { f.toString(), expected.get(f.getFileName().toString()), aarch64Wmm }).collect(Collectors.toList()));
    }
    return data;
}
Also used : Path(java.nio.file.Path) Property(com.dat3m.dartagnan.configuration.Property) RunWith(org.junit.runner.RunWith) ProverOptions(org.sosy_lab.java_smt.api.SolverContext.ProverOptions) ProverEnvironment(org.sosy_lab.java_smt.api.ProverEnvironment) TestHelper(com.dat3m.dartagnan.utils.TestHelper) Wmm(com.dat3m.dartagnan.wmm.Wmm) Result(com.dat3m.dartagnan.utils.Result) ParserCat(com.dat3m.dartagnan.parsers.cat.ParserCat) ProgramParser(com.dat3m.dartagnan.parsers.program.ProgramParser) ResourceHelper(com.dat3m.dartagnan.utils.ResourceHelper) SolverContext(org.sosy_lab.java_smt.api.SolverContext) Program(com.dat3m.dartagnan.program.Program) Assert.fail(org.junit.Assert.fail) Path(java.nio.file.Path) Parameterized(org.junit.runners.Parameterized) EnumSet(java.util.EnumSet) VerificationTask(com.dat3m.dartagnan.verification.VerificationTask) ImmutableMap(com.google.common.collect.ImmutableMap) Files(java.nio.file.Files) Test(org.junit.Test) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) File(java.io.File) TwoSolvers(com.dat3m.dartagnan.verification.solving.TwoSolvers) PASS(com.dat3m.dartagnan.utils.Result.PASS) List(java.util.List) Stream(java.util.stream.Stream) Arch(com.dat3m.dartagnan.configuration.Arch) Paths(java.nio.file.Paths) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) FAIL(com.dat3m.dartagnan.utils.Result.FAIL) Assert.assertEquals(org.junit.Assert.assertEquals) Wmm(com.dat3m.dartagnan.wmm.Wmm) ParserCat(com.dat3m.dartagnan.parsers.cat.ParserCat) Files(java.nio.file.Files) File(java.io.File) Result(com.dat3m.dartagnan.utils.Result)

Aggregations

ParserCat (com.dat3m.dartagnan.parsers.cat.ParserCat)10 Wmm (com.dat3m.dartagnan.wmm.Wmm)10 File (java.io.File)9 Test (org.junit.Test)7 Program (com.dat3m.dartagnan.program.Program)5 ProgramParser (com.dat3m.dartagnan.parsers.program.ProgramParser)4 VerificationTask (com.dat3m.dartagnan.verification.VerificationTask)4 Result (com.dat3m.dartagnan.utils.Result)3 Configuration (org.sosy_lab.common.configuration.Configuration)3 ProverEnvironment (org.sosy_lab.java_smt.api.ProverEnvironment)3 SolverContext (org.sosy_lab.java_smt.api.SolverContext)3 Property (com.dat3m.dartagnan.configuration.Property)2 EnumSet (java.util.EnumSet)2 Arch (com.dat3m.dartagnan.configuration.Arch)1 OptionInfo.collectOptions (com.dat3m.dartagnan.configuration.OptionInfo.collectOptions)1 PHANTOM_REFERENCES (com.dat3m.dartagnan.configuration.OptionNames.PHANTOM_REFERENCES)1 ProgramBuilder (com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder)1 ParserWitness (com.dat3m.dartagnan.parsers.witness.ParserWitness)1 SourceLanguage (com.dat3m.dartagnan.program.Program.SourceLanguage)1 CreateGitInfo (com.dat3m.dartagnan.utils.GitInfo.CreateGitInfo)1