def run_tests(ebin, utestEbin): fname = "logfile" cmd = " ".join(["erl", "-noshell", "-pa", ebin, "-pa", utestEbin, "-eval", "\"cuter_tests_lib:sample_trace_file(\\\"{}\\\")\"".format(fname), "-s", "init", "stop"]) subp.call(cmd, shell=True) result = solve(fname, 3, False, False, False) assert len(result), "Solver error" assert cc.is_sat(result[0]), "Not SAT status" assert "[x2 = int(44), x1 = int(1)]" == result[1], "Wrong model" try: os.remove(fname) except OSError: pass
def solve(fname, n, printConstraints, withSmt, withPrint): # Do the initializations. cglb.init() erlSolver = cz3.ErlangZ3() if not withSmt else cSMT.ErlangSMT() # Load the trace. r = cIO.JsonReader(fname, n) for entry, rev in r: if printConstraints: cpt.print_cmd(entry, rev) if cc.is_interpretable(entry): erlSolver.command_toSolver(entry, rev) # Load the axioms to the solver. erlSolver.add_axioms() # Solve the model. if withPrint: print "Solving the model ...", slv = erlSolver.solve() if withPrint: print slv if cc.is_sat(slv): m = erlSolver.model if withPrint: print m return (slv, str(m)) return slv
def solve(fname, n, printConstraints, withPrint): # Do the initializations. cglb.init() erlSolver = cSMT.ErlangSMT(1) # Load the trace. r = cIO.JsonReader(fname, n) for entry, rev in r: if printConstraints: cpt.print_cmd(entry, rev) if cc.is_interpretable(entry): erlSolver.command_toSolver(entry, rev) # Load the axioms to the solver. erlSolver.add_axioms() # Solve the model. if withPrint: print("Solving the model ...", ) slv = erlSolver.solve() if withPrint: print(slv) if cc.is_sat(slv): m = erlSolver.encode_model() if withPrint: print(m) values = [e.value.value for e in m.model.entries] return (slv, values) return slv