コード例 #1
0
 def solve(self, horn_file):
     """ Solve directly """
     self.setSolver()
     with utils.stats.timer('Parse'):
         q = self.fp.parse_file(horn_file)
     preds = utils.fp_get_preds(self.fp)
     with utils.stats.timer('Query'):
         res = self.fp.query(q[0])
         if res == z3.sat:
             utils.stat('Result', 'CEX')
         elif res == z3.unsat:
             utils.stat('Result', 'SAFE')
             self.printInv(preds)
         else:
             utils.stat('Result', 'UNK')
     stats.brunch_print()
     return
コード例 #2
0
ファイル: termination.py プロジェクト: edmcman/seahorn
def seaTerm(smt_file, rank_function):
    try:
        stat ('Result','UNKNOWN')
        stat ('Ranking_Function', rank_function)
        fp = z3.Fixedpoint()
        fp.set(engine='spacer')
        fp.set('xform.inline_eager', False)
        fp.set('xform.slice', False)
        fp.set('xform.inline_linear', False)
        fp.set('pdr.utvpi', False)
        fp.set('xform.karr', True)
        query = fp.parse_file(smt_file)
        with stats.timer('Termination'):
            if rank_function == 'max':
                piecewise(fp)
            elif rank_function == 'lex':
                lexicographic(fp)
            else:
                raise IOError('unknown ranking function template')
    except Exception as e:
        raise IOError(str(e))
    finally:
        stats.brunch_print()
コード例 #3
0
def seaTerm(smt_file, rank_function):
    try:
        stat('Result', 'UNKNOWN')
        stat('Ranking_Function', rank_function)
        fp = z3.Fixedpoint()
        fp.set(engine='spacer')
        fp.set('xform.inline_eager', False)
        fp.set('xform.slice', False)
        fp.set('xform.inline_linear', False)
        fp.set('pdr.utvpi', False)
        fp.set('xform.karr', True)
        query = fp.parse_file(smt_file)
        with stats.timer('Termination'):
            if rank_function == 'max':
                piecewise(fp)
            elif rank_function == 'lex':
                lexicographic(fp)
            else:
                raise IOError('unknown ranking function template')
    except Exception as e:
        raise IOError(str(e))
    finally:
        stats.brunch_print()
コード例 #4
0
    if args.dot_cfg: dot(pp_out)
    if args.view_cfg: dot(pp_out, True)
    #stat ('Progress', 'Crab Llvm')

    if args.asm_out_name is not None and args.asm_out_name != pp_out:
        if verbose: print 'cp {0} {1}'.format (pp_out, args.asm_out_name)
        shutil.copy2 (pp_out, args.asm_out_name)

    return 0

def killall ():
    global running_process
    if running_process != None:
        running_process.terminate ()
        running_process.kill ()
        running_process.wait ()
        running_process = None

if __name__ == '__main__':
    # unbuffered output
    sys.stdout = os.fdopen (sys.stdout.fileno (), 'w', 0)
    try:
        signal.signal (signal.SIGTERM, lambda x, y: killall ())
        sys.exit (main (sys.argv))
    except KeyboardInterrupt: pass
    finally:
        killall ()
        stats.brunch_print ()

コード例 #5
0
ファイル: inc.py プロジェクト: alx441/XSHM
            assert pp_out != in_name
            seapp(in_name, pp_out, arch=32, args=args)
            in_name = pp_out

        if args.opt_level > 0:
            opt_out = defOPTName(in_name, args.opt_level, workdir)
            llvmOpt(in_name, opt_out, args.opt_level)
            in_name = opt_out

        smt_out = defSMTName(in_name, workdir)
        seahorn_args = []
        seahorn_args.extend(['-horn-sem-lvl={0}'.format(args.track)])

        seahorn(in_name, smt_out, seahorn_args)
        in_name = smt_out

    stat('Result', 'UNKNOWN')
    feas = Feas(args)
    feas.solve(in_name)


if __name__ == '__main__':
    res = None
    try:
        main(sys.argv)
    except Exception as e:
        print str(e)
    finally:
        if bench: stats.brunch_print()
    sys.exit(res)
