28
28
JCC_DIR = '/usr/local/bin'
29
29
30
30
31
- def run_experiment (project_name , target_name , args , output_path ,
31
+ def run_experiment (project_name , target_name , args , output_path , errlog_path ,
32
32
build_output_path , upload_corpus_path , upload_coverage_path ,
33
33
experiment_name , upload_reproducer_path ):
34
34
config = build_project .Config (testing = True ,
@@ -72,6 +72,7 @@ def run_experiment(project_name, target_name, args, output_path,
72
72
73
73
build = build_project .Build ('libfuzzer' , 'address' , 'x86_64' )
74
74
local_output_path = '/workspace/output.log'
75
+ local_jcc_err_path = '/workspace/err.log' # From jcc.go:360.
75
76
local_corpus_path_base = '/workspace/corpus'
76
77
local_corpus_path = os .path .join (local_corpus_path_base , target_name )
77
78
default_target_path = os .path .join (build .out , target_name )
@@ -81,6 +82,24 @@ def run_experiment(project_name, target_name, args, output_path,
81
82
local_stacktrace_path = os .path .join (build .out , 'stacktrace/' )
82
83
fuzzer_args = ' ' .join (args + [f'-artifact_prefix={ local_artifact_path } ' ])
83
84
85
+ # Upload JCC's err.log.
86
+ if errlog_path :
87
+ compile_step_index = - 1
88
+ for i , step in enumerate (steps ):
89
+ step_args = step .get ('args' , [])
90
+ if '&& compile' in ' ' .join (step_args ):
91
+ compile_step_index = i
92
+ break
93
+ if compile_step_index == - 1 :
94
+ print ('Cannot find compile step.' )
95
+ else :
96
+ # Insert the upload step right after compile step.
97
+ upload_jcc_err_step = {
98
+ 'name' : 'gcr.io/cloud-builders/gsutil' ,
99
+ 'args' : ['cp' , local_jcc_err_path , errlog_path ]
100
+ }
101
+ steps .insert (compile_step_index + 1 , upload_jcc_err_step )
102
+
84
103
env = build_project .get_env (project_yaml ['language' ], build )
85
104
env .append ('RUN_FUZZER_MODE=batch' )
86
105
env .append ('CORPUS_DIR=' + local_corpus_path )
@@ -268,6 +287,10 @@ def main():
268
287
parser .add_argument ('--upload_build_log' ,
269
288
required = True ,
270
289
help = 'GCS build log location.' )
290
+ parser .add_argument ('--upload_err_log' ,
291
+ required = False ,
292
+ default = '' ,
293
+ help = 'GCS JCC error log location.' )
271
294
parser .add_argument ('--upload_output_log' ,
272
295
required = True ,
273
296
help = 'GCS log location.' )
@@ -287,7 +310,7 @@ def main():
287
310
args = parser .parse_args ()
288
311
289
312
run_experiment (args .project , args .target , args .args , args .upload_output_log ,
290
- args .upload_build_log , args .upload_corpus ,
313
+ args .upload_err_log , args . upload_build_log , args .upload_corpus ,
291
314
args .upload_coverage , args .experiment_name ,
292
315
args .upload_reproducer )
293
316
0 commit comments