Lines Matching +full:is +full:- +full:binary +full:- +full:path
8 from pathlib import Path
21 source: Path
22 binary: Path
53 …Target(source=Path("../utils/persistent_mode/test-instr.c").resolve(), binary=Path("test-instr-per…
54 Target(source=Path("../test-instr.c").resolve(), binary=Path("test-instr"))
57 targets = [str(target.binary) for target in all_targets]
61 …"AFL_NO_UI": "1", "AFL_TRY_AFFINITY": "1", "PATH": f'{str(Path("../").resolve())}:{os.environ["PAT…
65 parser.add_argument("-b", "--basedir", help="directory to use for temp files", type=str, default="/…
66 parser.add_argument("-d", "--debug", help="show verbose debugging output", action="store_true")
67 parser.add_argument("-r", "--runs", help="how many runs to average results over", type=int, default…
68 parser.add_argument("-f", "--fuzzers", help="how many afl-fuzz workers to use", type=int, default=c…
69 parser.add_argument("-m", "--mode", help="pick modes", action="append", default=modes, choices=mode…
70 parser.add_argument("-c", "--comment", help="add a comment about your setup", type=str, default="")
71 parser.add_argument("--cpu", help="override the detected CPU model name", type=str, default="")
72 parser.add_argument("--mhz", help="override the detected CPU MHz", type=str, default="")
74 …"-t", "--target", help="pick targets", action="append", default=["test-instr-persist-shmem"], choi…
85 chosen_targets = [target for target in all_targets if str(target.binary) in args.target]
87 str(t.binary): {m.name: None for m in chosen_modes} for t in chosen_targets}
91 async def clean_up_tempfiles() -> None:
94 target.binary.unlink()
96 shutil.rmtree(f"{args.basedir}/out-{mode.name}-{str(target.binary)}")
98 async def check_afl_persistent() -> bool:
102 async def check_afl_system() -> bool:
109 async def prep_env() -> None:
110 Path(f"{args.basedir}/in").mkdir(exist_ok=True, parents=True)
114 async def compile_target(source: Path, binary: Path) -> None: argument
115 print(f" [*] Compiling the {binary} fuzzing harness for the benchmark to use.")
117 …[str(Path("../afl-clang-lto").resolve()), "-o", str(Path(binary.resolve())), str(Path(source).reso…
121 print(yellow(f" [*] afl-clang-lto was unable to compile; falling back to afl-cc."))
123 … [str(Path("../afl-cc").resolve()), "-o", str(Path(binary.resolve())), str(Path(source).resolve())]
126 … sys.exit(red(f" [*] Error: afl-cc is unable to compile: {stderr.decode()} {stdout.decode()}"))
128 async def run_command(cmd: List[str]) -> Tuple[Optional[int], bytes, bytes]:
137 async def check_deps() -> None:
138 …if not (plat := platform.system()) == "Linux": sys.exit(red(f" [*] {plat} is not supported by this…
139 …if not os.access(Path("../afl-fuzz").resolve(), os.X_OK) and os.access(Path("../afl-cc").resolve()…
140 os.path.exists(Path("../SanitizerCoveragePCGUARD.so").resolve())):
141 …sys.exit(red(" [*] Compile AFL++: we need afl-fuzz, afl-clang-fast and SanitizerCoveragePCGUARD.so…
143 (returncode, stdout, stderr) = await run_command([str(Path("../afl-cc").resolve()), "-v"])
145 sys.exit(red(f" [*] Error: afl-cc -v returned: {stderr.decode()} {stdout.decode()}"))
154 …# Pick some sample settings from afl-{persistent,system}-config to try to see whether they were ru…
158 …print(yellow(f" [*] afl-persistent-config did not run; run it to improve performance (and decrease…
160 …print(yellow(f" [*] afl-system-config did not run; run it to improve performance (and decrease sec…
164 async def colon_values(filename: str, searchKey: str) -> List[str]:
165 """Return a colon-separated value given a key in a file, e.g. 'cpu MHz : 4976.109')"""
171 async def describe_afl_config() -> str:
172 if results.config is None:
183 async def save_benchmark_results() -> None:
184 …"""Append a single row to the benchmark results in JSON Lines format (which is simple to write and…
185 with open("benchmark-results.jsonl", "a") as jsonfile:
192 if results.hardware is None:
196 …print(blue(f" [*] Results have not been written to the COMPARISON.md file; this CPU is already pre…
199 if not "test-instr-persist-shmem" in results.targets or \
200 not "multicore" in results.targets["test-instr-persist-shmem"] or \
201 not "singlecore" in results.targets["test-instr-persist-shmem"] or \
202 results.targets["test-instr-persist-shmem"]["singlecore"] is None or \
203 results.targets["test-instr-persist-shmem"]["multicore"] is None:
205 …single = str(round(results.targets["test-instr-persist-shmem"]["singlecore"].execs_per_sec)).ljust…
206 …multi = str(round(results.targets["test-instr-persist-shmem"]["multicore"].execs_per_sec)).ljust(9)
214 async def main() -> None:
235 await compile_target(target.source, target.binary)
236 binary = str(target.binary)
240 …print(blue("(use --fuzzers to override)." if args.fuzzers == cpu_count else f"(the default is {cpu…
243 …print(gray(f" [*] {mode.name} {binary} run {run_idx+1} of {args.runs}, execs/s: "), end="", flush=…
245 outdir = f"{args.basedir}/out-{mode.name}-{binary}"
248 name = ["-o", outdir, "-M" if fuzzer_idx == 0 else "-S", str(afl)]
249 …cmds.append(["afl-fuzz", "-i", f"{args.basedir}/in"] + name + ["-s", "123", "-V10", "-D", f"./{bin…
250 # Prepare the afl-fuzz tasks, and then block while waiting for them to finish.
256 … # Our score is the sum of all execs_per_sec entries in fuzzer_stats files for the run.
267 # (Using float() because Decimal() is not JSON-serializable.)
271 results.targets[binary][mode.name] = run
273 if (((max(execs_per_sec) - min(execs_per_sec)) / avg_afl_execs_per_sec) * 100) > 15: