18
18
19
19
20
20
def main ():
21
- parser = argparse .ArgumentParser (formatter_class = argparse .ArgumentDefaultsHelpFormatter )
21
+ parser = argparse .ArgumentParser (
22
+ formatter_class = argparse .ArgumentDefaultsHelpFormatter ,
23
+ description = '''Run the fuzz targets with all inputs from the seed_dir once.''' ,
24
+ )
22
25
parser .add_argument (
23
26
"-l" ,
24
27
"--loglevel" ,
@@ -50,6 +53,10 @@ def main():
50
53
nargs = '*' ,
51
54
help = 'The target(s) to run. Default is to run all targets.' ,
52
55
)
56
+ parser .add_argument (
57
+ '--m_dir' ,
58
+ help = 'Merge inputs from this directory into the seed_dir. Needs /target subdirectory.' ,
59
+ )
53
60
54
61
args = parser .parse_args ()
55
62
@@ -112,6 +119,14 @@ def main():
112
119
logging .error ("subprocess timed out: Currently only libFuzzer is supported" )
113
120
sys .exit (1 )
114
121
122
+ if args .m_dir :
123
+ merge_inputs (
124
+ corpus = args .seed_dir ,
125
+ test_list = test_list_selection ,
126
+ build_dir = config ["environment" ]["BUILDDIR" ],
127
+ merge_dir = args .m_dir ,
128
+ )
129
+
115
130
run_once (
116
131
corpus = args .seed_dir ,
117
132
test_list = test_list_selection ,
@@ -121,6 +136,22 @@ def main():
121
136
)
122
137
123
138
139
+ def merge_inputs (* , corpus , test_list , build_dir , merge_dir ):
140
+ logging .info ("Merge the inputs in the passed dir into the seed_dir. Passed dir {}" .format (merge_dir ))
141
+ for t in test_list :
142
+ args = [
143
+ os .path .join (build_dir , 'src' , 'test' , 'fuzz' , t ),
144
+ '-merge=1' ,
145
+ os .path .join (corpus , t ),
146
+ os .path .join (merge_dir , t ),
147
+ ]
148
+ os .makedirs (os .path .join (corpus , t ), exist_ok = True )
149
+ os .makedirs (os .path .join (merge_dir , t ), exist_ok = True )
150
+ logging .debug ('Run {} with args {}' .format (t , args ))
151
+ output = subprocess .run (args , check = True , stderr = subprocess .PIPE , universal_newlines = True ).stderr
152
+ logging .debug ('Output: {}' .format (output ))
153
+
154
+
124
155
def run_once (* , corpus , test_list , build_dir , export_coverage , use_valgrind ):
125
156
for t in test_list :
126
157
corpus_path = os .path .join (corpus , t )
0 commit comments