コード例 #6
0
    stat ('Progress', 'SMT2')

    if args.out_name is not None and args.out_name != smt_out:
        if verbose: print 'cp {0} {1}'.format (smt_out, args.out_name)
        shutil.copy2 (smt_out, args.out_name)

    if (args.run_z3):
        if args.use_z3_smt2: runZ3 (smt_out, z3_args)
        else: runSpacer (smt_out, args.engine, cpu=args.cpu)

    return 0

def killall ():
    global running_process
    if running_process != None:
        running_process.terminate ()
        running_process.kill ()
        running_process.wait ()
        running_process = None

if __name__ == '__main__':
    # unbuffered output
    sys.stdout = os.fdopen (sys.stdout.fileno (), 'w', 0)
    try:
        signal.signal (signal.SIGTERM, lambda x, y: killall ())
        sys.exit (main (sys.argv))
    except KeyboardInterrupt: pass
    finally:
        killall ()
        stats.brunch_print ()
コード例 #7
0
 def run(self):
     result = self.runJar()
     self.processFile(result)
     stats.brunch_print()
コード例 #8
0
ファイル: runner.py プロジェクト: jayhorn/cav_experiments
 def run(self):
     result = self.runJar()
     self.processFile(result)
     stats.brunch_print()
コード例 #9
0
ファイル: inc.py プロジェクト: edmcman/seahorn
            assert pp_out != in_name
            seapp (in_name, pp_out, arch=32, args=args)
            in_name = pp_out

        if args.opt_level > 0:
            opt_out = defOPTName (in_name, args.opt_level, workdir)
            llvmOpt (in_name, opt_out, args.opt_level)
            in_name = opt_out

        smt_out = defSMTName(in_name, workdir)
        seahorn_args = []
        seahorn_args.extend (['-horn-sem-lvl={0}'.format (args.track)])

        seahorn (in_name, smt_out, seahorn_args)
        in_name = smt_out

    stat ('Result', 'UNKNOWN')
    feas = Feas(args)
    feas.solve(in_name)


if __name__ == '__main__':
    res = None
    try:
        main (sys.argv)
    except Exception as e:
        print str(e)
    finally:
        if bench: stats.brunch_print ()
    sys.exit (res)
コード例 #10
0
ファイル: runner.py プロジェクト: jayhorn/benchmarks
def runCpa(args, dr):
    print "--- Running CpaChecker --- "
    all_dir = [os.path.join(dr, name)for name in os.listdir(dr) if os.path.isdir(os.path.join(dr, name)) ]
    all_build_dir = list()
    raw_results = dict()
    cpa_out = "cpachecker_out"
    if not os.path.exists(cpa_out):
        os.mkdir(cpa_out)
    if args.mp:
        for d in sorted(all_dir):
            if debug: print "Benchmark:\t " + str(d)
            tmp = d.split("/")
            bench = tmp[len(tmp)-1]
            outputpath = cpa_out+os.sep+bench
            cmd = [CPA, "-valueAnalysis-java-with-RTT", "-cp", d, "-outputpath", outputpath, "Main"]
            result = ""
            try:
                bench_stats.start('Cpa-Time')
                result = run_with_timeout('cpa', cmd, args.timeout)
                bench_stats.stop('Cpa-Time')
                bench_stats.brunch_print()
                res = ""
                if result:
                    for line in result.split("\n"):
                        if "Verification result" in line:
                            res = "UNSAFE" if "FALSE" in line else "SAFE"
                else:
                    res = "UNKNOWN"
                raw_results.update({d:{"result":res,
                                       "total-time": str(bench_stats.get('Cpa-Time')),
                                       "logs": (outputpath + os.sep + "Report.html")}})
            except Exception as e:
                raw_results.update({prog: {"result":"UNKNOWN",
                                           "total-time":"",
                                           "logs": result}})
    else:
        for d in sorted(all_dir):
            if debug: print "Benchmark:\t " + str(d)
            tmp = d.split("/")
            bench = tmp[len(tmp)-1]
            java_prog = glob.glob(os.path.abspath(d) + os.sep + "*.java")
            for prog in sorted(java_prog):
	        print "Java file: " + str(prog)
                build_dir = os.path.splitext(prog)[0]
                build_dir = os.path.dirname(build_dir)
                bench_name = os.path.basename(prog).split(".java")[0]
                outputpath =  cpa_out+os.sep+bench_name
                cmd = [CPA, "-valueAnalysis-java-with-RTT", "-cp", build_dir, "-outputpath",outputpath, bench_name]
                result = ""
                try:
                    bench_stats.start('Cpa-Time')
                    result = run_with_timeout('cpa', cmd, args.timeout)
                    bench_stats.stop('Cpa-Time')
                    res = ""
                    if result:
                        for line in result.split("\n"):
                            if "Verification result" in line:
                                res = "UNSAFE" if "FALSE" in line else "SAFE"
                    else:
                         res = "UNKNOWN"
                    raw_results.update({bench_name:{ "result":res,
                                                     "total-time": str(bench_stats.get('Cpa-Time')),
                                                     "logs":(outputpath + os.sep + "Report.html")}})
                except Exception as e:
                    raw_results.update({prog: {"result":"UNKNOWN",
                                               "total-time":str(bench_stats.get('Cpa-Time')),
                                               "logs": result}})

    stats = cpaAnalysis(raw_results)
    return stats
