Beispiel #1
0
def print_stats():
    """Print current stats"""
    stats_to_print = stats.get()
    print("HIGHSCORES")
    print("----------")
    for each in stats_to_print["highscores"]:
        print("\t%s: %s" % (each, stats_to_print["highscores"][each]))
    print("\nRECORD")
    print("------")
    print(stats.get_record())
    print("\nHIGHEST NUMBER REACHED")
    print("----------------------")
    print(stats.get()["largest number reached"])
Beispiel #2
0
def jayhorn(build_dir, args):
    cmd = ["java", "-jar", JAYHORN, "-t", "60", "-stats", "-j", build_dir, '-mem-prec', "{}".format(args.mem)]
    if args.inline:
        cmd.extend(['-inline_size', '30', '-inline_count', '3'])
    cmd_spacer = cmd + ['-solver', 'spacer']
    bench_stats.start('JayHorn-Eldarica-Time')
    eldarica_result = run_with_timeout("jayhorn-eldarica_{}_{}".format(args.mem, args.inline), cmd, args.timeout)
    bench_stats.stop('JayHorn-Eldarica-Time')
    bench_stats.start('JayHorn-Spacer-Time')
    spacer_result = run_with_timeout("jayhorn-spacer_{}_{}".format(args.mem, args.inline), cmd_spacer, args.timeout)
    bench_stats.stop('JayHorn-Spacer-Time')
    eldarica_time = bench_stats.get("JayHorn-Eldarica-Time")
    spacer_time = bench_stats.get("JayHorn-Spacer-Time")
    return eldarica_result, spacer_result, str(eldarica_time), str(spacer_time)
Beispiel #3
0
def ajax_stats(request):
    callback = request.str_params['callback'] if 'callback' in request.str_params else None
    servers = request.str_params['servers'] if 'servers' in request.str_params else None
    qsort = request.str_params['qsort'] if 'qsort' in request.str_params else None
    qreverse = int(request.str_params['qreverse']) if 'qreverse' in request.str_params else 0
    qfilter = request.str_params['qfilter'] if 'qfilter' in request.str_params else None

    data = {}
    if servers:
        servers = servers.split(',')
        _stats = stats.get(servers)

        if _stats is not None:
            data = dict([
                ('servers', []),
                ('queues', [])
            ])

            for server, _data in _stats.iteritems():
                data['servers'].append({'server': server, 'stats': _data['server']})
                data['queues'].extend([dict(server=server, queue=queue, **qstats) for queue, qstats in _data['queues'].iteritems() if queue_filter(qfilter, queue, qstats)])

            data['servers'].sort(cmp=lambda x,y: cmp(x['server'].lower(), y['server'].lower()))
            data['queues'].sort(key=QUEUE_SORT['server'])
            data['queues'].sort(key=QUEUE_SORT[qsort] if qsort in QUEUE_SORT else QUEUE_SORT['name'], reverse=qreverse)

    return dream.JSONPResponse(callback=callback, body=data)
Beispiel #4
0
 def parallelRun(self, smt2_file):
     """
     Job spanner
     """
     ctx = z3.Context()
     fp = z3.Fixedpoint(ctx=ctx)
     jobs = []
     with stats.timer('Parse'):
         self.log.info('Parsing  ... ' + str(smt2_file))
         queries = fp.parse_file(smt2_file)
         stats.stop('Parse')
         self.log.info("Parsing time ... " + str(stats.get('Parse')) +
                       " ms")
         n_function = len(queries)
         n_query = n_function if self.args.func < 0 or self.args.func > n_function else self.args.func
         self.log.info("Number of functions ...  " + str(n_function))
         self.log.info("Number of jobs ... " + str(n_query))
         all_results = ""
         pool_jobs = Pool(processes=n_query)
         try:
             for q in range(n_query):
                 query = queries[q]
                 function_name = self.getFunctionName(query)
                 self.log.info("Checking feasibility of ...  " +
                               str(function_name))
                 #job_result = pool_jobs.apply_async(jobStarter, (self.args, qi, smt2_file, ), callback=self.onReturn)
                 job_result = pool_jobs.apply_async(jobStarter, (
                     self.args,
                     q,
                     smt2_file,
                 ))
                 job_result.wait(timeout=self.args.timeout)
                 if job_result.ready():
                     out = ""
                     try:
                         out = job_result.get()
                         if bench: print out
                     except Exception as e:
                         print str(e)
                         continue
                     all_results += out + "\n-----------------------\n"
                 else:
                     out = out_message % (function_name, "TIMEOUT", "", "",
                                          "", "", "")
                     out = bcolors.WARNING + out + bcolors.ENDC
                     if bench: print out
                     all_results += out + "\n------- ----------------\n"
             pool_jobs.close()
             pool_jobs.terminate()
             pool_jobs.join()
             if self.args.save:
                 f_name = ntpath.basename(smt2_file) + "_feas.txt"
                 with open(f_name, "w") as f:
                     f.write(all_results)
             else:
                 print "\n\t ========= SUMMARY SEAHORN INCONSISTENCY CHECKS   ========"
                 print all_results
         except Exception as e:
             self.log.exception(str(e))
