Skip to content

Commit 40e3807

Browse files
committed
Set up command line arguments
1 parent 730e458 commit 40e3807

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

fuzz/clean_fuzz_dir.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,51 @@
11
#!/usr/bin/env python3
22
import os
33
import shutil
4+
import argparse
45

5-
ROOT_DIR = "/home/jiayiguo/FuzzAug/fuzz/oss-fuzz/projects"
6+
# Default root directory
7+
DEFAULT_ROOT_DIR = "/home/jiayiguo/FuzzAug/fuzz/oss-fuzz/projects"
68

79
def clean_project_dirs(root_dir):
810
removed_files = 0
911
removed_dirs = 0
1012

11-
# 遍历一级项目目录
13+
# Walk through the root directory
1214
for project in os.listdir(root_dir):
1315
project_path = os.path.join(root_dir, project)
1416
if not os.path.isdir(project_path):
1517
continue
1618

17-
# 删除 fuzz_inputs 文件夹
19+
# Delete fuzz_inputs directories
1820
fuzz_inputs_path = os.path.join(project_path, "fuzz_inputs")
1921
if os.path.isdir(fuzz_inputs_path):
2022
shutil.rmtree(fuzz_inputs_path)
2123
print(f"🗑️ Removed dir: {fuzz_inputs_path}")
2224
removed_dirs += 1
2325

24-
# 删除 tests-gen 文件夹
26+
# Delete tests-gen directories
2527
tests_gen_path = os.path.join(project_path, "tests-gen")
2628
if os.path.isdir(tests_gen_path):
2729
shutil.rmtree(tests_gen_path)
2830
print(f"🗑️ Removed dir: {tests_gen_path}")
2931
removed_dirs += 1
3032

31-
# # 删除 .inputs.py 文件
32-
# for fname in os.listdir(project_path):
33-
# if fname.endswith(".inputs.py"):
34-
# file_path = os.path.join(project_path, fname)
35-
# os.remove(file_path)
36-
# print(f"🗑️ Removed file: {file_path}")
37-
# removed_files += 1
38-
39-
print(f"\n✅ Done. Removed {removed_files} files and {removed_dirs} directories.")
33+
print(f"\n✅ Done. Removed {removed_dirs} directories in total.")
4034

4135
if __name__ == "__main__":
42-
clean_project_dirs(ROOT_DIR)
36+
# Set up command line arguments
37+
parser = argparse.ArgumentParser(
38+
description='Clean project directories by removing fuzz_inputs and tests-gen folders',
39+
formatter_class=argparse.ArgumentDefaultsHelpFormatter
40+
)
41+
parser.add_argument('--root_dir', default=DEFAULT_ROOT_DIR,
42+
help='Root directory containing project folders')
43+
args = parser.parse_args()
44+
45+
# Validate the root directory exists
46+
if not os.path.isdir(args.root_dir):
47+
print(f"❌ Error: Specified root directory does not exist: {args.root_dir}")
48+
exit(1)
49+
50+
print(f"Cleaning projects in: {args.root_dir}")
51+
clean_project_dirs(args.root_dir)

0 commit comments

Comments
 (0)