Esempio n. 1
0
 def __init__(self, benchmark_path):
     Tool.__init__(self)
     self.benchmark_path = os.path.expanduser(benchmark_path)
     self.numbers_dict = {}
     self.errors_dict = {}
     self.total = None
     self.name = "CompCert"
Esempio n. 2
0
 def __init__(self, benchmark_path):
     Tool.__init__(self)
     self.benchmark_path = os.path.expanduser(benchmark_path)
     self.errors_dict = None
     self.numbers_dict = None
     self.name = "Valgrind + GCC"
     self.total = None
Esempio n. 3
0
    def run(self, verbose=False, log_location=None):
        output_dict = {"TP": 0, "FP": 0}
        error_code_dict = {}
        total = 0
        os.chdir(self.benchmark_path)
        for test_dir in filter(lambda x: os.path.isdir(x), os.listdir(os.getcwd())):
            os.chdir(test_dir)
            file_list = os.listdir(os.getcwd())
            folder = filter(lambda y: y.endswith(".c"), file_list)
            bar = progressbar.ProgressBar()
            Tool.print_folder(self, self.name, test_dir)
            for c_file in bar(folder):
                if "link" in c_file:
                    continue
                total += 1
                error_code = self.get_error_code(c_file)
                if error_code not in error_code_dict:
                    error_code_dict[error_code] = {"TP": set([]), "FP": set([])}
                signal.signal(signal.SIGALRM, self.signal_handler)
                signal.alarm(5)
                try:
                    command = ["ccomp", "-fstruct-passing", "-interp", "-trace", c_file]
                    subprocess.check_output(command, stderr=subprocess.STDOUT)
                except subprocess.CalledProcessError:
                    # Problem with the plugin
                    if "bad" in c_file:
                        output_dict["TP"] += 1
                        error_code_dict[error_code]["TP"].add(self.name)
                    else:
                        output_dict["FP"] += 1
                        error_code_dict[error_code]["FP"].add(self.name)
                except TimeoutException:
                    pass
                finally:
                    signal.alarm(0)
            os.chdir(self.benchmark_path)

        self.numbers_dict = output_dict
        self.errors_dict = error_code_dict
        self.total = total
Esempio n. 4
0
    def run(self, verbose=False, log_location=None):
        output_dict = {"TP": 0, "FP": 0}
        error_code_dict = {}
        total = 0
        os.chdir(self.benchmark_path)
        for dir in filter(lambda x: os.path.isdir(x), os.listdir(os.getcwd())):
            os.chdir(dir)
            Tool.print_folder(self, self.name, dir)
            file_list = os.listdir(os.getcwd())
            bar = progressbar.ProgressBar()
            for c_file in bar(filter(lambda y: y.endswith(".c"), file_list)):
                c_files = []
                exec_name = c_file.split('.')[0]
                if "link" in c_file:
                    if "link1" not in c_file:
                        continue
                    exec_name = exec_name.replace("-link1", "", )
                    c_files.append(c_file)
                    i = 2
                    while True:
                        split = c_file.split("-link1")
                        link_file_name = split[0] + "-link" + str(i) + split[1]
                        if link_file_name in file_list:
                            c_files.append(link_file_name)
                            i += 1
                            continue
                        break
                else:
                    c_files = [c_file]

                out_name = exec_name + ".out"
                total += 1
                if "-good" in c_file:
                    error_code = c_file.split("-good")[0]
                    is_bad = False
                else:
                    error_code = c_file.split("-bad")[0]
                    is_bad = True
                if error_code not in error_code_dict:
                    error_code_dict[error_code] = {"TP": set([]), "FP": set([])}
                signal.signal(signal.SIGALRM, self.signal_handler)
                signal.alarm(5)
                try:
                    command = ["clang", "-Wpedantic", "-Wall", "-Wextra", "-g", "-fsanitize=undefined",
                               "-std=c11"] + c_files + ["-o", out_name]
                    # print command
                    subprocess.check_output(command, stderr=subprocess.STDOUT)
                    mode = "runtime"
                    val_command = ["./" + out_name]
                    # print val_command
                    subprocess.check_output(val_command, stderr=subprocess.STDOUT)
                except subprocess.CalledProcessError as error:
                    if is_bad:
                        output_dict["TP"] += 1
                        error_code_dict[error_code]["TP"].add(self.name)
                    else:
                        output_dict["FP"] += 1
                        error_code_dict[error_code]["FP"].add(self.name)
                except TimeoutException:
                    pass
                finally:
                    signal.alarm(0)
            os.chdir(self.benchmark_path)
        self.numbers_dict = output_dict
        self.errors_dict = error_code_dict
        self.total = total
Esempio n. 5
0
 def cleanup(self):
     Tool.cleanup(self)
Esempio n. 6
0
 def cleanup(self):
     Tool.cleanup(self)
     self.logger.close_log()
Esempio n. 7
0
 def analyze(self):
     Tool.analyze(self)