Beispiel #5
0
    def __init__(self, username='', password='', get_dialogs_interval=60):

        self.delay_on_reply = config.get('vkbot_timing.delay_on_reply', 'i')
        self.chars_per_second = config.get('vkbot_timing.chars_per_second',
                                           'i')
        self.same_user_interval = config.get('vkbot_timing.same_user_interval',
                                             'i')
        self.same_conf_interval = config.get('vkbot_timing.same_conf_interval',
                                             'i')
        self.forget_interval = config.get('vkbot_timing.forget_interval', 'i')
        self.delay_on_first_reply = config.get(
            'vkbot_timing.delay_on_first_reply', 'i')
        self.stats_dialog_count = config.get('stats.dialog_count', 'i')
        self.no_leave_conf = config.get('vkbot.no_leave_conf', 'b')

        self.api = vkapi.VkApi(username,
                               password,
                               ignored_errors=ignored_errors,
                               timeout=config.get(
                                   'vkbot_timing.default_timeout', 'i'),
                               token_file=accounts.getFile('token.txt'),
                               log_file=accounts.getFile('inf.log')
                               if args.args['logging'] else '',
                               captcha_handler=createCaptchaHandler())
        stats.update('logging', bool(self.api.log_file))
        # hi java
        self.users = UserCache(
            self.api, self.fields + ',' +
            FriendController.requiredFields(_getFriendControllerParams()),
            config.get('cache.user_invalidate_interval', 'i'))
        self.confs = ConfCache(
            self.api, config.get('cache.conf_invalidate_interval', 'i'))
        self.vars = json.load(open('data/defaultvars.json', encoding='utf-8'))
        self.vars['default_bf'] = self.vars['bf']['id']
        self.initSelf(True)
        self.guid = int(time.time() * 5)
        self.last_viewed_comment = stats.get('last_comment', 0)
        self.good_conf = {}
        self.tm = ThreadManager()
        self.last_message = MessageCache()
        if os.path.isfile(accounts.getFile('msgdump.json')):
            try:
                data = json.load(open(accounts.getFile('msgdump.json')))
                self.last_message.load(data['cache'])
                self.api.longpoll = data['longpoll']
            except json.JSONDecodeError:
                logging.warning('Failed to load messages')
            os.remove(accounts.getFile('msgdump.json'))
        else:
            logging.info('Message dump does not exist')
        self.bad_conf_title = lambda s: False
        self.admin = None
        self.banned_list = []
        self.message_lock = threading.Lock()
        self.banned = set()
        self.receiver = MessageReceiver(self.api, get_dialogs_interval)
        self.receiver.longpoll_callback = self.longpollCallback
Beispiel #6
0
def jayhorn(build_dir, args):
    cmd = [
        "java", "-jar", JAYHORN, "-t", "60", "-stats", "-j", build_dir,
        '-mem-prec', "{}".format(args.mem)
    ]
    if args.inline:
        cmd.extend(['-inline_size', '30', '-inline_count', '3'])
    cmd_spacer = cmd + ['-solver', 'spacer']
    bench_stats.start('JayHorn-Eldarica-Time')
    eldarica_result = run_with_timeout(
        "jayhorn-eldarica_{}_{}".format(args.mem, args.inline), cmd,
        args.timeout)
    bench_stats.stop('JayHorn-Eldarica-Time')
    bench_stats.start('JayHorn-Spacer-Time')
    spacer_result = run_with_timeout(
        "jayhorn-spacer_{}_{}".format(args.mem, args.inline), cmd_spacer,
        args.timeout)
    bench_stats.stop('JayHorn-Spacer-Time')
    eldarica_time = bench_stats.get("JayHorn-Eldarica-Time")
    spacer_time = bench_stats.get("JayHorn-Spacer-Time")
    return eldarica_result, spacer_result, str(eldarica_time), str(spacer_time)
Beispiel #7
0
 def parallelRun(self, smt2_file):
     """
     Job spanner
     """
     ctx = z3.Context ()
     fp = z3.Fixedpoint (ctx=ctx)
     jobs = []
     with stats.timer ('Parse'):
         self.log.info('Parsing  ... ' + str(smt2_file))
         queries = fp.parse_file (smt2_file)
         stats.stop('Parse')
         self.log.info("Parsing time ... " + str(stats.get('Parse')) + " ms")
         n_function = len(queries)
         n_query = n_function if self.args.func < 0 or self.args.func > n_function else self.args.func
         self.log.info("Number of functions ...  " + str(n_function))
         self.log.info("Number of jobs ... " + str(n_query))
         all_results = ""
         pool_jobs = Pool(processes=n_query)
         try:
             for q in range(n_query):
                 query = queries[q]
                 function_name  = self.getFunctionName(query)
                 self.log.info("Checking feasibility of ...  " + str(function_name))
                 #job_result = pool_jobs.apply_async(jobStarter, (self.args, qi, smt2_file, ), callback=self.onReturn)
                 job_result = pool_jobs.apply_async(jobStarter, (self.args, q, smt2_file, ))
                 job_result.wait(timeout=self.args.timeout)
                 if job_result.ready():
                     out = ""
                     try:
                         out = job_result.get()
                         if bench: print out
                     except Exception as e:
                         print str(e)
                         continue
                     all_results += out + "\n-----------------------\n"
                 else:
                     out = out_message % (function_name, "TIMEOUT", "", "", "", "", "")
                     out = bcolors.WARNING + out + bcolors.ENDC
                     if bench: print out
                     all_results += out + "\n------- ----------------\n"
             pool_jobs.close()
             pool_jobs.terminate()
             pool_jobs.join()
             if self.args.save:
                 f_name = ntpath.basename(smt2_file)+"_feas.txt"
                 with open (f_name, "w") as f:
                     f.write(all_results)
             else:
                 print "\n\t ========= SUMMARY SEAHORN INCONSISTENCY CHECKS   ========"
                 print all_results
         except Exception as e:
             self.log.exception(str(e))
Beispiel #8
0
 def singleRun(self, smt2_file):
     """
     Single run
     """
     ctx = z3.Context()
     fp = z3.Fixedpoint(ctx=ctx)
     with stats.timer('Parse'):
         self.log.info('Parsing  ... ' + str(smt2_file))
         queries = fp.parse_file(smt2_file)
         stats.stop('Parse')
         self.log.info("Parsing time ... " + str(stats.get('Parse')) +
                       " ms")
         n_function = len(queries)
         n_query = n_function if self.args.func < 0 or self.args.func > n_function else self.args.func
         self.log.info("Number of functions ...  " + str(n_function))
         self.log.info("Number of jobs ... " + str(n_query))
         all_results = ""
         try:
             for q in range(n_query):
                 query = queries[q]
                 function_name = self.getFunctionName(query)
                 self.log.info("Checking feasibility of ...  " +
                               str(function_name))
                 out = ""
                 try:
                     p = multiprocessing.Process(target=checkFeas,
                                                 args=(
                                                     self.args,
                                                     q,
                                                     smt2_file,
                                                 ))
                     p.start()
                     p.join(self.args.timeout)
                     if p.is_alive():
                         out = out_message % (function_name, "TIMEOUT", "",
                                              "", "", "", "")
                         out = bcolors.WARNING + out + bcolors.ENDC
                         p.terminate()
                         p.join()
                 except Exception as e:
                     self.log.exception(str(e))
                     continue
                     all_results += out + "\n-----------------------\n"
             if self.args.save:
                 f_name = ntpath.basename(smt2_file) + "_feas.txt"
                 with open(f_name, "w") as f:
                     f.write(all_results)
         except Exception as e:
             self.log.exception(str(e))
Beispiel #9
0
 def singleRun(self, smt2_file):
     """
     Single run
     """
     ctx = z3.Context ()
     fp = z3.Fixedpoint (ctx=ctx)
     with stats.timer ('Parse'):
         self.log.info('Parsing  ... ' + str(smt2_file))
         queries = fp.parse_file (smt2_file)
         stats.stop('Parse')
         self.log.info("Parsing time ... " + str(stats.get('Parse')) + " ms")
         n_function = len(queries)
         n_query = n_function if self.args.func < 0 or self.args.func > n_function else self.args.func
         self.log.info("Number of functions ...  " + str(n_function))
         self.log.info("Number of jobs ... " + str(n_query))
         all_results = ""
         try:
             for q in range(n_query):
                 query = queries[q]
                 function_name  = self.getFunctionName(query)
                 self.log.info("Checking feasibility of ...  " + str(function_name))
                 out = ""
                 try:
                     p = multiprocessing.Process(target=checkFeas, args=(self.args, q, smt2_file, ))
                     p.start()
                     p.join(self.args.timeout)
                     if p.is_alive():
                         out = out_message % (function_name, "TIMEOUT", "", "", "", "", "")
                         out = bcolors.WARNING + out + bcolors.ENDC
                         p.terminate()
                         p.join()
                 except Exception as e:
                     self.log.exception(str(e))
                     continue
                     all_results += out + "\n-----------------------\n"
             if self.args.save:
                 f_name = ntpath.basename(smt2_file)+"_feas.txt"
                 with open (f_name, "w") as f:
                     f.write(all_results)
         except Exception as e:
             self.log.exception(str(e))
Beispiel #10
0
 def __init__(self, username='', password=''):
     self.api = vkapi.VkApi(username, password, ignored_errors=ignored_errors, timeout=config.get('vkbot.default_timeout', 'i'), token_file=accounts.getFile('token.txt'),
                            log_file=accounts.getFile('inf.log') if args.args['logging'] else '', captcha_handler=captcha.CaptchaHandler())
     self.api.initLongpoll()
     self.users = UserCache(self.api, 'sex,crop_photo,blacklisted,blacklisted_by_me,' + check_friend.fields)
     self.confs = ConfCache(self.api)
     self.vars = json.load(open('data/defaultvars.json', encoding='utf-8'))
     self.initSelf(True)
     self.guid = int(time.time() * 5)
     self.last_viewed_comment = stats.get('last_comment', 0)
     self.good_conf = {}
     self.tm = ThreadManager()
     self.last_message = MessageCache()
     self.last_message_id = 0
     self.whitelist = None
     self.whitelist_includeread = True
     self.bad_conf_title = lambda s: False
     self.admin = None
     self.banned_list = []
     self.longpoll_queue = queue.Queue()
     self.message_lock = threading.Lock()
Beispiel #11
0
    def checkFeas(self, expr_query):
        done = False  # flag to stop the feasibility checking
        rounds = 1  # counter for feasibility check
        self.ee_idx = self.ee_vars(expr_query)  #entr/exit vars
        self.log.info("EE VARS INDEX ..." + str(self.ee_idx))
        out = ""
        function_name = self.function_name
        while not done:
            with stats.timer('Query'):
                #if round == 0 else self.fp.query_from_lvl(12, expr_query)
                res = self.fp.query(expr_query)
                stats.stop('Query')
                self.query_times.append(str(stats.get('Query')))
                if bench:
                    print "Query | Round [" + str(
                        rounds) + "] | time  [" + str(
                            stats.get('Query')) + " ms]"
                if res == z3.sat:
                    msg = "ENTRY -> EXIT is FEASIBLE" if rounds == 1 else "STILL FEASIBLE: Continue checking ..."
                    self.log.info("( " + function_name + " ) " + msg)
                    self.feasible_flag |= set(self.ee_idx)
                    expr_query, path = self.cex(expr_query)
                    rounds += 1
                    if expr_query is None:
                        feas = list(self.feasible_flag)
                        infeas = ";".join(
                            [str(x) for x in list(self.non_feasible_flag)])
                        q_times = [float(x) for x in self.query_times]
                        q_average = sum(q_times) / len(q_times)
                        out += out_message % (function_name, "FEASIBLE", "",
                                              str(feas), infeas, str(rounds),
                                              str(q_average))
                        out = bcolors.OKGREEN + out + bcolors.ENDC
                        done = True
                elif res == z3.unsat:
                    inv = "\n-----------\n"
                    for p in self.preds:
                        lemmas = fp_get_cover_delta(self.fp, p)
                        inv += "\tBasic Block: " + str(p.decl())
                        inv += "\n\tInvariant: " + str(lemmas)
                        inv += "\n-----------\n"
                    inv_info = inv if self.args.inv else "(set --inv to get invariants info)"

                    if len(list(self.feasible_flag)) == self.flags:
                        self.log.info(" ( " + function_name + " ) FEASIBLE")
                        feas = list(self.feasible_flag)
                        q_times = [float(x) for x in self.query_times]
                        q_average = sum(q_times) / len(q_times)
                        out += out_message % (function_name, "FEASIBLE",
                                              inv_info, str(feas), "",
                                              str(rounds), str(q_average))
                        out = bcolors.OKGREEN + out + bcolors.ENDC
                    else:
                        msg = "EXIT is not FEASIBLE" if rounds == 1 else "INFEASIBLE BLOCK FOUND"
                        self.feasOut()
                        if rounds == 1:
                            self.feasible_flag.add(self.ee_idx[0])
                            self.non_feasible_flag.add(self.ee_idx[1])
                        self.log.info(" ( " + function_name + " ) " + msg)
                        feas, infeas = self.feasOut()
                        q_times = [float(x) for x in self.query_times]
                        q_average = sum(q_times) / len(q_times)
                        infeas_str = ";".join([str(x) for x in infeas])
                        out += out_message % (function_name, "INFEASIBLE",
                                              inv_info, str(feas), infeas_str,
                                              str(rounds), str(q_average))
                        out = bcolors.FAIL + out + bcolors.ENDC
                    done = True
                else:
                    out += out_message % (function_name, "UNKNOWN", "", "", "",
                                          "", "")
                    done = True
        return out
