-
Notifications
You must be signed in to change notification settings - Fork 38
Model with entry point #699
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
base: main
Are you sure you want to change the base?
Changes from 3 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 |
|---|---|---|
|
|
@@ -261,19 +261,19 @@ let run_file ~unsafe ~optimize ~entry_point ~invoke_with_symbols filename model | |
|
|
||
| let cmd ~unsafe ~optimize ~replay_file ~source_file ~entry_point | ||
| ~invoke_with_symbols = | ||
| let file_ext = Fpath.get_ext replay_file in | ||
| let* parse_fn = | ||
| let ext = Fpath.get_ext replay_file in | ||
| match String.lowercase_ascii ext with | ||
| match String.lowercase_ascii file_ext with | ||
| | ".json" -> Ok Symbol_scope.model_of_json | ||
| | ".scfg" -> Ok Symbol_scope.model_of_scfg | ||
| | _ -> Error (`Unsupported_file_extension ext) | ||
| | _ -> Error (`Unsupported_file_extension file_ext) | ||
| in | ||
| let* file_content = Bos.OS.File.read replay_file in | ||
| let* model = | ||
| let* model_entry_point, model = | ||
| match parse_fn file_content with | ||
| | Error (`Msg msg) -> Error (`Invalid_model msg) | ||
| | Error err -> Error err | ||
| | Ok model -> | ||
| | Ok (entry_point, model) -> | ||
| let bindings = Smtml.Model.get_bindings model in | ||
| let+ model = | ||
| list_map | ||
|
|
@@ -298,8 +298,13 @@ let cmd ~unsafe ~optimize ~replay_file ~source_file ~entry_point | |
| (Fmt.str "unexpected value type: %a" Smtml.Value.pp v) ) ) | ||
| bindings | ||
| in | ||
| Array.of_list model | ||
| (entry_point, Array.of_list model) | ||
| in | ||
| let entry_point = | ||
| if Option.is_none entry_point then model_entry_point else entry_point | ||
|
Member
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. Does it make sense to keep the
Collaborator
Author
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 guess not, I'll remove the option |
||
| in | ||
| Logs.debug (fun m -> m "%s" (Option.value ~default:"na" entry_point)); | ||
| Logs.debug (fun m -> m "%s" (Option.value ~default:"na" model_entry_point)); | ||
S41d marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| let+ () = | ||
| run_file ~unsafe ~optimize ~entry_point ~invoke_with_symbols source_file | ||
| model | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,8 @@ let run_file ~entry_point ~unsafe ~rac ~srac ~optimize ~invoke_with_symbols _pc | |
| Interpret.Symbolic.modul link_state.envs m | ||
|
|
||
| let print_bug ~model_format ~model_out_file ~id ~no_value ~no_stop_at_failure | ||
| ~no_assert_failure_expression_printing ~with_breadcrumbs bug = | ||
| ~no_assert_failure_expression_printing ~with_breadcrumbs | ||
| ~model_with_entry_point ~entry_point bug = | ||
| let pp fmt (model, labels, breadcrumbs, scoped_values) = | ||
| match model_format with | ||
| | Cmd_utils.Json -> | ||
|
|
@@ -62,7 +63,8 @@ let print_bug ~model_format ~model_out_file ~id ~no_value ~no_stop_at_failure | |
| } ) | ||
| labels | ||
| in | ||
| let children = | ||
| let model = { model with children = model.children @ lbls } in | ||
| let model = | ||
| if with_breadcrumbs then | ||
| let bcrumbs = | ||
| [ { Scfg.Types.name = "breadcrumbs" | ||
|
|
@@ -71,10 +73,22 @@ let print_bug ~model_format ~model_out_file ~id ~no_value ~no_stop_at_failure | |
| } | ||
| ] | ||
| in | ||
| model.children @ lbls @ bcrumbs | ||
| else model.children @ lbls | ||
| { model with children = model.children @ bcrumbs } | ||
| else model | ||
| in | ||
| Scfg.Pp.directive fmt { model with children } | ||
| let model = | ||
| if model_with_entry_point then | ||
| let ep = | ||
| [ { Scfg.Types.name = "entry_point" | ||
| ; params = [ entry_point ] | ||
| ; children = [] | ||
| } | ||
| ] | ||
| in | ||
| { model with children = model.children @ ep } | ||
| else model | ||
| in | ||
|
Member
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. Do you think we could put the entry point first in the output model (followed by the symbols)? I find it easier to read this way
Collaborator
Author
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. sure, i'll do that |
||
| Scfg.Pp.directive fmt model | ||
| in | ||
| let to_file path model labels breadcrumbs symbol_scopes = | ||
| let model_ext = match model_format with Json -> "json" | Scfg -> "scfg" in | ||
|
|
@@ -117,7 +131,7 @@ let print_bug ~model_format ~model_out_file ~id ~no_value ~no_stop_at_failure | |
|
|
||
| let print_and_count_failures ~model_format ~model_out_file ~no_value | ||
| ~no_assert_failure_expression_printing ~workspace ~no_stop_at_failure | ||
| ~count_acc ~results ~with_breadcrumbs = | ||
| ~count_acc ~results ~with_breadcrumbs ~model_with_entry_point ~entry_point = | ||
| let test_suite_dir = Fpath.(workspace / "test-suite") in | ||
| let* (_created : bool) = | ||
| if not no_value then OS.Dir.create test_suite_dir else Ok false | ||
|
|
@@ -133,7 +147,7 @@ let print_and_count_failures ~model_format ~model_out_file ~no_value | |
| let* () = | ||
| print_bug ~model_format ~model_out_file ~id:count_acc ~no_value | ||
| ~no_stop_at_failure ~no_assert_failure_expression_printing | ||
| ~with_breadcrumbs bug | ||
| ~with_breadcrumbs ~model_with_entry_point ~entry_point bug | ||
| in | ||
| Ok model | ||
| | `Error e -> Error e | ||
|
|
@@ -162,7 +176,7 @@ let sort_results deterministic_result_order results = | |
| let handle_result ~workers ~no_stop_at_failure ~no_value | ||
| ~no_assert_failure_expression_printing ~deterministic_result_order ~fail_mode | ||
| ~workspace ~solver ~model_format ~model_out_file ~with_breadcrumbs | ||
| (result : unit Symbolic.Choice.t) = | ||
| ~model_with_entry_point ~entry_point (result : unit Symbolic.Choice.t) = | ||
| let thread = Thread_with_memory.init () in | ||
| let res_queue = Wq.make () in | ||
| let path_count = Atomic.make 0 in | ||
|
|
@@ -193,10 +207,16 @@ let handle_result ~workers ~no_stop_at_failure ~no_value | |
| Array.iter Domain.join join_handles ) | ||
| in | ||
| let results = sort_results deterministic_result_order results in | ||
| let* entry_point = | ||
| if model_with_entry_point then | ||
| match entry_point with Some ep -> Ok ep | None -> Fmt.error_msg "" | ||
| else Ok "" | ||
S41d marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| in | ||
| let* count = | ||
| print_and_count_failures ~model_format ~model_out_file ~no_value | ||
| ~no_assert_failure_expression_printing ~workspace ~no_stop_at_failure | ||
| ~count_acc:0 ~results ~with_breadcrumbs | ||
| ~count_acc:0 ~results ~with_breadcrumbs ~model_with_entry_point | ||
| ~entry_point | ||
| in | ||
| Logs.info (fun m -> m "Completed paths: %d" (Atomic.get path_count)); | ||
| let+ () = if count > 0 then Error (`Found_bug count) else Ok () in | ||
|
|
@@ -209,7 +229,7 @@ let handle_result ~workers ~no_stop_at_failure ~no_value | |
| let cmd ~unsafe ~rac ~srac ~optimize ~workers ~no_stop_at_failure ~no_value | ||
| ~no_assert_failure_expression_printing ~deterministic_result_order ~fail_mode | ||
| ~workspace ~solver ~files ~model_format ~entry_point ~invoke_with_symbols | ||
| ~model_out_file ~with_breadcrumbs = | ||
| ~model_out_file ~with_breadcrumbs ~model_with_entry_point = | ||
| let* workspace = | ||
| match workspace with | ||
| | Some path -> Ok path | ||
|
|
@@ -226,4 +246,5 @@ let cmd ~unsafe ~rac ~srac ~optimize ~workers ~no_stop_at_failure ~no_value | |
| in | ||
| handle_result ~fail_mode ~workers ~solver ~deterministic_result_order | ||
| ~model_format ~no_value ~no_assert_failure_expression_printing ~workspace | ||
| ~no_stop_at_failure ~model_out_file ~with_breadcrumbs result | ||
| ~no_stop_at_failure ~model_out_file ~with_breadcrumbs | ||
| ~model_with_entry_point ~entry_point result | ||
Uh oh!
There was an error while loading. Please reload this page.