示例#1
0
from copy import deepcopy as dc
# Internal imports

from projectLib.AnalyzerInfo import AnalyzerInfo
from ProjectConfig import *
from projectLib.Heuristic import Heuristic

# LINES GENERATION PART START
print("COMPARISON GENERATION PART START")

svace_info = AnalyzerInfo()
svace_info.load_info(info_path["svace"], info_ind=1)
juliet_info = AnalyzerInfo()
juliet_info.load_info(info_path["juliet"], info_ind=1)

comparison = Heuristic("funcs", {}).\
    compare_info_with_heuristic(dc(svace_info), dc(juliet_info))

comparison.save_comparison(comp_results_path["standard"], 5)

print("COMPARISON GENERATION PART END")
print("SVRES GENERATION PART BEGIN")

comparison.generate_svres_for_both(
    svres_gen_path["standard"],
    project_name_par=code_project_name,
    project_src_dir_par=code_project_source_path,
    ind=5)

print("SVRES GENERATION PART END")
示例#2
0
from projectTests.ProjectConfig_test import *

# REQUIRES: mining tests should be passed!
# Automatically checks if information is not lost during save/load

juliet_res_dir = project_source_dir + "/AnalyzerOutputs/juliet_output_mine.svres"
svace_res_dir = project_source_dir + "/AnalyzerOutputs/svace_output_mine.svres"

juliet_info = AnalyzerInfo()
juliet_info.mine_info("juliet", juliet_res_dir, code_project_source_path,
                      cwe_num_list, warnings_list["juliet"])

svace_info = AnalyzerInfo()
svace_info.mine_info("svace", svace_res_dir, code_project_source_path,
                     cwe_num_list, warnings_list["juliet"])

svace_info.save_info(info_path["svace"], info_ind=0)
juliet_info.save_info(info_path["juliet"], info_ind=0)

svace_info_new = AnalyzerInfo()
svace_info_new.load_info(info_path["svace"], info_ind=0)

juliet_info_new = AnalyzerInfo()
juliet_info_new.load_info(info_path["juliet"], info_ind=0)

if svace_info_new == svace_info and juliet_info_new == juliet_info:
    print("Check save/load: Pass")
else:
    print("Check save/load: Fail")

print("Test finish.")
示例#3
0
# Internal imports
from projectLib.AnalyzerInfo import AnalyzerInfo
from ProjectConfig import *
from projectLib.Heuristic import Heuristic
from projectLib.FileInfo import FileInfo
from projectLib.ErrorInfo import ErrorInfo

svace_info = AnalyzerInfo()
svace_info.load_info(info_path["svace"], 0)
juliet_info = AnalyzerInfo()
juliet_info.load_info(info_path["juliet"], 0)

path_test = "./CSourceCode/jultst_same_syntax_test_file.c"

svace_piece = FileInfo(file=path_test,
                       errors=[ErrorInfo(lines=[3], type="SIMILAR_BRANCHES")])
jul_piece = FileInfo(file=path_test,
                     errors=[ErrorInfo(lines=[5, 7], type="CWE121")])

svace_info.info.append(svace_piece)
juliet_info.info.append(jul_piece)

comparison = Heuristic(heuristic_union_list[2][0],
                       heuristic_union_list[2][1]).compare_info_with_heuristic(
                           svace_info, juliet_info)
comparison.group_comparison(type_groups["svace"],
                            type_groups["juliet"]).print_comparison()

comparison.save_comparison(comp_results_path["standard"], 5)