55use std:: env;
66use std:: fs:: { read_dir, File } ;
77use std:: path:: Path ;
8- use std:: process:: { exit, Command , Stdio } ;
8+ use std:: process:: { exit, Command } ;
99use std:: str;
1010
1111const LLVM_PROFDATA : & str = "llvm-profdata" ;
1212const LLVM_COV : & str = "llvm-cov" ;
13- const DIFF : & str = "diff " ;
13+ const GIT : & str = "git " ;
1414
1515fn exit_help ( err : & str ) -> ! {
1616 eprintln ! ( "Error: {}" , err) ;
1717 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 " ) ;
1919 eprintln ! ( ) ;
2020 eprintln ! ( "Refer to the devtools/README.md for more details." ) ;
2121 exit ( 1 )
2222}
2323
2424fn 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 ( ) ;
2727 match output {
2828 Ok ( output) if output. status . success ( ) => { }
2929 _ => {
@@ -135,7 +135,7 @@ fn deterministic_coverage(
135135 . expect( "merge failed" )
136136 . success( ) ) ;
137137 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 )
139139 . args( [
140140 "show" ,
141141 "--show-line-counts-or-regions" ,
@@ -144,34 +144,31 @@ fn deterministic_coverage(
144144 & format!( "--instr-profile={}" , profdata_file. display( ) ) ,
145145 ] )
146146 . arg( fuzz_exe)
147- . stdout ( Stdio :: from ( cov_file) )
147+ . stdout( cov_file)
148148 . spawn( )
149149 . expect( "Failed to execute llvm-cov" )
150150 . wait( )
151151 . expect( "Failed to execute llvm-cov" )
152- . success ( ) ;
153- if !passed {
154- panic ! ( "Failed to execute llvm-profdata" )
155- }
152+ . success( ) ) ;
156153 cov_txt_path
157154 } ;
158155 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" ] )
161158 . arg ( a)
162159 . arg ( b)
163160 . status ( )
164- . expect ( "Failed to execute diff command" )
161+ . expect ( "Failed to execute git command" )
165162 . success ( ) ;
166163 if !same {
167164 eprintln ! ( ) ;
168- eprintln ! ( "The coverage was not determinstic between runs." ) ;
165+ eprintln ! ( "The coverage was not deterministic between runs." ) ;
169166 eprintln ! ( "{}" , err) ;
170167 eprintln ! ( "Exiting." ) ;
171168 exit ( 1 ) ;
172169 }
173170 } ;
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.
175172 //
176173 // This can catch issues and isolate where a single fuzz input triggers non-determinism, but
177174 // all other fuzz inputs are deterministic.
0 commit comments