@@ -117,7 +117,6 @@ class bmc_covert:
117
117
118
118
// if satisified, we compute a goto_trace
119
119
bool satisfied;
120
- goto_tracet goto_trace;
121
120
122
121
goalt (
123
122
const std::string &_description,
@@ -143,6 +142,12 @@ class bmc_covert:
143
142
return disjunction (tmp);
144
143
}
145
144
};
145
+
146
+ struct testt
147
+ {
148
+ goto_tracet goto_trace;
149
+ std::vector<irep_idt> covered_goals;
150
+ };
146
151
147
152
inline irep_idt id (goto_programt::const_targett loc)
148
153
{
@@ -151,8 +156,10 @@ class bmc_covert:
151
156
152
157
typedef std::map<irep_idt, goalt> goal_mapt;
153
158
goal_mapt goal_map;
159
+ typedef std::vector<testt> testst;
160
+ testst tests;
154
161
155
- std::string get_test (const goto_tracet &goto_trace)
162
+ std::string get_test (const goto_tracet &goto_trace) const
156
163
{
157
164
bool first=true ;
158
165
std::string test;
@@ -196,6 +203,8 @@ Function: bmc_covert::satisfying_assignment
196
203
197
204
void bmc_covert::satisfying_assignment ()
198
205
{
206
+ tests.push_back (testt ());
207
+ testt &test = tests.back ();
199
208
for (auto &g_it : goal_map)
200
209
{
201
210
goalt &g=g_it.second ;
@@ -212,13 +221,13 @@ void bmc_covert::satisfying_assignment()
212
221
{
213
222
status () << " Covered " << g.description << messaget::eom;
214
223
g.satisfied =true ;
215
- symex_target_equationt::SSA_stepst::iterator next=c_it.step ;
216
- next++; // include the instruction itself
217
- build_goto_trace (bmc.equation , next, solver, bmc.ns , g.goto_trace );
224
+ test.covered_goals .push_back (g_it.first );
218
225
break ;
219
226
}
220
227
}
221
228
}
229
+ build_goto_trace (bmc.equation , bmc.equation .SSA_steps .end (),
230
+ solver, bmc.ns , test.goto_trace );
222
231
}
223
232
224
233
/* ******************************************************************\
@@ -378,88 +387,101 @@ bool bmc_covert::operator()()
378
387
{
379
388
const goalt &goal=it.second ;
380
389
381
- xmlt xml_result (" result " );
382
- xml_result.set_attribute (" goal " , id2string (it.first ));
390
+ xmlt xml_result (" goal " );
391
+ xml_result.set_attribute (" id " , id2string (it.first ));
383
392
xml_result.set_attribute (" description" , goal.description );
384
393
xml_result.set_attribute (" status" , goal.satisfied ?" SATISFIED" :" FAILED" );
385
394
386
395
if (goal.source_location .is_not_nil ())
387
396
xml_result.new_element ()=xml (goal.source_location );
388
397
389
- if (goal.satisfied )
398
+ std::cout << xml_result << " \n " ;
399
+ }
400
+
401
+ for (const auto & test : tests)
402
+ {
403
+ xmlt xml_result (" test" );
404
+ if (bmc.options .get_bool_option (" trace" ))
390
405
{
391
- if (bmc.options .get_bool_option (" trace" ))
392
- {
393
- convert (bmc.ns , goal.goto_trace , xml_result.new_element ());
394
- }
395
- else
396
- {
397
- xmlt &xml_test=xml_result.new_element (" test" );
406
+ convert (bmc.ns , test.goto_trace , xml_result.new_element ());
407
+ }
408
+ else
409
+ {
410
+ xmlt &xml_test=xml_result.new_element (" inputs" );
398
411
399
- for (const auto & step : goal.goto_trace .steps )
412
+ for (const auto & step : test.goto_trace .steps )
413
+ {
414
+ if (step.is_input ())
400
415
{
401
- if (step.is_input ())
402
- {
403
- xmlt &xml_input=xml_test.new_element (" input" );
404
- xml_input.set_attribute (" id" , id2string (step.io_id ));
405
- if (step.io_args .size ()==1 )
406
- xml_input.new_element (" value" )=
407
- xml (step.io_args .front (), bmc.ns );
408
- }
416
+ xmlt &xml_input=xml_test.new_element (" input" );
417
+ xml_input.set_attribute (" id" , id2string (step.io_id ));
418
+ if (step.io_args .size ()==1 )
419
+ xml_input.new_element (" value" )=
420
+ xml (step.io_args .front (), bmc.ns );
409
421
}
410
-
411
422
}
412
423
}
413
424
425
+ for (const auto & goal_id : test.covered_goals )
426
+ {
427
+ xmlt &xml_goal=xml_result.new_element (" goal" );
428
+ xml_goal.set_attribute (" id" , id2string (goal_id));
429
+ }
430
+
414
431
std::cout << xml_result << " \n " ;
415
432
}
416
-
417
433
break ;
418
434
}
419
435
case ui_message_handlert::JSON_UI:
420
436
{
421
437
json_objectt json_result;
422
- json_arrayt &result_array =json_result[" results " ].make_array ();
438
+ json_arrayt &goals_array =json_result[" goals " ].make_array ();
423
439
for (const auto & it : goal_map)
424
440
{
425
441
const goalt &goal=it.second ;
426
442
427
- json_objectt &result=result_array .push_back ().make_object ();
443
+ json_objectt &result=goals_array .push_back ().make_object ();
428
444
result[" status" ]=json_stringt (goal.satisfied ?" satisfied" :" failed" );
429
445
result[" goal" ]=json_stringt (id2string (it.first ));
430
446
result[" description" ]=json_stringt (goal.description );
431
447
432
448
if (goal.source_location .is_not_nil ())
433
449
result[" sourceLocation" ]=json (goal.source_location );
450
+ }
451
+ json_result[" totalGoals" ]=json_numbert (i2string (goal_map.size ()));
452
+ json_result[" goalsCovered" ]=json_numbert (i2string (goals_covered));
434
453
435
- if (goal.satisfied )
454
+ json_arrayt &tests_array=json_result[" tests" ].make_array ();
455
+ for (const auto & test : tests)
456
+ {
457
+ json_objectt &result=tests_array.push_back ().make_object ();
458
+ if (bmc.options .get_bool_option (" trace" ))
436
459
{
437
- if (bmc.options .get_bool_option (" trace" ))
438
- {
439
- jsont &json_trace=result[" trace" ];
440
- convert (bmc.ns , goal.goto_trace , json_trace);
441
- }
442
- else
443
- {
444
- json_arrayt &json_test=result[" test" ].make_array ();
460
+ jsont &json_trace=result[" trace" ];
461
+ convert (bmc.ns , test.goto_trace , json_trace);
462
+ }
463
+ else
464
+ {
465
+ json_arrayt &json_test=result[" inputs" ].make_array ();
445
466
446
- for (const auto & step : goal.goto_trace .steps )
467
+ for (const auto & step : test.goto_trace .steps )
468
+ {
469
+ if (step.is_input ())
447
470
{
448
- if (step.is_input ())
449
- {
450
- json_objectt json_input;
451
- json_input[" id" ]=json_stringt (id2string (step.io_id ));
452
- if (step.io_args .size ()==1 )
453
- json_input[" value" ]=json (step.io_args .front (), bmc.ns );
454
- json_test.push_back (json_input);
455
- }
471
+ json_objectt json_input;
472
+ json_input[" id" ]=json_stringt (id2string (step.io_id ));
473
+ if (step.io_args .size ()==1 )
474
+ json_input[" value" ]=json (step.io_args .front (), bmc.ns );
475
+ json_test.push_back (json_input);
456
476
}
457
-
458
477
}
459
478
}
479
+ json_arrayt &goal_refs=result[" coveredGoals" ].make_array ();
480
+ for (const auto & goal_id : test.covered_goals )
481
+ {
482
+ goal_refs.push_back (json_stringt (id2string (goal_id)));
483
+ }
460
484
}
461
- json_result[" totalGoals" ]=json_numbert (i2string (goal_map.size ()));
462
- json_result[" goalsCovered" ]=json_numbert (i2string (goals_covered));
463
485
std::cout << " ,\n " << json_result;
464
486
break ;
465
487
}
@@ -478,16 +500,10 @@ bool bmc_covert::operator()()
478
500
479
501
if (bmc.ui ==ui_message_handlert::PLAIN)
480
502
{
481
- std::set<std::string> tests;
482
-
483
- for (const auto & it : goal_map)
484
- if (it.second .satisfied )
485
- tests.insert (get_test (it.second .goto_trace ));
486
-
487
503
std::cout << " Test suite:" << ' \n ' ;
488
504
489
- for (const auto & t : tests)
490
- std::cout << t << ' \n ' ;
505
+ for (const auto & test : tests)
506
+ std::cout << get_test (test. goto_trace ) << ' \n ' ;
491
507
}
492
508
493
509
return false ;
0 commit comments