Skip to content

Commit

Permalink
fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
thientc committed Dec 28, 2022
1 parent 0649b00 commit 58fca32
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ FUTAG запускает статический анализ во время с

### 2.2. Установка:

- Скачать последний релиз [futag-llvm.latest.tar.gz](https://github.com/ispras/Futag/releases/tag/latest) и разархивировать
- Скачать последний релиз [futag-llvm.1.2.2.tar.xz](https://github.com/ispras/Futag/releases/tag/1.2.2) и разархивировать

- Установить зависимости:
```bash
Expand Down
Binary file modified src/python/futag-package/dist/futag-1.2.2-py3-none-any.whl
Binary file not shown.
Binary file modified src/python/futag-package/dist/futag-1.2.2.tar.gz
Binary file not shown.
32 changes: 20 additions & 12 deletions src/python/futag-package/src/futag/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2588,12 +2588,13 @@ def gen_targets(self, anonymous: bool = False):
(self.output_path / "result-report.json").as_posix(), "w"))

def compile_driver_worker(self, bgen_args):
p = Popen(
bgen_args["compiler_cmd"],
stdout=PIPE,
stderr=PIPE,
universal_newlines=True,
)
with open(bgen_args["error_path"], "w") as error_log_file:
p = Popen(
bgen_args["compiler_cmd"],
stdout=PIPE,
stderr=error_log_file,
universal_newlines=True,
)

target_file = open(bgen_args["source_path"], "a")

Expand All @@ -2613,7 +2614,7 @@ def compile_driver_worker(self, bgen_args):
output, errors = p.communicate()
if p.returncode:
print(" ".join(bgen_args["compiler_cmd"]))
print("\n-- [Futag] ERROR on target ", bgen_args["target_name"], ":\n", errors)
print("\n-- [Futag] ERROR on target ", bgen_args["target_name"], "\n")
for c in compiler_cmd:
if c.find(self.tmp_output_path.as_posix()) >= 0:
new_compiler_cmd.append(c.replace(self.tmp_output_path.as_posix(), self.failed_path.as_posix()))
Expand All @@ -2630,8 +2631,15 @@ def compile_driver_worker(self, bgen_args):

target_file.write(" ".join(new_compiler_cmd))
target_file.write("\n */\n")

error_log_file = open(bgen_args["error_path"], "r")
if error_log_file:
target_file.write("\n// Error log:")
target_file.write("\n/* \n")
target_file.write("".join(error_log_file.readlines()))
error_log_file.close()
target_file.write("\n */\n")
target_file.close()


def compile_targets(self, workers: int = 4, keep_failed: bool = False, extra_include: str = "", extra_dynamiclink: str = "", flags: str = FUZZ_COMPILER_FLAGS, coverage: bool=False):
"""
Expand Down Expand Up @@ -2706,8 +2714,6 @@ def compile_targets(self, workers: int = 4, keep_failed: bool = False, extra_inc
if pathlib.Path(iter[2:]).exists():
include_subdir.append("-I" + pathlib.Path(iter[2:]).absolute().as_posix() + "/")
os.chdir(current_location)



compiler_path = ""
if self.target_type == LIBFUZZER:
Expand Down Expand Up @@ -2766,17 +2772,19 @@ def compile_targets(self, workers: int = 4, keep_failed: bool = False, extra_inc
for dir in fuzz_driver_dirs:
for target_src in [t for t in dir.glob("*"+self.target_extension) if t.is_file()]:
target_path = dir.as_posix() + "/" + target_src.stem + ".out"
error_path = dir.as_posix() + "/" + target_src.stem + ".err"
generated_targets += 1
if self.target_type == LIBFUZZER:
compiler_cmd = [compiler_path.as_posix()] + compiler_flags_libFuzzer.split(" ") + current_include + [extra_include] + [
target_src.as_posix()] + ["-o"] + [target_path] + static_lib + [extra_dynamiclink]
target_src.as_posix()] + ["-o"] + [target_path] + static_lib + extra_dynamiclink.split(" ")
else:
compiler_cmd = [compiler_path.as_posix()] + compiler_flags_aflplusplus.split(" ") + current_include + [extra_include] +[
target_src.as_posix()] + ["-o"] + [target_path] + static_lib + [extra_dynamiclink]
target_src.as_posix()] + ["-o"] + [target_path] + static_lib + extra_dynamiclink.split(" ")

compile_cmd_list.append({
"compiler_cmd" : compiler_cmd,
"target_name": target_src.stem,
"error_path": error_path,
"source_path": target_src.as_posix(),
"binary_path": target_path,
"compiler_info": compiler_info,
Expand Down
7 changes: 4 additions & 3 deletions src/python/futag-package/src/futag/sysmsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
BUILD_EX_PARAMS = ""
INSTALL_PATH = ".futag-install"
ANALYSIS_PATH = ".futag-analysis"
COMPILER_FLAGS = "-fsanitize=address -g -O0"
COMPILER_COVERAGE_FLAGS = "-fsanitize=address -g -O0 -fprofile-instr-generate -fcoverage-mapping"
FUZZ_COMPILER_FLAGS = "-fsanitize=address,fuzzer -g -O0"
DEBUG_FLAGS = "-g -O0 "
COMPILER_FLAGS = "-fsanitize=address "
COMPILER_COVERAGE_FLAGS = "-fprofile-instr-generate -fcoverage-mapping "
FUZZ_COMPILER_FLAGS = "-fsanitize=address,fuzzer "
FUZZ_DRIVER_PATH = "futag-fuzz-drivers"
ANALYSIS_FILE_PATH=".futag-analysis/futag-analysis-result.json"
CMAKE_PATH_ERROR="Please specify other directory for building with cmake."
Expand Down

0 comments on commit 58fca32

Please sign in to comment.