Search in sources :

Example 31 with SingleResourceBProgram

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

the class VerificationResultOptionsTest method testDeadlockedProgram.

@Test
public void testDeadlockedProgram() throws Exception {
    final SingleResourceBProgram bprog = new SingleResourceBProgram("VerificationResultOptions.js");
    bprog.putInGlobalScope("addWaiter", false);
    bprog.putInGlobalScope("createDeadlock", true);
    bprog.putInGlobalScope("createFailedAssertion", false);
    DfsBProgramVerifier vfr = new DfsBProgramVerifier();
    final VerificationResult res = vfr.verify(bprog);
    assertEquals(VerificationResult.ViolationType.Deadlock, res.getViolationType());
    assertTrue(res.isCounterExampleFound());
}
Also used : VerificationResult(il.ac.bgu.cs.bp.bpjs.analysis.VerificationResult) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) DfsBProgramVerifier(il.ac.bgu.cs.bp.bpjs.analysis.DfsBProgramVerifier) Test(org.junit.Test)

Example 32 with SingleResourceBProgram

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

the class VerificationResultOptionsTest method testOKProgram.

@Test
public void testOKProgram() throws Exception {
    final SingleResourceBProgram bprog = new SingleResourceBProgram("VerificationResultOptions.js");
    bprog.putInGlobalScope("addWaiter", false);
    bprog.putInGlobalScope("createDeadlock", false);
    bprog.putInGlobalScope("createFailedAssertion", false);
    DfsBProgramVerifier vfr = new DfsBProgramVerifier();
    final VerificationResult res = vfr.verify(bprog);
    assertEquals(VerificationResult.ViolationType.None, res.getViolationType());
    assertFalse(res.isCounterExampleFound());
}
Also used : VerificationResult(il.ac.bgu.cs.bp.bpjs.analysis.VerificationResult) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) DfsBProgramVerifier(il.ac.bgu.cs.bp.bpjs.analysis.DfsBProgramVerifier) Test(org.junit.Test)

Example 33 with SingleResourceBProgram

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

the class NamedArgsHotNColdTest method superStepTest.

@Test
public void superStepTest() throws InterruptedException {
    BProgramRunner sut = new BProgramRunner(new SingleResourceBProgram("NamedArgsHotNCold.js"));
    sut.addListener(new PrintBProgramRunnerListener());
    InMemoryEventLoggingListener eventLogger = sut.addListener(new InMemoryEventLoggingListener());
    sut.run();
    eventLogger.getEvents().forEach(e -> System.out.println(e));
    final BEvent hotEvent = new BEvent("hotEvent");
    final BEvent coldEvent = new BEvent("coldEvent");
    final BEvent allDoneEvent = new BEvent("allDone");
    EventPattern expected = new EventPattern().append(coldEvent).append(hotEvent).append(coldEvent).append(hotEvent).append(coldEvent).append(hotEvent).append(allDoneEvent);
    assertTrue(expected.matches(eventLogger.getEvents()));
}
Also used : PrintBProgramRunnerListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener) EventPattern(il.ac.bgu.cs.bp.bpjs.analysis.eventpattern.EventPattern) BProgramRunner(il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) InMemoryEventLoggingListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener) BEvent(il.ac.bgu.cs.bp.bpjs.model.BEvent) Test(org.junit.Test)

Example 34 with SingleResourceBProgram

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

the class EventsArraysTest method testEventsWithData.

@Test
public void testEventsWithData() throws Exception {
    BProgramRunner bpr = new BProgramRunner(new SingleResourceBProgram("EventArrays.js"));
    bpr.addListener(new PrintBProgramRunnerListener());
    InMemoryEventLoggingListener events = bpr.addListener(new InMemoryEventLoggingListener());
    bpr.run();
    assertEquals(Arrays.asList("e11", "e21"), events.getEvents().stream().map(BEvent::getName).collect(toList()));
}
Also used : PrintBProgramRunnerListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener) BProgramRunner(il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) InMemoryEventLoggingListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener) BEvent(il.ac.bgu.cs.bp.bpjs.model.BEvent) Test(org.junit.Test)

Example 35 with SingleResourceBProgram

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

the class FailedAssertionTest method testNoAssertion.

@Test
public void testNoAssertion() throws InterruptedException {
    final SingleResourceBProgram bprog = new SingleResourceBProgram("FailedAssertionTest.js");
    BProgramRunner sut = new BProgramRunner(bprog);
    sut.addListener(new PrintBProgramRunnerListener());
    InMemoryEventLoggingListener eventLogger = sut.addListener(new InMemoryEventLoggingListener());
    System.out.println("About to start program");
    bprog.putInGlobalScope("shouldFail", false);
    sut.run();
    assertEquals(Arrays.asList("piff", "puff", "poof!", "peff"), eventLogger.eventNames());
    assertFalse(sut.hasFailedAssertion());
}
Also used : PrintBProgramRunnerListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener) BProgramRunner(il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) InMemoryEventLoggingListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener) Test(org.junit.Test)

Aggregations

SingleResourceBProgram (il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram)45 Test (org.junit.Test)38 BProgramRunner (il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner)29 PrintBProgramRunnerListener (il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener)26 InMemoryEventLoggingListener (il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener)22 BProgram (il.ac.bgu.cs.bp.bpjs.model.BProgram)17 BEvent (il.ac.bgu.cs.bp.bpjs.model.BEvent)14 EventPattern (il.ac.bgu.cs.bp.bpjs.analysis.eventpattern.EventPattern)10 DfsBProgramVerifier (il.ac.bgu.cs.bp.bpjs.analysis.DfsBProgramVerifier)9 VerificationResult (il.ac.bgu.cs.bp.bpjs.analysis.VerificationResult)9 StringBProgram (il.ac.bgu.cs.bp.bpjs.model.StringBProgram)7 BriefPrintDfsVerifierListener (il.ac.bgu.cs.bp.bpjs.analysis.listeners.BriefPrintDfsVerifierListener)4 PrioritizedBSyncEventSelectionStrategy (il.ac.bgu.cs.bp.bpjs.model.eventselection.PrioritizedBSyncEventSelectionStrategy)3 BProgramStateVisitedStateStore (il.ac.bgu.cs.bp.bpjs.analysis.BProgramStateVisitedStateStore)2 Node (il.ac.bgu.cs.bp.bpjs.analysis.Node)1 BProgramRunnerListenerAdapter (il.ac.bgu.cs.bp.bpjs.execution.listeners.BProgramRunnerListenerAdapter)1 ExecutorServiceMaker (il.ac.bgu.cs.bp.bpjs.internal.ExecutorServiceMaker)1 BProgramSyncSnapshot (il.ac.bgu.cs.bp.bpjs.model.BProgramSyncSnapshot)1 FailedAssertion (il.ac.bgu.cs.bp.bpjs.model.FailedAssertion)1 LoggingEventSelectionStrategyDecorator (il.ac.bgu.cs.bp.bpjs.model.eventselection.LoggingEventSelectionStrategyDecorator)1