コード例 #11
0
def runCpa(args, dr):
    print "--- Running CpaChecker --- "
    all_dir = [
        os.path.join(dr, name) for name in os.listdir(dr)
        if os.path.isdir(os.path.join(dr, name))
    ]
    all_build_dir = list()
    raw_results = dict()
    cpa_out = "cpachecker_out"
    if not os.path.exists(cpa_out):
        os.mkdir(cpa_out)
    if args.mp:
        for d in sorted(all_dir):
            if debug: print "Benchmark:\t " + str(d)
            tmp = d.split("/")
            bench = tmp[len(tmp) - 1]
            outputpath = cpa_out + os.sep + bench
            cmd = [
                CPA, "-valueAnalysis-java-with-RTT", "-cp", d, "-outputpath",
                outputpath, "Main"
            ]
            result = ""
            try:
                bench_stats.start('Cpa-Time')
                result = run_with_timeout('cpa', cmd, args.timeout)
                bench_stats.stop('Cpa-Time')
                bench_stats.brunch_print()
                res = ""
                if result:
                    for line in result.split("\n"):
                        if "Verification result" in line:
                            res = "UNSAFE" if "FALSE" in line else "SAFE"
                else:
                    res = "UNKNOWN"
                raw_results.update({
                    d: {
                        "result": res,
                        "total-time": str(bench_stats.get('Cpa-Time')),
                        "logs": (outputpath + os.sep + "Report.html")
                    }
                })
            except Exception as e:
                raw_results.update({
                    prog: {
                        "result": "UNKNOWN",
                        "total-time": "",
                        "logs": result
                    }
                })
    else:
        for d in sorted(all_dir):
            if debug: print "Benchmark:\t " + str(d)
            tmp = d.split("/")
            bench = tmp[len(tmp) - 1]
            java_prog = glob.glob(os.path.abspath(d) + os.sep + "*.java")
            for prog in sorted(java_prog):
                print "Java file: " + str(prog)
                build_dir = os.path.splitext(prog)[0]
                build_dir = os.path.dirname(build_dir)
                bench_name = os.path.basename(prog).split(".java")[0]
                outputpath = cpa_out + os.sep + bench_name
                cmd = [
                    CPA, "-valueAnalysis-java-with-RTT", "-cp", build_dir,
                    "-outputpath", outputpath, bench_name
                ]
                result = ""
                try:
                    bench_stats.start('Cpa-Time')
                    result = run_with_timeout('cpa', cmd, args.timeout)
                    bench_stats.stop('Cpa-Time')
                    res = ""
                    if result:
                        for line in result.split("\n"):
                            if "Verification result" in line:
                                res = "UNSAFE" if "FALSE" in line else "SAFE"
                    else:
                        res = "UNKNOWN"
                    raw_results.update({
                        bench_name: {
                            "result": res,
                            "total-time": str(bench_stats.get('Cpa-Time')),
                            "logs": (outputpath + os.sep + "Report.html")
                        }
                    })
                except Exception as e:
                    raw_results.update({
                        prog: {
                            "result": "UNKNOWN",
                            "total-time": str(bench_stats.get('Cpa-Time')),
                            "logs": result
                        }
                    })

    stats = cpaAnalysis(raw_results)
    return stats