@@ -120,12 +120,12 @@ fn deterministic_coverage(
120
120
. map ( |entry| entry. expect ( "IO error" ) )
121
121
. collect :: < Vec < _ > > ( ) ;
122
122
entries. sort_by_key ( |entry| entry. file_name ( ) ) ;
123
- let run_single = |run_id : u8 , entry : & Path , thread_id : usize | -> Result < PathBuf , AppError > {
124
- let cov_txt_path = build_dir. join ( format ! ( "fuzz_det_cov.show.t{thread_id}.r {run_id}.txt" ) ) ;
125
- let profraw_file = build_dir. join ( format ! ( "fuzz_det_cov.t{thread_id}.r {run_id}.profraw" ) ) ;
126
- let profdata_file = build_dir. join ( format ! ( "fuzz_det_cov.t{thread_id}.r {run_id}.profdata" ) ) ;
127
- if ! {
128
- {
123
+ let run_single = |run_id : char , entry : & Path , thread_id : usize | -> Result < PathBuf , AppError > {
124
+ let cov_txt_path = build_dir. join ( format ! ( "fuzz_det_cov.show.t{thread_id}.{run_id}.txt" ) ) ;
125
+ let profraw_file = build_dir. join ( format ! ( "fuzz_det_cov.t{thread_id}.{run_id}.profraw" ) ) ;
126
+ let profdata_file = build_dir. join ( format ! ( "fuzz_det_cov.t{thread_id}.{run_id}.profdata" ) ) ;
127
+ {
128
+ let output = {
129
129
let mut cmd = Command :: new ( fuzz_exe) ;
130
130
if using_libfuzzer {
131
131
cmd. arg ( "-runs=1" ) ;
@@ -135,11 +135,15 @@ fn deterministic_coverage(
135
135
. env ( "LLVM_PROFILE_FILE" , & profraw_file)
136
136
. env ( "FUZZ" , fuzz_target)
137
137
. arg ( entry)
138
- . status ( )
139
- . map_err ( |e| format ! ( "fuzz failed with {e}" ) ) ?
140
- . success ( )
141
- } {
142
- Err ( "fuzz failed" . to_string ( ) ) ?;
138
+ . output ( )
139
+ . map_err ( |e| format ! ( "fuzz failed: {e}" ) ) ?;
140
+ if !output. status . success ( ) {
141
+ Err ( format ! (
142
+ "fuzz failed!\n stdout:\n {}\n stderr:\n {}\n " ,
143
+ String :: from_utf8_lossy( & output. stdout) ,
144
+ String :: from_utf8_lossy( & output. stderr)
145
+ ) ) ?;
146
+ }
143
147
}
144
148
if !Command :: new ( LLVM_PROFDATA )
145
149
. arg ( "merge" )
@@ -210,8 +214,8 @@ The coverage was not deterministic between runs.
210
214
if !entry. is_file ( ) {
211
215
Err ( format ! ( "{} should be a file" , entry. display( ) ) ) ?;
212
216
}
213
- let cov_txt_base = run_single ( 0 , & entry, thread_id) ?;
214
- let cov_txt_repeat = run_single ( 1 , & entry, thread_id) ?;
217
+ let cov_txt_base = run_single ( 'a' , & entry, thread_id) ?;
218
+ let cov_txt_repeat = run_single ( 'b' , & entry, thread_id) ?;
215
219
check_diff (
216
220
& cov_txt_base,
217
221
& cov_txt_repeat,
@@ -249,23 +253,23 @@ The coverage was not deterministic between runs.
249
253
if !corpus_dir. is_dir ( ) {
250
254
Err ( format ! ( "{} should be a folder" , corpus_dir. display( ) ) ) ?;
251
255
}
252
- let cov_txt_base = run_single ( 0 , & corpus_dir, 0 ) ?;
253
- let cov_txt_repeat = run_single ( 1 , & corpus_dir, 0 ) ?;
256
+ let cov_txt_base = run_single ( 'a' , & corpus_dir, 0 ) ?;
257
+ let cov_txt_repeat = run_single ( 'b' , & corpus_dir, 0 ) ?;
254
258
check_diff (
255
259
& cov_txt_base,
256
260
& cov_txt_repeat,
257
261
& format ! ( "All fuzz inputs in {} were used." , corpus_dir. display( ) ) ,
258
262
) ?;
259
263
}
260
- println ! ( "Coverage test passed for {fuzz_target}." ) ;
264
+ println ! ( "✨ Coverage test passed for {fuzz_target}. ✨ " ) ;
261
265
Ok ( ( ) )
262
266
}
263
267
264
268
fn main ( ) -> ExitCode {
265
269
match app ( ) {
266
270
Ok ( ( ) ) => ExitCode :: SUCCESS ,
267
271
Err ( err) => {
268
- eprintln ! ( "{}" , err) ;
272
+ eprintln ! ( "⚠️ \n {}" , err) ;
269
273
ExitCode :: FAILURE
270
274
}
271
275
}
0 commit comments