Skip to content

Commit 483c583

Browse files
build-generator: add option for running OFG generation (#917)
Makes it possible to run auto harness generation on generated builds as part of the same command ```sh MODEL=gpt-4o python3 -m experimental.build_generator.runner \ -of oss-fuzz/ -i targets2.txt -o generated-3 --generate-harness ``` ref: #911 Signed-off-by: David Korczynski <[email protected]>
1 parent aaaf0f8 commit 483c583

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

experimental/build_generator/runner.py

+37
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,36 @@ def run_parallels(oss_fuzz_base, target_repositories, llm_model,
291291
proc.join()
292292

293293

294+
def run_harness_generation(out_gen):
295+
"""Runs harness generation based on the projects in `out`"""
296+
297+
projects_dir = os.path.join(out_gen, 'oss-fuzz-projects')
298+
if not os.path.isdir(projects_dir):
299+
logger.info('Found no projects.')
300+
return
301+
302+
# Set up if needed
303+
if not os.path.isdir('work'):
304+
subprocess.check_call('./scripts/run-new-oss-fuzz-project/setup.sh',
305+
shell=True)
306+
307+
# Copy projects over
308+
projects_to_run = []
309+
for project in os.listdir(projects_dir):
310+
dst = os.path.join('work', 'oss-fuzz', 'projects', project)
311+
if os.path.isdir(dst):
312+
shutil.rmtree(dst)
313+
shutil.copytree(os.path.join(projects_dir, project),
314+
os.path.join('work', 'oss-fuzz', 'projects', project))
315+
projects_to_run.append(project)
316+
317+
# Run project generation
318+
project_string = ' '.join(projects_to_run)
319+
subprocess.check_call(
320+
f'./scripts/run-new-oss-fuzz-project/run-project.sh {project_string}',
321+
shell=True)
322+
323+
294324
def parse_commandline():
295325
"""Parse the commandline."""
296326
parser = argparse.ArgumentParser()
@@ -313,6 +343,10 @@ def parse_commandline():
313343
'-m',
314344
help=f'LLM model to use. Available: {str(constants.MODELS)}',
315345
type=str)
346+
parser.add_argument(
347+
'--generate-harness',
348+
action='store_true',
349+
help='Will run OFG harness creation on generated projects.')
316350
return parser.parse_args()
317351

318352

@@ -341,6 +375,9 @@ def main():
341375
run_parallels(os.path.abspath(args.oss_fuzz), target_repositories, args.model,
342376
args.build_heuristics, args.out)
343377

378+
if args.generate_harness:
379+
run_harness_generation(args.out)
380+
344381

345382
if __name__ == '__main__':
346383
main()

scripts/run-new-oss-fuzz-project/run-project.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cd ${OSS_FUZZ_DIR}
4343

4444
for p2 in ${PROJECTS}; do
4545
python3 $FI_DIR/oss_fuzz_integration/runner.py \
46-
introspector $p2 10 --disable-webserver
46+
introspector $p2 1 --disable-webserver
4747
# Reset is necessary because some project exeuction
4848
# could break the display encoding which affect
4949
# the later oss-fuzz-gen execution.

0 commit comments

Comments
 (0)