FRET-LibAFL/scripts/parallellize_cargo_check.py
Dominik Maier 21f8b1d147
Replace addr_of with &raw across the codebase (#2669)
* Replace addr_of with &raw across the codebase

* fix fixes

* more fix

* undo clang fmt?

* oops

* fix?

* allocator fix

* more fix

* more more

* more docs

* more fix

* mas mas mas

* hm

* more

* fix Frida

* needed

* more error

* qemu
2024-11-08 17:19:55 +01:00

58 lines
1.9 KiB
Python
Executable File

#!/usr/bin/python3
import subprocess
import os
import sys
import math
LLVM_VERSION = "18"
# Current CI Runner
ci_instances = 18
if len(sys.argv) != 2:
exit(1)
instance_idx = int(sys.argv[1])
# Set llvm config if it's not already set
if "LLVM_CONFIG" not in os.environ:
os.environ["LLVM_CONFIG"] = f"llvm-config-{LLVM_VERSION}"
command = (
"DOCS_RS=1 cargo hack check --workspace --each-feature --clean-per-run "
"--exclude-features=prelude,python,sancov_pcguard_edges,arm,aarch64,i386,be,systemmode,whole_archive "
"--no-dev-deps --exclude libafl_libfuzzer --exclude libafl_qemu --exclude libafl_qemu_sys --print-command-list;"
"DOCS_RS=1 cargo hack check -p libafl_qemu -p libafl_qemu_sys --each-feature --clean-per-run "
"--exclude-features=prelude,python,sancov_pcguard_edges,arm,aarch64,i386,be,systemmode,whole_archive,slirp "
"--no-dev-deps --features usermode --print-command-list"
)
# Run the command and capture the output
output = subprocess.check_output(command, shell=True, text=True)
output = output.strip().split("\n")[0:]
all_task_cnt = len(output) // 2 # by 2 cuz one task has two lines
task_per_core = math.ceil(all_task_cnt // ci_instances)
print(task_per_core, "tasks assigned to this instance")
for task in output[
instance_idx * 2 * task_per_core : (instance_idx + 1) * 2 * task_per_core
]:
print("Running ", task)
print(os.environ)
if (
"utils/libafl_jumper/Cargo.toml" in task
and "--no-default-features" in task
and "--features" not in task
):
# ignore libafl_jumper no std
continue
if "libafl_frida" in task:
# DOCS_RS is needed for libafl_frida to build without auto-download feature
cargo_check = subprocess.check_output(
task, shell=True, text=True, env=dict(os.environ, DOCS_RS="1")
)
else:
cargo_check = subprocess.check_output(task, shell=True, text=True)