Beispiel #12
0
    def checkFeas(self, expr_query):
        done = False # flag to stop the feasibility checking
        rounds = 1 # counter for feasibility check
        self.ee_idx = self.ee_vars(expr_query) #entr/exit vars
        self.log.info("EE VARS INDEX ..." + str(self.ee_idx))
        out = ""
        function_name = self.function_name
        while not done:
            with stats.timer ('Query'):
                #if round == 0 else self.fp.query_from_lvl(12, expr_query)
                res = self.fp.query (expr_query)
                stats.stop('Query')
                self.query_times.append(str(stats.get('Query')))
                if bench: print "Query | Round [" + str(rounds) + "] | time  [" + str(stats.get('Query')) + " ms]"
                if res == z3.sat:
                    msg = "ENTRY -> EXIT is FEASIBLE" if rounds==1 else "STILL FEASIBLE: Continue checking ..."
                    self.log.info("( " + function_name + " ) " + msg)
                    self.feasible_flag |= set(self.ee_idx)
                    expr_query, path = self.cex(expr_query)
                    rounds += 1
                    if expr_query is None:
                        feas = list(self.feasible_flag)
                        infeas = ";".join([str(x) for x in list(self.non_feasible_flag)])
                        q_times = [float(x) for x in self.query_times]
                        q_average = sum(q_times) / len(q_times)
                        out += out_message % (function_name, "FEASIBLE", "", str(feas),  infeas, str(rounds), str(q_average))
                        out = bcolors.OKGREEN + out + bcolors.ENDC
                        done = True
                elif res == z3.unsat:
                    inv =  "\n-----------\n"
                    for p in self.preds:
                        lemmas = fp_get_cover_delta (self.fp, p)
                        inv += "\tBasic Block: " + str(p.decl())
                        inv += "\n\tInvariant: " + str(lemmas)
                        inv += "\n-----------\n"
                    inv_info = inv if self.args.inv else "(set --inv to get invariants info)"

                    if len(list(self.feasible_flag)) == self.flags:
                        self.log.info(" ( " + function_name + " ) FEASIBLE")
                        feas = list(self.feasible_flag)
                        q_times = [float(x) for x in self.query_times]
                        q_average = sum(q_times) / len(q_times)
                        out += out_message % (function_name, "FEASIBLE", inv_info, str(feas), "", str(rounds), str(q_average))
                        out = bcolors.OKGREEN + out + bcolors.ENDC
                    else:
                        msg = "EXIT is not FEASIBLE" if rounds==1 else "INFEASIBLE BLOCK FOUND"
                        self.feasOut()
                        if rounds == 1:
                            self.feasible_flag.add(self.ee_idx[0])
                            self.non_feasible_flag.add(self.ee_idx[1])
                        self.log.info(" ( " + function_name + " ) " + msg)
                        feas, infeas = self.feasOut()
                        q_times = [float(x) for x in self.query_times]
                        q_average = sum(q_times) / len(q_times)
                        infeas_str = ";".join([str(x) for x in infeas])
                        out += out_message % (function_name, "INFEASIBLE", inv_info, str(feas), infeas_str, str(rounds), str(q_average))
                        out = bcolors.FAIL + out + bcolors.ENDC
                    done = True
                else:
                    out += out_message % (function_name, "UNKNOWN", "", "", "", "", "")
                    done = True
        return out
Beispiel #13
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
Beispiel #14
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