Skip to content

Commit 5ea8144

Browse files
tests: Add support for excluding fuzz targets using -x/--exclude
1 parent 555236f commit 5ea8144

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

test/fuzz/test_runner.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"tx_out",
4848
]
4949

50+
5051
def main():
5152
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
5253
parser.add_argument(
@@ -66,6 +67,11 @@ def main():
6667
action='store_true',
6768
help='If true, run fuzzing binaries under the valgrind memory error detector',
6869
)
70+
parser.add_argument(
71+
'-x',
72+
'--exclude',
73+
help="A comma-separated list of targets to exclude",
74+
)
6975
parser.add_argument(
7076
'seed_dir',
7177
help='The seed corpus to run on (must contain subfolders for each fuzz target).',
@@ -100,7 +106,7 @@ def main():
100106
logging.error("No fuzz targets found")
101107
sys.exit(1)
102108

103-
logging.info("Fuzz targets found: {}".format(test_list_all))
109+
logging.debug("{} fuzz target(s) found: {}".format(len(test_list_all), " ".join(sorted(test_list_all))))
104110

105111
args.target = args.target or test_list_all # By default run all
106112
test_list_error = list(set(args.target).difference(set(test_list_all)))
@@ -109,7 +115,15 @@ def main():
109115
test_list_selection = list(set(test_list_all).intersection(set(args.target)))
110116
if not test_list_selection:
111117
logging.error("No fuzz targets selected")
112-
logging.info("Fuzz targets selected: {}".format(test_list_selection))
118+
if args.exclude:
119+
for excluded_target in args.exclude.split(","):
120+
if excluded_target not in test_list_selection:
121+
logging.error("Target \"{}\" not found in current target list.".format(excluded_target))
122+
continue
123+
test_list_selection.remove(excluded_target)
124+
test_list_selection.sort()
125+
126+
logging.info("{} of {} detected fuzz target(s) selected: {}".format(len(test_list_selection), len(test_list_all), " ".join(test_list_selection)))
113127

114128
try:
115129
help_output = subprocess.run(

0 commit comments

Comments
 (0)