@@ -73,7 +73,7 @@ let frontend ~macros ~incl_dirs ~incl_files astprints ~filename ~magic_comment_c
73
73
idents = [ Alloc.History. (str, sym, None ) ]
74
74
}
75
75
in
76
- let @ _ , ail_prog_opt, prog0 =
76
+ let @ cabs_tunit_opt , ail_prog_opt, prog0 =
77
77
c_frontend_and_elaboration ~cn_init_scope (conf, io) (stdlib, impl) ~filename
78
78
in
79
79
let @ () =
@@ -83,6 +83,7 @@ let frontend ~macros ~incl_dirs ~incl_files astprints ~filename ~magic_comment_c
83
83
else
84
84
return ()
85
85
in
86
+ let cabs_tunit = Option. get cabs_tunit_opt in
86
87
let markers_env, ail_prog = Option. get ail_prog_opt in
87
88
Tags. set_tagDefs prog0.Core. tagDefs;
88
89
let prog1 = Remove_unspecs. rewrite_file prog0 in
@@ -91,7 +92,7 @@ let frontend ~macros ~incl_dirs ~incl_files astprints ~filename ~magic_comment_c
91
92
let statement_locs = CStatements. search (snd ail_prog) in
92
93
print_log_file (" original" , CORE prog0);
93
94
print_log_file (" without_unspec" , CORE prog1);
94
- return (prog3, (markers_env, ail_prog), statement_locs)
95
+ return (cabs_tunit, prog3, (markers_env, ail_prog), statement_locs)
95
96
96
97
97
98
let handle_frontend_error = function
@@ -132,14 +133,15 @@ let with_well_formedness_check
132
133
~(* Callbacks *)
133
134
handle_error
134
135
~(f :
136
+ cabs_tunit:CF.Cabs.translation_unit ->
135
137
prog5:unit Mucore.file ->
136
138
ail_prog:CF.GenTypes.genTypeCategory A.ail_program ->
137
139
statement_locs:Cerb_location.t CStatements.LocMap.t ->
138
140
paused:_ Typing.pause ->
139
141
unit Or_TypeError.t )
140
142
=
141
143
check_input_file filename;
142
- let prog, (markers_env, ail_prog), statement_locs =
144
+ let cabs_tunit, prog, (markers_env, ail_prog), statement_locs =
143
145
handle_frontend_error
144
146
(frontend
145
147
~macros
@@ -169,7 +171,7 @@ let with_well_formedness_check
169
171
Typing. run_to_pause Context. empty (Check. check_decls_lemmata_fun_specs prog5)
170
172
in
171
173
Result. iter_error handle_error (Typing. pause_to_result paused);
172
- f ~prog5 ~ail_prog ~statement_locs ~paused
174
+ f ~cabs_tunit ~ prog5 ~ail_prog ~statement_locs ~paused
173
175
in
174
176
Pp. maybe_close_times_channel () ;
175
177
Result. fold ~ok: (fun () -> exit 0 ) ~error: handle_error result
@@ -250,7 +252,8 @@ let well_formed
250
252
~no_inherit_loc
251
253
~magic_comment_char_dollar
252
254
~handle_error: (handle_type_error ~json ?output_dir ~serialize_json: json_trace)
253
- ~f: (fun ~prog5 :_ ~ail_prog :_ ~statement_locs :_ ~paused :_ -> Or_TypeError. return () )
255
+ ~f: (fun ~cabs_tunit :_ ~prog5 :_ ~ail_prog :_ ~statement_locs :_ ~paused :_ ->
256
+ Or_TypeError. return () )
254
257
255
258
256
259
let verify
@@ -321,7 +324,7 @@ let verify
321
324
~no_inherit_loc
322
325
~magic_comment_char_dollar (* Callbacks *)
323
326
~handle_error: (handle_type_error ~json ?output_dir ~serialize_json: json_trace)
324
- ~f: (fun ~prog5 :_ ~ail_prog :_ ~statement_locs :_ ~paused ->
327
+ ~f: (fun ~cabs_tunit : _ ~ prog5 :_ ~ail_prog :_ ~statement_locs :_ ~paused ->
325
328
let check (functions , global_var_constraints , lemmas ) =
326
329
let open Typing in
327
330
let @ errors = Check. time_check_c_functions (global_var_constraints, functions) in
@@ -413,7 +416,7 @@ let generate_executable_specs
413
416
~no_inherit_loc
414
417
~magic_comment_char_dollar (* Callbacks *)
415
418
~handle_error: (handle_type_error ~json ?output_dir ~serialize_json: json_trace)
416
- ~f: (fun ~prog5 ~ail_prog ~statement_locs ~paused :_ ->
419
+ ~f: (fun ~cabs_tunit : _ ~ prog5 ~ail_prog ~statement_locs ~paused :_ ->
417
420
Cerb_colour. without_colour
418
421
(fun () ->
419
422
(try
@@ -457,6 +460,7 @@ let run_tests
457
460
max_backtracks
458
461
max_unfolds
459
462
max_array_length
463
+ with_static_hack
460
464
input_timeout
461
465
null_in_every
462
466
seed
@@ -495,25 +499,45 @@ let run_tests
495
499
~no_inherit_loc
496
500
~magic_comment_char_dollar (* Callbacks *)
497
501
~handle_error
498
- ~f: (fun ~prog5 ~ail_prog ~statement_locs ~paused :_ ->
502
+ ~f: (fun ~cabs_tunit ~prog5 ~ail_prog ~statement_locs ~paused :_ ->
503
+ let config : TestGeneration.config =
504
+ { num_samples;
505
+ max_backtracks;
506
+ max_unfolds;
507
+ max_array_length;
508
+ with_static_hack;
509
+ input_timeout;
510
+ null_in_every;
511
+ seed;
512
+ logging_level;
513
+ progress_level;
514
+ interactive;
515
+ until_timeout;
516
+ exit_fast;
517
+ max_stack_depth;
518
+ allowed_depth_failures;
519
+ max_generator_size;
520
+ random_size_splits;
521
+ allowed_size_split_backtracks;
522
+ sized_null;
523
+ coverage;
524
+ disable_passes
525
+ }
526
+ in
527
+ TestGeneration. set_config config;
528
+ let _, sigma = ail_prog in
529
+ if
530
+ List. is_empty
531
+ (TestGeneration. functions_under_test ~with_warning: true cabs_tunit sigma prog5)
532
+ then (
533
+ print_endline " No testable functions, trivially passing" ;
534
+ exit 0 );
535
+ if not (Sys. file_exists output_dir) then (
536
+ print_endline (" Directory \" " ^ output_dir ^ " \" does not exist." );
537
+ Sys. mkdir output_dir 0o777 ;
538
+ print_endline (" Created directory \" " ^ output_dir ^ " \" with full permissions." ));
499
539
Cerb_colour. without_colour
500
540
(fun () ->
501
- if
502
- prog5
503
- |> Executable_spec_extract. collect_instrumentation
504
- |> fst
505
- |> List. filter (fun (inst : Executable_spec_extract.instrumentation ) ->
506
- Option. is_some inst.internal)
507
- |> List. is_empty
508
- then (
509
- print_endline " No testable functions, trivially passing" ;
510
- exit 0 );
511
- if not (Sys. file_exists output_dir) then (
512
- print_endline (" Directory \" " ^ output_dir ^ " \" does not exist." );
513
- Sys. mkdir output_dir 0o777 ;
514
- print_endline
515
- (" Created directory \" " ^ output_dir ^ " \" with full permissions." ));
516
- let _, sigma = ail_prog in
517
541
Cn_internal_to_ail. augment_record_map (BaseTypes. Record [] );
518
542
(try
519
543
Executable_spec. main
@@ -528,35 +552,12 @@ let run_tests
528
552
statement_locs
529
553
with
530
554
| e -> handle_error_with_user_guidance ~label: " CN-Exec" e);
531
- let config : TestGeneration.config =
532
- { num_samples;
533
- max_backtracks;
534
- max_unfolds;
535
- max_array_length;
536
- input_timeout;
537
- null_in_every;
538
- seed;
539
- logging_level;
540
- progress_level;
541
- interactive;
542
- until_timeout;
543
- exit_fast;
544
- max_stack_depth;
545
- allowed_depth_failures;
546
- max_generator_size;
547
- random_size_splits;
548
- allowed_size_split_backtracks;
549
- sized_null;
550
- coverage;
551
- disable_passes
552
- }
553
- in
554
555
(try
555
556
TestGeneration. run
556
557
~output_dir
557
558
~filename
558
559
~without_ownership_checking
559
- config
560
+ cabs_tunit
560
561
sigma
561
562
prog5
562
563
with
@@ -949,6 +950,14 @@ module Testing_flags = struct
949
950
& info [ " max-array-length" ] ~doc )
950
951
951
952
953
+ let with_static_hack =
954
+ let doc =
955
+ " (HACK) Use an `#include` instead of linking to build testing. Necessary until \
956
+ https://github.com/rems-project/cerberus/issues/784 or equivalent."
957
+ in
958
+ Arg. (value & flag & info [ " with-static-hack" ] ~doc )
959
+
960
+
952
961
let input_timeout =
953
962
let doc = " Timeout for discarding a generation attempt (ms)" in
954
963
Arg. (
@@ -1104,6 +1113,7 @@ let testing_cmd =
1104
1113
$ Testing_flags. gen_backtrack_attempts
1105
1114
$ Testing_flags. gen_max_unfolds
1106
1115
$ Testing_flags. max_array_length
1116
+ $ Testing_flags. with_static_hack
1107
1117
$ Testing_flags. input_timeout
1108
1118
$ Testing_flags. null_in_every
1109
1119
$ Testing_flags. seed
0 commit comments