5
5
use std:: env;
6
6
use std:: fs:: { read_dir, File } ;
7
7
use std:: path:: Path ;
8
- use std:: process:: { exit, Command , Stdio } ;
8
+ use std:: process:: { exit, Command } ;
9
9
use std:: str;
10
10
11
11
const LLVM_PROFDATA : & str = "llvm-profdata" ;
12
12
const LLVM_COV : & str = "llvm-cov" ;
13
- const DIFF : & str = "diff " ;
13
+ const GIT : & str = "git " ;
14
14
15
15
fn exit_help ( err : & str ) -> ! {
16
16
eprintln ! ( "Error: {}" , err) ;
17
17
eprintln ! ( ) ;
18
- eprintln ! ( "Usage: program ./build_dir ./qa-assets-corpora-dir fuzz_target " ) ;
18
+ eprintln ! ( "Usage: program ./build_dir ./qa-assets/fuzz_corpora fuzz_target_name " ) ;
19
19
eprintln ! ( ) ;
20
20
eprintln ! ( "Refer to the devtools/README.md for more details." ) ;
21
21
exit ( 1 )
22
22
}
23
23
24
24
fn sanity_check ( corpora_dir : & Path , fuzz_exe : & Path ) {
25
- for tool in [ LLVM_PROFDATA , LLVM_COV , DIFF ] {
26
- let output = Command :: new ( tool) . arg ( "--version " ) . output ( ) ;
25
+ for tool in [ LLVM_PROFDATA , LLVM_COV , GIT ] {
26
+ let output = Command :: new ( tool) . arg ( "--help " ) . output ( ) ;
27
27
match output {
28
28
Ok ( output) if output. status . success ( ) => { }
29
29
_ => {
@@ -135,7 +135,7 @@ fn deterministic_coverage(
135
135
. expect( "merge failed" )
136
136
. success( ) ) ;
137
137
let cov_file = File :: create ( & cov_txt_path) . expect ( "Failed to create coverage txt file" ) ;
138
- let passed = Command :: new ( LLVM_COV )
138
+ assert ! ( Command :: new( LLVM_COV )
139
139
. args( [
140
140
"show" ,
141
141
"--show-line-counts-or-regions" ,
@@ -144,34 +144,31 @@ fn deterministic_coverage(
144
144
& format!( "--instr-profile={}" , profdata_file. display( ) ) ,
145
145
] )
146
146
. arg( fuzz_exe)
147
- . stdout ( Stdio :: from ( cov_file) )
147
+ . stdout( cov_file)
148
148
. spawn( )
149
149
. expect( "Failed to execute llvm-cov" )
150
150
. wait( )
151
151
. expect( "Failed to execute llvm-cov" )
152
- . success ( ) ;
153
- if !passed {
154
- panic ! ( "Failed to execute llvm-profdata" )
155
- }
152
+ . success( ) ) ;
156
153
cov_txt_path
157
154
} ;
158
155
let check_diff = |a : & Path , b : & Path , err : & str | {
159
- let same = Command :: new ( DIFF )
160
- . arg ( "--unified" )
156
+ let same = Command :: new ( GIT )
157
+ . args ( [ "--no-pager" , "diff" , "--no-index" ] )
161
158
. arg ( a)
162
159
. arg ( b)
163
160
. status ( )
164
- . expect ( "Failed to execute diff command" )
161
+ . expect ( "Failed to execute git command" )
165
162
. success ( ) ;
166
163
if !same {
167
164
eprintln ! ( ) ;
168
- eprintln ! ( "The coverage was not determinstic between runs." ) ;
165
+ eprintln ! ( "The coverage was not deterministic between runs." ) ;
169
166
eprintln ! ( "{}" , err) ;
170
167
eprintln ! ( "Exiting." ) ;
171
168
exit ( 1 ) ;
172
169
}
173
170
} ;
174
- // First, check that each fuzz input is determinisic running by itself in a process.
171
+ // First, check that each fuzz input is deterministic running by itself in a process.
175
172
//
176
173
// This can catch issues and isolate where a single fuzz input triggers non-determinism, but
177
174
// all other fuzz inputs are deterministic.
0 commit comments