Skip to content
Snippets Groups Projects
Commit 943ba10b authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[crowbar] modify test to check for correct pretty-print of ghost else

parent 6026b072
No related branches found
No related tags found
No related merge requests found
...@@ -65,7 +65,7 @@ let prepare () = ...@@ -65,7 +65,7 @@ let prepare () =
Kernel.set_warn_status Kernel.wkey_ghost_bad_use Log.Wabort; Kernel.set_warn_status Kernel.wkey_ghost_bad_use Log.Wabort;
Messages.reset_once_flag (); Messages.reset_once_flag ();
return.skind <- Return (None, Loc.unknown); return.skind <- Return (None, Loc.unknown);
forward_goto_target.labels <- [Label("Unreach", Loc.unknown, false)]; forward_goto_target.labels <- [Label("Unreach", Loc.unknown, true)];
let old = Project.current () in let old = Project.current () in
Project.set_current (Project.create "simple project"); Project.set_current (Project.create "simple project");
Project.remove ~project:old () Project.remove ~project:old ()
...@@ -133,7 +133,7 @@ let mk_label = ...@@ -133,7 +133,7 @@ let mk_label =
| [] -> | [] ->
incr nb; incr nb;
let name = "L" ^ (string_of_int !nb) in let name = "L" ^ (string_of_int !nb) in
stmt.labels <- [ Label (name, Loc.unknown, false) ] stmt.labels <- [ Label (name, Loc.unknown, true) ]
| _ -> () | _ -> ()
(* approximation for gotos: if all the statements we jump over are ghost, we (* approximation for gotos: if all the statements we jump over are ghost, we
...@@ -503,8 +503,35 @@ let check_file (env, file) = ...@@ -503,8 +503,35 @@ let check_file (env, file) =
in in
if env.should_fail && success then if env.should_fail && success then
report file_name "Found ghost code that should not have been accepted" report file_name "Found ghost code that should not have been accepted"
else if not (env.should_fail) && not success then else if not (env.should_fail) then begin
report file_name "Found ghost code that should have been accepted" if success then begin
let norm_buf = Buffer.create 150 in
let fmt = Format.formatter_of_buffer norm_buf in
let f = Globals.Functions.find_by_name "f" in
Kernel_function.pretty fmt f;
let prj2 = Project.create "copy" in
Project.set_current prj2;
Kernel.Files.set [ Filepath.Normalized.of_string file_name ];
File.init_from_cmdline ();
let copy_buf = Buffer.create 150 in
let fmt = Format.formatter_of_buffer copy_buf in
let f = Globals.Functions.find_by_name "f" in
Kernel_function.pretty fmt f;
if Buffer.contents norm_buf <> Buffer.contents copy_buf then begin
let norm = open_out (file_name ^ ".norm.c") in
Buffer.output_buffer norm norm_buf;
flush norm;
close_out norm;
let copy = open_out (file_name ^ ".copy.c") in
Buffer.output_buffer copy copy_buf;
flush copy;
close_out copy;
report file_name "Found ghost code not well pretty-printed"
end else true
end
else
report file_name "Found ghost code that should have been accepted"
end
else true else true
let () = let () =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment