当前位置: 首页>>代码示例>>Python>>正文


Python Logger.close_log方法代码示例

本文整理汇总了Python中utils.logger.Logger.close_log方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.close_log方法的具体用法?Python Logger.close_log怎么用?Python Logger.close_log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.logger.Logger的用法示例。


在下文中一共展示了Logger.close_log方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_name

# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import close_log [as 别名]
class UBSan:
    def get_name(self):
        return self.name


    def __init__(self, benchmark_path, log_file_path):
        self.pipeline = MakePipeline(benchmark_path)
        self.name = "UBSan"
        self.logger = Logger(log_file_path, self.name)
        self.output_dict = {}
        self.tp_set = set([])
        self.fp_set = set([])
        self.neg_count = 0
        os.chdir(os.path.expanduser(benchmark_path))

    def run(self):
        self.pipeline.build_benchmark(CC="clang", CFLAGS="-g -fsanitize=undefined -fsanitize=integer", LD="clang")
        self.pipeline.run_bechmark(self, [], 2)
        return self.output_dict

    def get_output_dict(self):
        return self.output_dict

    def get_tp_set(self):
        print len(self.tp_set)
        return self.tp_set

    def get_fp_set(self):
        print len(self.fp_set)
        return self.fp_set

    def analyze_output(self, exit_code, stdout, stderr, cur_dir, i, j):
        if len(stderr) > 0:
            print(stderr)
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        if "runtime error" in (stdout + stderr).lower():
            if "w_Defects" in cur_dir:
                self.output_dict[i]["TP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "TP")
                self.tp_set.add((i, j))
            else:
                self.output_dict[i]["FP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "FP")
                self.fp_set.add((i, j))
        else:
            self.logger.log_output(stdout, i, cur_dir, j, "NEG")
            self.neg_count += 1

    def analyze_timeout(self, cur_dir, i, j):
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        self.logger.log_output("", i, cur_dir, j, "NEG")
        self.neg_count += 1

    def cleanup(self):
        self.pipeline.clean_benchmark()
        self.logger.close_log()
开发者ID:osamagid,项目名称:evaluation,代码行数:62,代码来源:ub_san.py

示例2: get_name

# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import close_log [as 别名]
class Valgrind:
    def get_name(self):
        return self.name


    def __init__(self, benchmark_path, log_file_path):
        self.pipeline = MakePipeline(benchmark_path)
        self.name = "Valgrind"
        self.logger = Logger(log_file_path, self.name)
        self.output_dict = {}
        self.tp_set = set([])
        self.fp_set = set([])
        self.neg_count = 0
        os.chdir(os.path.expanduser(benchmark_path))

    def run(self):
        self.pipeline.build_benchmark(CC="gcc", CFLAGS="", LD="gcc")
        self.pipeline.run_bechmark(self, ["valgrind", "--error-exitcode=10"], 6)
        return self.output_dict

    def get_output_dict(self):
        return self.output_dict

    def get_tp_set(self):
        print len(self.tp_set)
        return self.tp_set

    def get_fp_set(self):
        print len(self.fp_set)
        return self.fp_set

    def analyze_output(self, exit_code, stdout, stderr, cur_dir, i, j):
        print(stderr)
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        if exit_code != 0:
            if "w_Defects" in cur_dir:
                self.output_dict[i]["TP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "TP")
                self.tp_set.add((i, j))
            else:
                self.output_dict[i]["FP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "FP")
                self.fp_set.add((i, j))
        else:
            self.logger.log_output(stdout, i, cur_dir, j, "NEG")

    def analyze_timeout(self, cur_dir, i, j):
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        self.logger.log_output("", i, cur_dir, j, "NEG")

    def cleanup(self):
        self.pipeline.clean_benchmark()
        self.logger.close_log()
开发者ID:osamagid,项目名称:evaluation,代码行数:59,代码来源:valgrind.py

示例3: get_name

# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import close_log [as 别名]
class TSan:
    def get_name(self):
        return self.name

    def build(self):
        if "Makefile" in os.listdir(os.getcwd()):
            subprocess.check_call(["make", "clean"])
        subprocess.check_call(["autoreconf", "--install"])
        subprocess.check_call(["automake"])
        subprocess.check_call(["./configure", "CFLAGS=-g"])
        subprocess.check_call(["make"], stderr=subprocess.STDOUT)

    def __init__(self, benchmark_path, log_file_path):
        self.pipeline = MakePipeline(benchmark_path)
        self.name = "TSan"
        self.logger = Logger(log_file_path, self.name)
        self.output_dict = {}
        self.tp_set = set([])
        self.fp_set = set([])
        self.neg_count = 0
        os.chdir(os.path.expanduser(benchmark_path))

    def run(self):
        self.pipeline.build_benchmark(CC="clang", CFLAGS="-g -fsanitize=thread", LD="clang")
        self.pipeline.run_bechmark(self, [], 2)
        return self.output_dict

    def get_output_dict(self):
        return self.output_dict

    def get_tp_set(self):
        print len(self.tp_set)
        return self.tp_set

    def get_fp_set(self):
        print len(self.fp_set)
        return self.fp_set

    def analyze_output(self, exit_code, stdout, stderr, cur_dir, i, j):
        if len(stderr) > 0:
            print(stderr)
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        if "ThreadSanitizer: reported" in stderr:
            if "w_Defects" in cur_dir:
                self.output_dict[i]["TP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "TP")
                self.tp_set.add((i, j))
            else:
                self.output_dict[i]["FP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "FP")
                self.fp_set.add((i, j))
        else:
            self.logger.log_output(stdout, i, cur_dir, j, "NEG")
            self.neg_count += 1

    def analyze_timeout(self, cur_dir, i, j):
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        self.logger.log_output("", i, cur_dir, j, "NEG")
        self.neg_count += 1

    def cleanup(self):
        print "Total Count = " + str(self.neg_count + len(self.tp_set) + len(self.fp_set))
        Tool.cleanup(self)
        self.logger.close_log()
开发者ID:msaxena2,项目名称:evaluation,代码行数:70,代码来源:tsan.py

示例4: FramaC

# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import close_log [as 别名]

#.........这里部分代码省略.........
            if file_name in line and "WARNING" in line.upper():
                if "Neither code nor specification" in line:
                    continue
                # Simple condition for an alarm in the file
                return True
        return False


    def sanitize_header_file(self, original_header_path, new_header_path, framac_include_path, header_file_name):
        allowed_list = map(lambda z : z.split('/')[-1], [y for x in os.walk(framac_include_path) for y in glob(os.path.join(x[0], '*.h'))])
        pattern = re.compile('#include\ *<(.*)>')
        if not os.path.exists(new_header_path):
            os.mkdir(new_header_path)
        with open(os.path.join(new_header_path, header_file_name), 'w+') as temp_file:
            with open(os.path.join(original_header_path, header_file_name), 'r') as cur_file:
                for line in cur_file:
                    match = re.match(pattern, line)
                    if match:
                        if match.group(1) not in allowed_list:
                            continue
                    temp_file.write(line)


    def get_framac_command(self, cur_dir, file_prefix, temp_dir_name, vflag):
        cur_path = os.path.join(self.benchmark_path, cur_dir)
        temp_path = os.path.join(cur_path, temp_dir_name)
        if not os.path.exists(temp_path):
            os.mkdir(temp_path)

        relevant_file_path = os.path.join(cur_path, file_prefix + ".c")
        bootstrap_file_path = os.path.join(temp_path, file_prefix + "-temp.c")
        utils.external_info.bootstrap_file(relevant_file_path, bootstrap_file_path, vflag)
        return ["frama-c", "-val", bootstrap_file_path]

    def run(self):
        relevant_dirs = ["01.w_Defects", "02.wo_Defects"]
        output_dict = {}

        for cur_dir in relevant_dirs:
            spec_dict = self.info.get_spec_dict()
            mapping_dict = self.info.get_file_mapping()
            for i in range(1, len(spec_dict.keys()) + 1):
                if i not in output_dict:
                    output_dict[i] = {"count": spec_dict[i]["actual_count"], "TP": 0, "FP": 0}
                if (i, -1) in self.info.get_ignore_list():
                    continue
                file_prefix = mapping_dict[i]
                print self.name + " being tested on folder " + cur_dir + " and file " + file_prefix
                # bar = progressbar.ProgressBar(redirect_stdout=True)
                verdict = False
                output = ""
                for j in range(1, spec_dict[i]["count"]):
                    if (i, j) in self.info.get_ignore_list():
                        continue
                    vflag = str('%03d' % j)
                    try:
                        framac_command = self.get_framac_command(cur_dir, file_prefix, "framac_dir", vflag)
                        print " ".join(framac_command)
                        if len(framac_command) != 0:
                            signal.signal(signal.SIGALRM, self.signal_handler)
                            #signal.alarm(10)
                            output = subprocess.check_output(framac_command, stderr=subprocess.STDOUT)
                            print output
                            verdict = self.analyze_output(output, file_prefix)
                            if verdict:
                                if "w_Defects" in cur_dir:
                                    output_dict[i]["TP"] += 1
                                else:
                                    output_dict[i]["FP"] += 1

                    except subprocess.CalledProcessError as e:
                        signal.alarm(0)
                        #error with the plugin
                        continue

                    except TimeoutException:
                        continue
                    finally:
                        if verdict:
                            self.logger.log_output(output, file_prefix + ".c", cur_dir, str(j), "TP")
                        if not verdict:
                            self.logger.log_output(output, file_prefix + ".c", cur_dir, str(j), "NEG")
                        signal.alarm(0)
        return output_dict

    def get_name(self):
        return self.name

    def __init__(self, benchmark_path, log_path):
        self.info = Info()
        self.benchmark_path = benchmark_path
        self.name = "framac"
        self.logger = Logger(log_path, self.name)

    def analyze(self):
        Tool.analyze(self)

    def cleanup(self):
        Tool.cleanup(self)
        self.logger.close_log()
开发者ID:msaxena2,项目名称:autobench,代码行数:104,代码来源:frama_c.py

示例5: analyze_output

# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import close_log [as 别名]
class FramaC:


    def analyze_output(self, output, file_name):
        print output
        for line in output.split('\n'):
            if file_name in line and "WARNING" in line.upper():
                if "Neither code nor specification" in line:
                    continue
                # Simple condition for an alarm in the file
                return True
        return False

    def get_framac_command(self, cur_dir, file_prefix, temp_dir_name, vflag):
        cur_path = os.path.join(self.benchmark_path, cur_dir)
        temp_path = os.path.join(cur_path, temp_dir_name)
        if not os.path.exists(temp_path):
            os.mkdir(temp_path)

        relevant_file_path = os.path.join(cur_path, file_prefix + ".c")
        bootstrap_file_path = os.path.join(temp_path, file_prefix + "-temp.c")
        utils.external_info.bootstrap_file(relevant_file_path, bootstrap_file_path, vflag, "SH")
        return ["frama-c", "-val", "-machdep", "gcc_x86_64", bootstrap_file_path]

    def run(self):
        output_dict = {}

        for cur_dir in relevant_dirs:
            spec_dict = self.info.get_spec_dict()
            mapping_dict = self.info.get_file_mapping()
            for i in range(1, len(spec_dict.keys()) + 1):
                if i not in output_dict:
                    output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
                if (i, -1) in self.info.get_ignore_list():
                    continue
                file_prefix = mapping_dict[i]
                verdict = False
                output = ""
                for j in range(1, spec_dict[i]["count"] + 1):
                    if (i, j) in self.info.get_ignore_list():
                        continue
                    output_dict[i]["count"] += 1
                    vflag = str('%03d' % j)
                    framac_command = self.get_framac_command(cur_dir, file_prefix, "framac_dir", vflag)
                    print self.name + " ** " + " ".join(framac_command)
                    try:
                        if len(framac_command) != 0:
                            process = subprocess.Popen(framac_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                            process.wait(timeout=8)
                            output = process.stdout.read() + process.stderr.read()
                            verdict = self.analyze_output(output, file_prefix)
                            if verdict:
                                if "w_Defects" in cur_dir:
                                    output_dict[i]["TP"] += 1
                                    self.tp_set.add((i, j))
                                else:
                                    output_dict[i]["FP"] += 1
                                    self.fp_set.add((i, j))

                    except subprocess.TimeoutExpired:
                        self.logger.log_output(output, i, cur_dir, j, "TO")
                    finally:
                        process.kill()
                        if verdict:
                            if "w_Defects" in cur_dir:
                                self.logger.log_output(output, i, cur_dir, j, "TP")
                            else:
                                self.logger.log_output(output, i, cur_dir, j, "FP")
                        else:
                            self.logger.log_output(output, file_prefix + ".c", cur_dir, str(j), "NEG")
        return output_dict

    def get_name(self):
        return self.name

    def __init__(self, benchmark_path, log_path):
        self.info = Info()
        self.benchmark_path = benchmark_path
        self.name = "framac"
        self.logger = Logger(log_path, self.name)
        self.fp_set = set()


    def cleanup(self):
        map(lambda x: shutil.rmtree(os.path.join(os.path.join(self.benchmark_path, x), "framac_dir")), relevant_dirs)
        self.logger.close_log()

    def get_tp_set(self):
        return self.tp_set

    def get_fp_set(self):
        return self.fp_set
开发者ID:osamagid,项目名称:evaluation,代码行数:94,代码来源:frama_c.py

示例6: get_name

# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import close_log [as 别名]
class Helgrind:
    def get_name(self):
        return self.name

    def build(self):
        if "Makefile" in os.listdir(os.getcwd()):
            subprocess.check_call(["make", "clean"])
        subprocess.check_call(["autoreconf", "--install"])
        subprocess.check_call(["automake"])
        subprocess.check_call(["./configure", "CFLAGS=-g"])
        subprocess.check_call(["make"], stderr=subprocess.STDOUT)

    def __init__(self, benchmark_path, log_file_path):
        self.pipeline = MakePipeline(benchmark_path)
        self.name = "Helgrind"
        self.logger = Logger(log_file_path, self.name)
        self.output_dict = {}
        self.tp_set = set([])
        self.fp_set = set([])
        os.chdir(os.path.expanduser(benchmark_path))

    def run(self):
        self.pipeline.build_benchmark(CC="gcc", CFLAGS="-g", LD="gcc")
        self.pipeline.run_bechmark(self, ["valgrind", "--tool=helgrind", "--error-exitcode=10"], 6)
        return self.output_dict

    def get_output_dict(self):
        return self.output_dict

    def get_tp_set(self):
        return self.tp_set

    def get_fp_set(self):
        return self.fp_set

    def analyze_output(self, exit_code, stdout, stderr, cur_dir, i, j):
        print(stderr)
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        if exit_code != 0:
            if "w_Defects" in cur_dir:
                self.output_dict[i]["TP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "TP")
                self.tp_set.add((i, j))
            else:
                self.output_dict[i]["FP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "FP")
                self.fp_set.add((i, j))
        else:
            self.logger.log_output(stdout, i, cur_dir, j, "NEG")

    def analyze_timeout(self, cur_dir, i, j):
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        self.logger.log_output("", i, cur_dir, j, "NEG")

    def cleanup(self):
        Tool.cleanup(self)
        self.logger.close_log()
开发者ID:msaxena2,项目名称:evaluation,代码行数:63,代码来源:helgrind.py

示例7: Valgrind

# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import close_log [as 别名]
class Valgrind(Tool):

    def signal_handler(self, signum, frame):
        raise TimeoutException("Timed out!")



    def run(self, verbose=False, log_location=None):
        output_dict = {}
        spec_dict = self.info.get_spec_dict()
        ignore_list = self.info.get_ignore_list()
        os.chdir(self.benchmark_path)
        mapping_dict = self.info.get_file_mapping()
        relevant_dirs = ["01.w_Defects", "02.wo_Defects"]
        for cur_dir in relevant_dirs:
            for i in range(1, len(spec_dict.keys()) + 1):
                if i not in output_dict:
                    output_dict[i] = {"count": spec_dict[i]["actual_count"], "TP": 0, "FP": 0}
                if (i, -1) in ignore_list:
                    continue
                file_prefix = mapping_dict[i]
                print self.name + " being tested on file " + str(i)
                executable_name = cur_dir.split('.')[0] + "_" + cur_dir.split('.')[-1]
                for j in range(1, spec_dict[i]["count"]):
                    if (i, j) in ignore_list:
                        continue
                    arg = str('%03d' % i) + str('%03d' % j)
                    valgrind_command = ["valgrind", "--error-exitcode=30", os.path.join(self.benchmark_path, cur_dir, executable_name), arg]
                    print " ".join(valgrind_command)
                    result = "NEG"
                    output = ""
                    try:
                        #output = subprocess.check_output(kcc_command, stderr=subprocess.STDOUT, timeout=4)
                        process = subprocess.Popen(valgrind_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                        exit_code = process.wait(timeout=8)
                        output = process.stdout.read() + process.stderr.read()
                        print output
                        if exit_code != 0:
                            result="POS"

                    except subprocess.TimeoutExpired as e:
                        result = "TO"

                    finally:
                        process.kill()
                        if result == "POS":
                            if "w_Defects" in cur_dir:
                                output_dict[i]["TP"] += 1
                                self.logger.log_output(output, file_prefix + ".c", cur_dir, j, "TP")
                            else:
                                output_dict[i]["FP"] += 1
                                self.logger.log_output(output, file_prefix + ".c", cur_dir, j, "FP")
                        elif result == "TO":
                            self.logger.log_output(output, file_prefix + ".c", cur_dir, j, "TO")
                        else:
                            self.logger.log_output(output, file_prefix + ".c", cur_dir, j, "NEG")



        return output_dict

    def get_name(self):
        return self.name


    def __init__(self, benchmark_path, log_file_path):
        os.chdir(os.path.expanduser(benchmark_path))

        # subprocess.check_call(["./bootstrap"])
        # subprocess.check_call(["./configure", "CC=clang", "LD=clang", "CFLAGS=-flint"])
        # compile_output = subprocess.check_call(["make", "-j4"], stderr=subprocess.STDOUT)


        self.info = Info()
        self.benchmark_path = benchmark_path
        self.name = "Valgrind"
        self.logger = Logger(log_file_path, self.name)

    def analyze(self):
        Tool.analyze(self)

    def cleanup(self):
        Tool.cleanup(self)
        self.logger.close_log()
开发者ID:msaxena2,项目名称:autobench,代码行数:86,代码来源:valgrind.py

示例8: RVMatch

# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import close_log [as 别名]

#.........这里部分代码省略.........
        bootstrap_file_path = os.path.join(temp_path, file_prefix + "-temp.c")
        utils.external_info.bootstrap_file(relevant_file_path, bootstrap_file_path, vflag)
        return ["kcc", "-flint", "-lm", "-I" + os.path.join(self.benchmark_path, "include"), "-o", os.path.join(temp_path, file_prefix + "-temp.out"), bootstrap_file_path, os.path.join(self.benchmark_path, "extern.c")]


    def get_run_command(self, cur_dir, file_prefix, temp_dir_name):
        relevant_file_path = os.path.join(self.benchmark_path, cur_dir, temp_dir_name, file_prefix + "-temp.out")
        print relevant_file_path
        if os.path.exists(relevant_file_path):
            return [relevant_file_path]
        return []

    def analyze_output(self, output):
        print "Checking output " + output
        error_regex = re.compile('(UB|CV|IMPL|L|USP)\-([A-Z]+[0-9]*)')
        if re.search(error_regex, output):
            return True
        return False

    def run(self, verbose=False, log_location=None):
        output_dict = {}
        spec_dict = self.info.get_spec_dict()
        ignore_list = self.info.get_ignore_list()
        os.chdir(self.benchmark_path)
        mapping_dict = self.info.get_file_mapping()
        relevant_dirs = ["01.w_Defects", "02.wo_Defects"]
        for cur_dir in relevant_dirs:
            for i in range(1, len(spec_dict.keys()) + 1):
                if i not in output_dict:
                    output_dict[i] = {"count": spec_dict[i]["actual_count"], "TP": 0, "FP": 0}
                if (i, -1) in ignore_list:
                    continue
                file_prefix = mapping_dict[i]
                print self.name + " being tested on file " + str(i)
                executable_name = cur_dir.split('.')[0] + "_" + cur_dir.split('.')[-1]
                #bar = progressbar.ProgressBar()
                for j in range(1, spec_dict[i]["count"]):
                    if (i, j) in ignore_list:
                        continue
                    arg = str('%03d' % i) + str('%03d' % j)
                    kcc_command = [os.path.join(self.benchmark_path, cur_dir, executable_name), arg]
                    print kcc_command
                    result = "NEG"
                    output = ""
                    try:
                        signal.signal(signal.SIGALRM, self.signal_handler)
                        signal.alarm(12)
                        output = subprocess.check_output(kcc_command, stderr=subprocess.STDOUT)
                        if self.analyze_output(output):
                            result = "POS"

                    except subprocess.CalledProcessError as e:
                        output = e.output
                        if self.analyze_output(e.output):
                            result = "POS"

                    except TimeoutException:
                        result = "TO"

                    finally:
                        signal.alarm(0)
                        if result == "POS":
                            if "w_Defects" in cur_dir:
                                output_dict[i]["TP"] += 1
                                self.logger.log_output(output, file_prefix + ".c", cur_dir, j, "TP")
                            else:
                                output_dict[i]["FP"] += 1
                                self.logger.log_output(output, file_prefix + ".c", cur_dir, j, "FP")
                        elif result == "TO":
                            self.logger.log_output(output, file_prefix + ".c", cur_dir, j, "TO")
                        else:
                            self.logger.log_output(output, file_prefix + ".c", cur_dir, j, "NEG")



        return output_dict

    def get_name(self):
        return self.name


    def __init__(self, benchmark_path, log_file_path):
        os.chdir(os.path.expanduser(benchmark_path))

        #subprocess.check_call(["./bootstrap"])
        #subprocess.check_call(["./configure", "CC=kcc", "LD=kcc", "CFLAGS=-flint"])
        #compile_output = subprocess.check_call(["make", "-j4"], stderr=subprocess.STDOUT)


        self.info = Info()
        self.benchmark_path = benchmark_path
        self.name = "RV-Match"
        self.logger = Logger(log_file_path, self.name)

    def analyze(self):
        Tool.analyze(self)

    def cleanup(self):
        Tool.cleanup(self)
        self.logger.close_log()
开发者ID:msaxena2,项目名称:autobench,代码行数:104,代码来源:rv_match.py

示例9: get_name

# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import close_log [as 别名]
class RVMatch:
    def get_name(self):
        return self.name

    def check_output(self, output):
        print "Checking output " + output
        error_regex = re.compile('(UB|CV|IMPL|L|USP)\-([A-Z]+[0-9]*)')
        if re.search(error_regex, output):
            return True
        return False


    def __init__(self, benchmark_path, log_file_path):
        self.pipeline = MakePipeline(benchmark_path)
        self.name = "RVMatch"
        self.logger = Logger(log_file_path, self.name)
        self.output_dict = {}
        self.tp_set = set([])
        self.fp_set = set([])
        self.neg_count = 0
        os.chdir(os.path.expanduser(benchmark_path))

    def run(self):
        self.pipeline.build_benchmark(CC="kcc", CFLAGS="-flint", LD="kcc")
        self.pipeline.run_bechmark(self, [], 2)
        return self.output_dict

    def get_output_dict(self):
        return self.output_dict

    def get_tp_set(self):
        print len(self.tp_set)
        return self.tp_set

    def get_fp_set(self):
        print len(self.fp_set)
        return self.fp_set

    def analyze_output(self, exit_code, stdout, stderr, cur_dir, i, j):
        output = stdout + stderr
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        if self.check_output(output):
            if "w_Defects" in cur_dir:
                self.output_dict[i]["TP"] += 1
                self.logger.log_output(output, i, cur_dir, j, "TP")
                self.tp_set.add((i, j))
            else:
                self.output_dict[i]["FP"] += 1
                self.logger.log_output(output, i, cur_dir, j, "FP")
                self.fp_set.add((i, j))
        else:
            self.logger.log_output(output, i, cur_dir, j, "NEG")
            self.neg_count += 1

    def analyze_timeout(self, cur_dir, i, j):
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        self.logger.log_output("", i, cur_dir, j, "NEG")
        self.neg_count += 1

    def cleanup(self):
        self.pipeline.clean_benchmark()
        self.logger.close_log()
开发者ID:osamagid,项目名称:evaluation,代码行数:68,代码来源:rv_match.py

示例10: TIS

# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import close_log [as 别名]
class TIS(Tool):
    def signal_handler(self, signum, frame):
        raise TimeoutException("Timed out!")

    def analyze_output(self, output, file_name):
        return "ERROR" in output.upper()




    def get_tis_command(self, cur_dir, file_prefix, temp_dir_name, vflag, header_file_path):
        cur_path = os.path.join(self.benchmark_path, cur_dir)
        temp_path = os.path.join(cur_path, temp_dir_name)
        if not os.path.exists(temp_path):
            os.mkdir(temp_path)

        relevant_file_path = os.path.join(cur_path, file_prefix + ".c")
        bootstrap_file_path = os.path.join(temp_path, file_prefix + "-temp.c")
        utils.external_info.bootstrap_file(relevant_file_path, bootstrap_file_path, vflag, "SH")
        return ["tis", bootstrap_file_path]

    def run(self):
        relevant_dirs = ["01.w_Defects", "02.wo_Defects"]
        output_dict = {}

        for cur_dir in relevant_dirs:
            spec_dict = self.info.get_spec_dict()
            mapping_dict = self.info.get_file_mapping()
            for i in range(1, len(spec_dict.keys()) + 1):
                if i not in output_dict:
                    output_dict[i] = {"count": spec_dict[i]["actual_count"], "TP": 0, "FP": 0}
                if (i, -1) in self.info.get_ignore_list():
                    continue
                file_prefix = mapping_dict[i]
                print self.name + " being tested on folder " + cur_dir + " and file " + file_prefix
                # bar = progressbar.ProgressBar(redirect_stdout=True)
                verdict = False
                output = ""
                for j in range(1, spec_dict[i]["count"]):
                    if (i, j) in self.info.get_ignore_list():
                        continue
                    vflag = str('%03d' % j)
                    try:
                        original_header_path = os.path.join(self.benchmark_path, "include")
                        new_header_path = os.path.join(original_header_path, "tis_temp")
                        tis_command = self.get_tis_command(cur_dir, file_prefix, "tis_dir", vflag, new_header_path)
                        print " ".join(tis_command)
                        if len(tis_command) != 0:
                            signal.signal(signal.SIGALRM, self.signal_handler)
                            process = subprocess.Popen(tis_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                            process.wait(timeout=10)
                            output += process.stdout.read() + process.stderr.read()
                            verdict = self.analyze_output(output, file_prefix)
                            if verdict:
                                if "w_Defects" in cur_dir:
                                    output_dict[i]["TP"] += 1
                                    self.logger.log_output(output, file_prefix + ".c", cur_dir, str(j), "TP")
                                else:
                                    output_dict[i]["FP"] += 1
                                    self.logger.log_output(output, file_prefix + ".c", cur_dir, str(j), "FP")

                    except subprocess.CalledProcessError as e:
                        self.logger.log_output(output, file_prefix + ".c", cur_dir, str(j), "NEG")
                        #error with the plugin
                        continue

                    except subprocess.TimeoutExpired:
                        continue

                    finally:
                        process.kill()
                        if not verdict:
                            self.logger.log_output(output, file_prefix + ".c", cur_dir, str(j), "NEG")

        return output_dict

    def get_name(self):
        return self.name

    def __init__(self, benchmark_path, log_path):
        self.info = Info()
        self.benchmark_path = benchmark_path
        self.name = "TIS"
        self.logger = Logger(log_path, self.name)

    def analyze(self):
        Tool.analyze(self)

    def cleanup(self):
        Tool.cleanup(self)
        self.logger.close_log()
开发者ID:msaxena2,项目名称:autobench,代码行数:93,代码来源:tis.py

示例11: get_name

# 需要导入模块: from utils.logger import Logger [as 别名]
# 或者: from utils.logger.Logger import close_log [as 别名]
class MSan:
    def get_name(self):
        return self.name


    def __init__(self, benchmark_path, log_file_path):
        self.pipeline = MakePipeline(benchmark_path)
        self.name = "MSan"
        self.logger = Logger(log_file_path, self.name)
        self.output_dict = {}
        self.tp_set = set([])
        self.fp_set = set([])
        self.neg_count = 0
        os.chdir(os.path.expanduser(benchmark_path))

    def run(self):
        self.pipeline.build_benchmark(CC="clang", CFLAGS="-g -fsanitize=memory", LD="clang")
        self.pipeline.run_bechmark(self, [], 2)
        return self.output_dict

    def get_output_dict(self):
        return self.output_dict

    def get_tp_set(self):
        print len(self.tp_set)
        return self.tp_set

    def get_fp_set(self):
        print len(self.fp_set)
        return self.fp_set

    def analyze_output(self, exit_code, stdout, stderr, cur_dir, i, j):
        if len(stderr) > 0:
            print(stderr)
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        if exit_code != 0:
            if "w_Defects" in cur_dir:
                self.output_dict[i]["TP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "TP")
                self.tp_set.add((i, j))
            else:
                self.output_dict[i]["FP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "FP")
                self.fp_set.add((i, j))
        else:
            self.logger.log_output(stdout, i, cur_dir, j, "NEG")
            self.neg_count += 1

    def analyze_timeout(self, cur_dir, i, j):
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        self.logger.log_output("", i, cur_dir, j, "NEG")
        self.neg_count += 1

    def cleanup(self):
        print "Numbers for " + self.name
        print "Total Count = " + str(self.neg_count + len(self.tp_set) + len(self.fp_set))
        print "TP Count = " + str(len(self.tp_set))
        print "FP Count = " + str(len(self.fp_set))
        print "Negatives Count = " + str(self.neg_count)
        Tool.cleanup(self)
        self.logger.close_log()
开发者ID:msaxena2,项目名称:evaluation,代码行数:67,代码来源:m_san.py


注:本文中的utils.logger.Logger.close_log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。