From 5dd82119aaa56031829513706858e61ad71c8681 Mon Sep 17 00:00:00 2001 From: Arthur Chan Date: Tue, 11 Feb 2025 10:32:47 +0000 Subject: [PATCH] Fix bug Signed-off-by: Arthur Chan --- data_prep/project_src.py | 1 - experiment/textcov.py | 6 +++--- experimental/from_scratch/generate.py | 14 +++++++------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/data_prep/project_src.py b/data_prep/project_src.py index 0b1061ba4..78582ea19 100755 --- a/data_prep/project_src.py +++ b/data_prep/project_src.py @@ -101,7 +101,6 @@ def _get_harness(src_file: str, out: str, language: str) -> tuple[str, str]: target not in content for target in ['testing.F', 'testing.T', '.Fuzz']): return '', '' - short_path = src_file[len(out):] return short_path, content diff --git a/experiment/textcov.py b/experiment/textcov.py index 1dbffa90b..024a5bfe2 100644 --- a/experiment/textcov.py +++ b/experiment/textcov.py @@ -165,7 +165,7 @@ def subtract_covered_lines(self, other: File): for line_no, line in self.lines.items(): other_line = other.lines.get(line_no) if other_line and other_line.hit_count > 0: - self.lines[line_no].hit_count = 0 + line.hit_count = 0 @dataclasses.dataclass @@ -292,7 +292,7 @@ def from_python_file(cls, file_handle) -> Textcov: return textcov @classmethod - def from_go_file(cls, file_hnadle) -> Textcov: + def from_go_file(cls, file_handle) -> Textcov: """Read a textcov from a fuzz.cov file for golang project.""" textcov = cls() textcov.language = 'go' @@ -327,7 +327,7 @@ def from_go_file(cls, file_hnadle) -> Textcov: line = f'Line{line_no}' current_file.lines[line] = Line(contents=line, hit_count=hit_count) - textcov.files[filename] = current_file + textcov.files[file_name] = current_file return textcov diff --git a/experimental/from_scratch/generate.py b/experimental/from_scratch/generate.py index c39fe45a9..aa42a047b 100644 --- a/experimental/from_scratch/generate.py +++ b/experimental/from_scratch/generate.py @@ -105,9 +105,9 @@ def check_args(args) -> bool: return True print( - 'You must include either:\n (1) target function name by --function;\n (2) target ' - 'source file and line number by --source-file and --source-line;\n (3) ' - '--far-reach') + 'You must include either:\n (1) target function name by --function;\n ' + '(2) target source file and line number by --source-file and ' + '--source-line;\n (3) --far-reach') return False @@ -236,11 +236,11 @@ def introspector_lang_to_entrypoint(language: str) -> str: """Map an introspector language to entrypoint function.""" if language in ['c', 'c++']: return 'LLVMFuzzerTestOneInput' - elif language == 'jvm': + if language == 'jvm': return 'fuzzerTestOneInput' - else: - # Other supported languages have no fixed entry point - return '' + + # Other supported languages have no fixed entry point + return '' def get_far_reach_benchmarks(