diff --git a/wake/cli/test.py b/wake/cli/test.py index d1759461..e38a5a2e 100644 --- a/wake/cli/test.py +++ b/wake/cli/test.py @@ -263,7 +263,7 @@ def extract_crash_log_dict(crash_log_file_path: Path) -> dict: except json.JSONDecodeError: raise ValueError(f"Invalid JSON format in crash log file: {crash_log_file_path}") - def get_shrink_argument_path(shrink_path_str: str) -> Path: + def get_shrink_argument_path(shrink_path_str: str, dir_name: str) -> Path: try: path = Path(shrink_path_str) if not path.exists(): @@ -273,7 +273,7 @@ def get_shrink_argument_path(shrink_path_str: str) -> Path: pass crash_logs_dir = ( - get_config().project_root_path / ".wake" / "logs" / "crashes" + get_config().project_root_path / ".wake" / "logs" / dir_name ) if not crash_logs_dir.exists(): raise click.BadParameter( @@ -287,30 +287,6 @@ def get_shrink_argument_path(shrink_path_str: str) -> Path: raise click.BadParameter(f"Invalid crash log index: {index}") return Path(crash_logs[index]) - def get_shrank_argument_path(shrank_path_str: str) -> Path: - try: - shrank_path = Path(shrank_path_str) - if not shrank_path.exists(): - raise ValueError(f"Shrank data file not found: {shrank_path}") - return shrank_path - except ValueError: - pass - shrank_data_path = ( - get_config().project_root_path / ".wake" / "logs" / "shrank" - ) - if not shrank_data_path.exists(): - raise click.BadParameter( - f"Shrank data file not found: {shrank_data_path}" - ) - - index = int(shrank_path_str) - shrank_files = sorted( - shrank_data_path.glob("*.bin"), key=os.path.getmtime, reverse=True - ) - if abs(index) > len(shrank_files): - raise click.BadParameter(f"Invalid crash log index: {index}") - return Path(shrank_files[index]) - if shrank is not None and shrink is not None: raise click.BadParameter( "Both shrink and shrieked cannot be provided at the same time." @@ -321,7 +297,7 @@ def get_shrank_argument_path(shrank_path_str: str) -> Path: if shrink is not None: set_fuzz_mode(1) - shrink_crash_path = get_shrink_argument_path(shrink) + shrink_crash_path = get_shrink_argument_path(shrink, "crashes") print("shrink from crash log: ", shrink_crash_path) crash_log_dict = extract_crash_log_dict(shrink_crash_path) path = crash_log_dict["test_file"] @@ -336,7 +312,7 @@ def get_shrank_argument_path(shrank_path_str: str) -> Path: if shrank: set_fuzz_mode(2) - shrank_data_path = get_shrank_argument_path(shrank) + shrank_data_path = get_shrink_argument_path(shrank, "shrank") print("shrank from shrank data: ", shrank_data_path) with open(shrank_data_path, "r") as f: target_fuzz_path = json.load(f)["target_fuzz_path"]