use of il.ac.bgu.cs.bp.bpjs.analysis.VerificationResult 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());
}
use of il.ac.bgu.cs.bp.bpjs.analysis.VerificationResult in project BPjs by bThink-BGU.
the class DiningPhilTest method printCounterExample.
private static void printCounterExample(VerificationResult res) {
System.out.println("Found a counterexample");
final List<Node> trace = res.getCounterExampleTrace();
trace.forEach(nd -> System.out.println(" " + nd.getLastEvent()));
Node last = trace.get(trace.size() - 1);
System.out.println("selectableEvents: " + last.getSelectableEvents());
last.getSystemState().getBThreadSnapshots().stream().sorted((s1, s2) -> s1.getName().compareTo(s2.getName())).forEach(s -> {
System.out.println(s.getName());
System.out.println(s.getBSyncStatement());
System.out.println();
});
}
use of il.ac.bgu.cs.bp.bpjs.analysis.VerificationResult in project BPjs by bThink-BGU.
the class DiningPhilTest method verifyPhilosophers.
private static VerificationResult verifyPhilosophers(int philosopherCount) throws InterruptedException {
// Create a program
final SingleResourceBProgram bprog = new SingleResourceBProgram("BPJSDiningPhil.js");
bprog.putInGlobalScope("PHILOSOPHER_COUNT", philosopherCount);
try {
DfsBProgramVerifier vfr = new DfsBProgramVerifier();
vfr.setMaxTraceLength(50);
final VerificationResult res = vfr.verify(bprog);
System.out.printf("Scanned %,d states\n", res.getScannedStatesCount());
System.out.printf("Time: %,d milliseconds\n", res.getTimeMillies());
return res;
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
return null;
}
use of il.ac.bgu.cs.bp.bpjs.analysis.VerificationResult in project BPjs by bThink-BGU.
the class StateStorePerformanceComparison method runVerifier.
private static void runVerifier(DfsBProgramVerifier vfr) throws Exception {
System.out.println("Testing " + vfr.getVisitedNodeStore());
System.out.println("Heating up");
for (int i = 0; i < HEAT_UP_ITERATIONS; i++) {
vfr.verify(makeBProgram());
}
for (int i = 0; i < ITERATIONS; i++) {
VerificationResult res = vfr.verify(makeBProgram());
System.out.println(res.getTimeMillies());
}
}
use of il.ac.bgu.cs.bp.bpjs.analysis.VerificationResult in project BPjs by bThink-BGU.
the class TicTacToeVerMain method main.
public static void main(String[] args) throws InterruptedException {
// Create a program
BProgram bprog = new SingleResourceBProgram("BPJSTicTacToe.js");
bprog.setEventSelectionStrategy(new PrioritizedBSyncEventSelectionStrategy());
bprog.setDaemonMode(true);
String simulatedPlayer = "bp.registerBThread('XMoves', function() {\n" + "while (true) {\n" + "bsync({ request:[ X(0, 0), X(0, 1), X(0, 2), X(1, 0), \n" + "X(1, 1), X(1, 2), X(2, 0), X(2, 1), X(2, 2) ] }, 10); \n" + "}\n" + "});\n";
// This bthread models the requirement that X never wins.
String xCantWinRequirementBThread = "bp.registerBThread( \"req:NoXWin\", function(){\n" + " bp.sync({waitFor:StaticEvents.XWin});\n" + " bp.ASSERT(false, \"Found a trace where X wins.\");\n" + "});";
bprog.appendSource(simulatedPlayer);
bprog.appendSource(xCantWinRequirementBThread);
// bprog.appendSource(infiBThread);
try {
DfsBProgramVerifier vfr = new DfsBProgramVerifier();
vfr.setDetectDeadlocks(false);
vfr.setMaxTraceLength(70);
// vfr.setDebugMode(true);
vfr.setVisitedNodeStore(new BProgramStateVisitedStateStore(false));
vfr.setProgressListener(new BriefPrintDfsVerifierListener());
final VerificationResult res = vfr.verify(bprog);
if (res.isCounterExampleFound()) {
System.out.println("Found a counterexample");
res.getCounterExampleTrace().forEach(nd -> System.out.println(" " + nd.getLastEvent()));
} else {
System.out.println("No counterexample found.");
}
System.out.printf("Scanned %,d states\n", res.getScannedStatesCount());
System.out.printf("Time: %,d milliseconds\n", res.getTimeMillies());
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
System.out.println("end of run");
}
Aggregations