25
25
26
26
def build_proj_with_default (project_name ):
27
27
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
+ )
29
32
except :
30
33
print ("Building default failed" )
31
34
exit (5 )
32
35
36
+
33
37
def build_proj_with_coverage (project_name ):
38
+ cmd = [
39
+ "python3" ,
40
+ "infra/helper.py" ,
41
+ "build_fuzzers" ,
42
+ "--sanitizer=coverage" ,
43
+ project_name
44
+ ]
34
45
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
+ )
36
50
except :
37
51
print ("Building with coverage failed" )
38
52
exit (5 )
39
53
54
+
40
55
def get_fuzzers (project_name ):
41
56
execs = []
42
57
for l in os .listdir ("build/out/%s" % (project_name )):
@@ -48,6 +63,7 @@ def get_fuzzers(project_name):
48
63
print ("Executable files: %s" % (str (execs )))
49
64
return execs
50
65
66
+
51
67
def get_next_corpus_dir ():
52
68
max_idx = - 1
53
69
for f in os .listdir ("." ):
@@ -60,6 +76,7 @@ def get_next_corpus_dir():
60
76
None
61
77
return "corpus-%d" % (max_idx + 1 )
62
78
79
+
63
80
def get_recent_corpus_dir ():
64
81
max_idx = - 1
65
82
for f in os .listdir ("." ):
@@ -72,6 +89,7 @@ def get_recent_corpus_dir():
72
89
None
73
90
return "corpus-%d" % (max_idx )
74
91
92
+
75
93
def run_all_fuzzers (project_name , fuzztime ):
76
94
# First get all fuzzers names
77
95
fuzzer_names = get_fuzzers (project_name )
@@ -85,7 +103,17 @@ def run_all_fuzzers(project_name, fuzztime):
85
103
os .mkdir (target_corpus )
86
104
os .mkdir (target_crashes )
87
105
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
+ ]
89
117
try :
90
118
subprocess .check_call (" " .join (cmd ), shell = True )
91
119
print ("Execution finished without exception" )
@@ -97,6 +125,7 @@ def run_all_fuzzers(project_name, fuzztime):
97
125
if "crash-" in l or "leak-" in l :
98
126
shutil .move (l , target_crashes )
99
127
128
+
100
129
def get_coverage (project_name ):
101
130
#1 Find all coverage reports
102
131
corpus_dir = get_recent_corpus_dir ()
@@ -105,23 +134,37 @@ def get_coverage(project_name):
105
134
for f in os .listdir (corpus_dir ):
106
135
if os .path .isdir ("build/corpus/%s/%s" % (project_name , f )):
107
136
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
+ )
109
141
110
142
#3 run coverage command
143
+ cmd = [
144
+ "python3" ,
145
+ "infra/helper.py" ,
146
+ "coverage" ,
147
+ "--no-corpus-download" ,
148
+ project_name
149
+ ]
111
150
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
+ )
113
155
except :
114
156
print ("Could not run coverage reports" )
115
157
116
158
117
- #try:
118
- # subprocess.check_call("docker kill $(docker ps -qa)", shell=True)
119
- #except:
120
- # None
121
-
122
159
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
+ )
125
168
try :
126
169
summary_file = "build/out/%s/report/linux/summary.json" % (project_name )
127
170
with open (summary_file , "r" ) as fj :
@@ -148,12 +191,24 @@ def complete_coverage_check(project_name, fuzztime):
148
191
149
192
return percent
150
193
194
+
151
195
def get_single_cov (project , target , corpus_dir ):
152
196
print ("BUilding single project" )
153
197
build_proj_with_coverage (project )
154
198
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
+ ]
155
210
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 ) )
157
212
except :
158
213
print ("Could not run coverage reports" )
159
214
0 commit comments