Search in sources :

Example 1 with BProgram

use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.

the class DfsBProgramVerifierTest method testTwoLoopingBThreads.

@Test(timeout = 2000)
public void testTwoLoopingBThreads() throws Exception {
    BProgram bprog = new StringBProgram("bp.registerBThread('bt1', function(){" + "    while(true){\n" + "       bsync({ request:[ bp.Event(\"STAM1\") ] });\n" + "}});\n" + "bp.registerBThread('bt2', function(){" + "    while(true){\n" + "       bsync({ request:[ bp.Event(\"STAM2\") ] });\n" + "}});\n" + "");
    DfsBProgramVerifier sut = new DfsBProgramVerifier();
    sut.setIterationCountGap(1);
    sut.setProgressListener(new BriefPrintDfsVerifierListener());
    sut.setDebugMode(true);
    VerificationResult res = sut.verify(bprog);
    assertFalse(res.isCounterExampleFound());
    assertEquals(1, res.getScannedStatesCount());
}
Also used : BriefPrintDfsVerifierListener(il.ac.bgu.cs.bp.bpjs.analysis.listeners.BriefPrintDfsVerifierListener) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) BProgram(il.ac.bgu.cs.bp.bpjs.model.BProgram) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) Test(org.junit.Test)

Example 2 with BProgram

use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.

the class DfsBProgramVerifierTest method testTwoSimpleBThreads.

@Test
public void testTwoSimpleBThreads() throws Exception {
    BProgram bprog = new StringBProgram("bp.registerBThread('bt1', function(){bsync({ request:[ bp.Event(\"STAM1\") ] });});" + "bp.registerBThread('bt2', function(){bsync({ request:[ bp.Event(\"STAM2\") ] });});");
    DfsBProgramVerifier sut = new DfsBProgramVerifier();
    sut.setIterationCountGap(1);
    sut.setProgressListener(new BriefPrintDfsVerifierListener());
    sut.setDetectDeadlocks(false);
    VerificationResult res = sut.verify(bprog);
    assertTrue(res.isVerifiedSuccessfully());
    assertEquals(3, res.getScannedStatesCount());
    assertEquals(VerificationResult.ViolationType.None, res.getViolationType());
}
Also used : BriefPrintDfsVerifierListener(il.ac.bgu.cs.bp.bpjs.analysis.listeners.BriefPrintDfsVerifierListener) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) BProgram(il.ac.bgu.cs.bp.bpjs.model.BProgram) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) Test(org.junit.Test)

Example 3 with BProgram

use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.

the class DfsBProgramVerifierTest method simpleAAABTrace_hashedNodeStore.

@Test
public void simpleAAABTrace_hashedNodeStore() throws Exception {
    BProgram program = new SingleResourceBProgram("AAABTrace.js");
    DfsBProgramVerifier sut = new DfsBProgramVerifier();
    sut.setProgressListener(new BriefPrintDfsVerifierListener());
    program.appendSource(Requirements.eventNotSelected("B"));
    sut.setVisitedNodeStore(new BProgramStateVisitedStateStore(true));
    VerificationResult res = sut.verify(program);
    assertTrue(res.isCounterExampleFound());
    assertEquals("AAAB", traceEventNamesString(res.getCounterExampleTrace(), ""));
}
Also used : BriefPrintDfsVerifierListener(il.ac.bgu.cs.bp.bpjs.analysis.listeners.BriefPrintDfsVerifierListener) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) BProgram(il.ac.bgu.cs.bp.bpjs.model.BProgram) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) Test(org.junit.Test)

Example 4 with BProgram

use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.

the class BProgramSyncSnapshotClonerTest method verifyProgram.

@Test
public void verifyProgram() throws Exception {
    DfsBProgramVerifier vfr = new DfsBProgramVerifier();
    BProgram bprog = new SingleResourceBProgram("BProgramSyncSnapshotClonerTest.js");
    final VerificationResult res = vfr.verify(bprog);
    System.out.println("res = " + res.getCounterExampleTrace());
}
Also used : VerificationResult(il.ac.bgu.cs.bp.bpjs.analysis.VerificationResult) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) BProgram(il.ac.bgu.cs.bp.bpjs.model.BProgram) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) DfsBProgramVerifier(il.ac.bgu.cs.bp.bpjs.analysis.DfsBProgramVerifier) Test(org.junit.Test)

Example 5 with BProgram

use of il.ac.bgu.cs.bp.bpjs.model.BProgram in project BPjs by bThink-BGU.

the class StateStorePerformanceComparison method makeBProgram.

private static BProgram makeBProgram() {
    // prepare b-program
    final BProgram bprog = new SingleResourceBProgram(IMPLEMENTATION);
    bprog.putInGlobalScope("MAZE_NAME", MAZE_NAME);
    bprog.putInGlobalScope("TARGET_FOUND_EVENT", TARGET_FOUND_EVENT);
    bprog.appendSource(Requirements.eventNotSelected(TARGET_FOUND_EVENT.getName()));
    return bprog;
}
Also used : SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) BProgram(il.ac.bgu.cs.bp.bpjs.model.BProgram) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram)

Aggregations

BProgram (il.ac.bgu.cs.bp.bpjs.model.BProgram)36 Test (org.junit.Test)29 SingleResourceBProgram (il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram)23 StringBProgram (il.ac.bgu.cs.bp.bpjs.model.StringBProgram)21 BProgramRunner (il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner)11 BProgramSyncSnapshot (il.ac.bgu.cs.bp.bpjs.model.BProgramSyncSnapshot)10 BThreadSyncSnapshot (il.ac.bgu.cs.bp.bpjs.model.BThreadSyncSnapshot)9 BEvent (il.ac.bgu.cs.bp.bpjs.model.BEvent)8 PrintBProgramRunnerListener (il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener)7 NativeContinuation (org.mozilla.javascript.NativeContinuation)7 BriefPrintDfsVerifierListener (il.ac.bgu.cs.bp.bpjs.analysis.listeners.BriefPrintDfsVerifierListener)5 Scriptable (org.mozilla.javascript.Scriptable)5 InMemoryEventLoggingListener (il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener)4 DfsBProgramVerifier (il.ac.bgu.cs.bp.bpjs.analysis.DfsBProgramVerifier)3 VerificationResult (il.ac.bgu.cs.bp.bpjs.analysis.VerificationResult)3 BPjsCodeEvaluationException (il.ac.bgu.cs.bp.bpjs.exceptions.BPjsCodeEvaluationException)2 ExecutorServiceMaker (il.ac.bgu.cs.bp.bpjs.internal.ExecutorServiceMaker)2 EventSelectionStrategy (il.ac.bgu.cs.bp.bpjs.model.eventselection.EventSelectionStrategy)2 PrioritizedBSyncEventSelectionStrategy (il.ac.bgu.cs.bp.bpjs.model.eventselection.PrioritizedBSyncEventSelectionStrategy)2 SimpleEventSelectionStrategy (il.ac.bgu.cs.bp.bpjs.model.eventselection.SimpleEventSelectionStrategy)2