2525
2626def build_proj_with_default (project_name ):
2727 try :
28- subprocess .check_call ("python3 infra/helper.py build_fuzzers --clean %s" % (project_name ), shell = True )
28+ subprocess .check_call (
29+ "python3 infra/helper.py build_fuzzers --clean %s" % (project_name ),
30+ shell = True
31+ )
2932 except :
3033 print ("Building default failed" )
3134 exit (5 )
3235
36+
3337def build_proj_with_coverage (project_name ):
38+ cmd = [
39+ "python3" ,
40+ "infra/helper.py" ,
41+ "build_fuzzers" ,
42+ "--sanitizer=coverage" ,
43+ project_name
44+ ]
3445 try :
35- subprocess .check_call ("python3 infra/helper.py build_fuzzers --sanitizer=coverage %s" % (project_name ), shell = True )
46+ subprocess .check_call (
47+ " " .join (cmd ),
48+ shell = True
49+ )
3650 except :
3751 print ("Building with coverage failed" )
3852 exit (5 )
3953
54+
4055def get_fuzzers (project_name ):
4156 execs = []
4257 for l in os .listdir ("build/out/%s" % (project_name )):
@@ -48,6 +63,7 @@ def get_fuzzers(project_name):
4863 print ("Executable files: %s" % (str (execs )))
4964 return execs
5065
66+
5167def get_next_corpus_dir ():
5268 max_idx = - 1
5369 for f in os .listdir ("." ):
@@ -60,6 +76,7 @@ def get_next_corpus_dir():
6076 None
6177 return "corpus-%d" % (max_idx + 1 )
6278
79+
6380def get_recent_corpus_dir ():
6481 max_idx = - 1
6582 for f in os .listdir ("." ):
@@ -72,6 +89,7 @@ def get_recent_corpus_dir():
7289 None
7390 return "corpus-%d" % (max_idx )
7491
92+
7593def run_all_fuzzers (project_name , fuzztime ):
7694 # First get all fuzzers names
7795 fuzzer_names = get_fuzzers (project_name )
@@ -85,7 +103,17 @@ def run_all_fuzzers(project_name, fuzztime):
85103 os .mkdir (target_corpus )
86104 os .mkdir (target_crashes )
87105
88- cmd = ["python3 ./infra/helper.py run_fuzzer --corpus-dir=%s %s %s -- -max_total_time=%d -detect_leaks=0" % (target_corpus , project_name , f , fuzztime )]
106+ cmd = [
107+ "python3" ,
108+ "./infra/helper.py" ,
109+ "run_fuzzer" ,
110+ "--corpus-dir=%s" % (target_corpus ),
111+ "%s" % (project_name ),
112+ "%s" % (f ),
113+ "--" ,
114+ "-max_total_time=%d" % (fuzztime ),
115+ "-detect_leaks=0"
116+ ]
89117 try :
90118 subprocess .check_call (" " .join (cmd ), shell = True )
91119 print ("Execution finished without exception" )
@@ -97,6 +125,7 @@ def run_all_fuzzers(project_name, fuzztime):
97125 if "crash-" in l or "leak-" in l :
98126 shutil .move (l , target_crashes )
99127
128+
100129def get_coverage (project_name ):
101130 #1 Find all coverage reports
102131 corpus_dir = get_recent_corpus_dir ()
@@ -105,23 +134,37 @@ def get_coverage(project_name):
105134 for f in os .listdir (corpus_dir ):
106135 if os .path .isdir ("build/corpus/%s/%s" % (project_name , f )):
107136 shutil .rmtree ("build/corpus/%s/%s" % (project_name , f ))
108- shutil .copytree (os .path .join (corpus_dir , f ), "build/corpus/%s/%s" % (project_name , f ))
137+ shutil .copytree (
138+ os .path .join (corpus_dir , f ),
139+ "build/corpus/%s/%s" % (project_name , f )
140+ )
109141
110142 #3 run coverage command
143+ cmd = [
144+ "python3" ,
145+ "infra/helper.py" ,
146+ "coverage" ,
147+ "--no-corpus-download" ,
148+ project_name
149+ ]
111150 try :
112- subprocess .check_call ("python3 infra/helper.py coverage --no-corpus-download %s" % (project_name ), shell = True )#, timeout=60)
151+ subprocess .check_call (
152+ " " .join (cmd ),
153+ shell = True
154+ )
113155 except :
114156 print ("Could not run coverage reports" )
115157
116158
117- #try:
118- # subprocess.check_call("docker kill $(docker ps -qa)", shell=True)
119- #except:
120- # None
121-
122159 print ("Copying report" )
123- shutil .copytree ("./build/out/%s/report" % (project_name ), "./%s/report" % (corpus_dir ))
124- shutil .copytree ("./build/out/%s/report_target" % (project_name ), "./%s/report_target" % (corpus_dir ))
160+ shutil .copytree (
161+ "./build/out/%s/report" % (project_name ),
162+ "./%s/report" % (corpus_dir )
163+ )
164+ shutil .copytree (
165+ "./build/out/%s/report_target" % (project_name ),
166+ "./%s/report_target" % (corpus_dir )
167+ )
125168 try :
126169 summary_file = "build/out/%s/report/linux/summary.json" % (project_name )
127170 with open (summary_file , "r" ) as fj :
@@ -148,12 +191,24 @@ def complete_coverage_check(project_name, fuzztime):
148191
149192 return percent
150193
194+
151195def get_single_cov (project , target , corpus_dir ):
152196 print ("BUilding single project" )
153197 build_proj_with_coverage (project )
154198
199+ cmd = [
200+ "python3" ,
201+ "infra/helper.py" ,
202+ "coverage" ,
203+ "--no-corpus-download" ,
204+ "--fuzz-target" ,
205+ target ,
206+ "--corpus-dir" ,
207+ corpus_dir ,
208+ project_name
209+ ]
155210 try :
156- subprocess .check_call ("python3 infra/helper.py coverage --no-corpus-download --fuzz-target %s --corpus-dir %s %s" % ( target , corpus_dir , project_name ), shell = True ) #, timeout=60 )
211+ subprocess .check_call (" " . join ( cmd ) )
157212 except :
158213 print ("Could not run coverage reports" )
159214
0 commit comments