@contextmanager def timing(activity): t0 = time.time() yield print('\n' + ('=' * 80) + '\nCompleted ' + activity + ' in ' + str(time.time() - t0) + ' secs' + '\n' + ('=' * 80)) if __name__ == '__main__': logging.basicConfig(filename='ktadvance_juliet.log', level=logging.WARNING) args = parse() testpath = UF.get_juliet_testpath(args.path) cpath = os.path.abspath(testpath) if not os.path.isdir(cpath): print(UP.cpath_not_found_err_msg(cpath)) exit() sempath = os.path.join(cpath, 'semantics') if (not os.path.isdir(sempath)): print( 'No semantics directory found. Please create primary proof obligations first.' ) exit(0) # check linkinfo globaldefs = os.path.join(
print('~' * 80) print('Juliet test cases: ') print('~' * 80) print('\nPrimary proof obligations\n') rhlen = max(len(x) for x in JTC.testcases) allppos = [] allspos = [] sumppos = {} sumspos = {} for cwe in sorted(JTC.testcases): for t in JTC.testcases[cwe]: t = os.path.join(cwe, t) cpath = UF.get_juliet_testpath(t) sempath = os.path.join(cpath, 'semantics') if not os.path.isdir(sempath): missing.append(t) continue capp = CApplication(sempath) ppos = capp.get_ppos() spos = capp.get_spos() allppos.extend(ppos) allspos.extend(spos) sumppos[t] = RP.get_method_count(ppos) sumspos[t] = RP.get_method_count(spos) print( RP.row_method_count_tostring(sumppos, perc=True,