コード例 #1
0
ファイル: cuter_port.py プロジェクト: Baha/cuter
def decode_load_trace_file(erlport, erlz3, cmd):
    r = cIO.JsonReader(cmd["f"], cmd["e"])
    for tp, tag, x, rev in r:
        if cglb.__TTY__:
            print x
        if cc.is_interpretable(tp):
            erlz3.command_toZ3(tp, x, rev)
コード例 #2
0
def decode_load_trace_file(erlport, erlSolver, cmd):
    """
    Loads a trace file.
    """
    r = cIO.JsonReader(cmd.filename, cmd.to_constraint)
    for entry, rev in r:
        if cc.is_interpretable(entry):
            erlSolver.command_toSolver(entry, rev)
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
0
ファイル: cuter_print.py プロジェクト: ioolkos/cuter
        print(xs)
        sys.exit(1)


def usage():
    print("Usage: cuter_print.py TraceFile [ OPTIONS ]")
    print("PARAMETERS")
    print("	TraceFile		The trace file of an execution.")
    print("OPTIONS")
    print("	-t    			Shows the tag of the log entry.")
    print("	--help			Display this information.")


if __name__ == "__main__":
    shortOpts = "t"
    longOpts = ["help"]
    optlist, remainder = getopt.gnu_getopt(sys.argv[1:], shortOpts, longOpts)
    for opt, arg in optlist:
        if opt == "--help":
            usage()
            sys.exit(0)
        elif opt == "-t":
            with_tags = True
    cglb.init()
    fname = remainder[0]
    n = 0
    for entry, rev in cio.JsonReader(fname, 100000000):
        n += 1
        print_cmd(entry, rev)
    print("Total Commands:", n)
コード例 #6
0
        return "[]"
    if tp == cc.JSON_ERLTYPE_TUPLE:
        return "tuple"
    if tp == cc.JSON_ERLTYPE_TUPLEDET:
        return "{%s}" % ", ".join(map(pretty_type, d["a"]))
    if tp == cc.JSON_ERLTYPE_UNION:
        return "|".join(map(pretty_type, d["a"]))


if "tty" in sys.argv:
    sys.argv.remove("tty")
cglb.init()

fname = sys.argv[1]
n = 0
for tp, tag, json_data, rev in cio.JsonReader(fname, 100000000):
    n += 1
    #  print tp
    #  print json_data

    # Symbolic parameters
    if tp == cc.OP_PARAMS:
        pprint(["PARAMS", pretty_list(json_data["a"])], tag)
    # Symbolic parameters
    elif tp == cc.OP_SPEC:
        msg = ["SPEC"]
        for sp in json_data["a"]:
            msg.append("(%s) -> %s" % (pretty_list(sp["p"]), pretty(sp["r"])))
        pprint(msg, tag)
    # True guard constraint
    elif tp == cc.OP_GUARD_TRUE: