use of il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram in project BPjs by bThink-BGU.
the class InterruptTest method superStepTest.
@Test
public void superStepTest() throws InterruptedException {
BProgramRunner sut = new BProgramRunner(new SingleResourceBProgram("Interrupt.js"));
sut.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = sut.addListener(new InMemoryEventLoggingListener());
sut.run();
eventLogger.getEvents().forEach(e -> System.out.println(e));
final BEvent breakingEvent = new BEvent("breaking");
assertEquals(Arrays.asList(breakingEvent, breakingEvent), eventLogger.getEvents());
}
use of il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram in project BPjs by bThink-BGU.
the class DfsBProgramVerifierTest method testAAABRun.
@Test
public void testAAABRun() throws Exception {
BProgram program = new SingleResourceBProgram("AAABTrace.js");
BProgramRunner rnr = new BProgramRunner(program);
rnr.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = rnr.addListener(new InMemoryEventLoggingListener());
rnr.run();
eventLogger.getEvents().forEach(System.out::println);
assertTrue(eventNamesString(eventLogger.getEvents(), "").matches("^(AAAB)+$"));
}
use of il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram in project BPjs by bThink-BGU.
the class DfsBProgramVerifierTest method deadlockRun.
@Test
public void deadlockRun() throws Exception {
BProgram program = new SingleResourceBProgram("deadlocking.js");
BProgramRunner rnr = new BProgramRunner(program);
rnr.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = rnr.addListener(new InMemoryEventLoggingListener());
rnr.run();
eventLogger.getEvents().forEach(System.out::println);
assertTrue(eventNamesString(eventLogger.getEvents(), "").matches("^A$"));
}
use of il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram in project BPjs by bThink-BGU.
the class DfsBProgramVerifierTest method simpleAAABTrace.
@Test
public void simpleAAABTrace() throws Exception {
BProgram program = new SingleResourceBProgram("AAABTrace.js");
DfsBProgramVerifier sut = new DfsBProgramVerifier();
sut.setProgressListener(new BriefPrintDfsVerifierListener());
program.appendSource(Requirements.eventNotSelected("B"));
sut.setVisitedNodeStore(new ForgetfulVisitedStateStore());
VerificationResult res = sut.verify(program);
assertTrue(res.isCounterExampleFound());
assertEquals("AAAB", traceEventNamesString(res.getCounterExampleTrace(), ""));
}
use of il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram in project BPjs by bThink-BGU.
the class DfsBProgramVerifierTest method deadlockTrace.
@Test
public void deadlockTrace() throws Exception {
BProgram program = new SingleResourceBProgram("deadlocking.js");
DfsBProgramVerifier sut = new DfsBProgramVerifier();
sut.setVisitedNodeStore(new ForgetfulVisitedStateStore());
VerificationResult res = sut.verify(program);
assertTrue(res.isCounterExampleFound());
assertEquals(VerificationResult.ViolationType.Deadlock, res.getViolationType());
assertEquals("A", traceEventNamesString(res.getCounterExampleTrace(), ""));
}
Aggregations