File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33require 'coverage'
4+ require 'base64'
45
56# Is the `fuzz` function defined in the fuzz target?
67def fuzz_function_exists? ( file_path )
@@ -33,8 +34,15 @@ def fuzz_function_exists?(file_path)
3334reader , writer = IO . pipe
3435
3536fork do
37+ seen = { }
3638 loop do
37- puts "reading from IO pipe: #{ reader . gets . strip } "
39+ encoded_bytes , cov_hash = reader . gets . strip . split ( '_' )
40+ decoded_bytes = Base64 . strict_decode64 ( encoded_bytes )
41+
42+ if !seen . include? ( cov_hash )
43+ seen [ cov_hash ] = Base64 . strict_decode64 ( encoded_bytes )
44+ puts ( seen )
45+ end
3846 end
3947end
4048
@@ -45,15 +53,17 @@ def fuzz_function_exists?(file_path)
4553
4654 Coverage . start ( :all )
4755
56+ bytes = Random . new . bytes ( 10 )
57+
4858 begin
4959 load ( file_path )
50- fuzz ( Random . new . bytes ( 10 ) )
60+ fuzz ( bytes )
5161 rescue => e
5262 puts "Encountered an exception: #{ e } "
5363 exit ( 1 )
5464 end
5565
56- writer . puts ( Coverage . result . hash )
66+ writer . puts ( Base64 . strict_encode64 ( bytes ) + '_' + Coverage . result . hash . to_s )
5767 end
5868 Process . wait
5969end
You can’t perform that action at this time.
0 commit comments