-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Enable OWI fuzzer.ml to save generated WASM modules to local dir #463
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,11 @@ let timeout_count = ref 0 | |
|
||
let global_count = ref 0 | ||
|
||
let write_module filename m = | ||
let oc = open_out filename in | ||
Fmt.pf (Format.formatter_of_out_channel oc) "%a@." Owi.Text.pp_modul m; | ||
close_out oc | ||
|
||
let compare (module I1 : Interprets.INTERPRET) | ||
(module I2 : Interprets.INTERPRET) m = | ||
if Param.debug then begin | ||
|
@@ -69,6 +74,20 @@ let compare (module I1 : Interprets.INTERPRET) | |
|
||
let check (module I1 : Interprets.INTERPRET) (module I2 : Interprets.INTERPRET) | ||
m = | ||
(* Save the generated module *) | ||
if Param.save_modules then ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the case of |
||
(* Create output directory if it doesn't exist *) | ||
if not (Sys.file_exists Param.output_dir) then | ||
Unix.mkdir Param.output_dir 0o755; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use |
||
|
||
let filename = Printf.sprintf "%s/gen_do_module_%d.wat" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use |
||
Param.output_dir !global_count in | ||
write_module filename m; | ||
|
||
if Param.debug then | ||
Fmt.epr "Saved module to %s@\n" filename; | ||
); | ||
|
||
compare (module I1) (module I2) m | ||
|
||
let add_test name gen (module I1 : Interprets.INTERPRET) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,7 @@ let initial_fuel = 100 | |
let allow_partial_timeout = true | ||
|
||
let max_time_execution = 0.01 (* seconds *) | ||
|
||
let save_modules = true (* Set to false to disable saving modules *) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would set this to false by default because this is quite likely to make the fuzzing much more slower |
||
|
||
let output_dir = "generated_modules" (* Directory to save modules *) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use
Bos.OS.File.writef
instead ? You have an example here. It forces you to handle error properly (I just realizedopen_out
is hidden by theprelude
library in the whole code-base but not in the fuzzer...).