Skip to content

Commit eeac672

Browse files
authored
Merge pull request #1018 from Degiorgio/test-gen-support
Instrumenting special assert in CPROVER_START after call into the function under test. (#398)
2 parents 448f1ca + 2534b80 commit eeac672

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/goto-instrument/cover.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,33 @@ bool instrument_cover_goals(
14611461
cmdline.isset("no-trivial-tests"));
14621462
}
14631463

1464+
if(cmdline.isset("cover-traces-must-terminate"))
1465+
{
1466+
// instrument an additional goal in CPROVER_START. This will rephrase
1467+
// the reachability problem by asking BMC to provide a solution that
1468+
// satisfies a goal while getting to the end of the program-under-test.
1469+
const auto sf_it=
1470+
goto_functions.function_map.find(goto_functions.entry_point());
1471+
if(sf_it==goto_functions.function_map.end())
1472+
{
1473+
msg.error() << "cover-traces-must-terminate: invalid entry point ["
1474+
<< goto_functions.entry_point() << "]"
1475+
<< messaget::eom;
1476+
return true;
1477+
}
1478+
auto if_it=sf_it->second.body.instructions.end();
1479+
while(!if_it->is_function_call())
1480+
if_it--;
1481+
if_it++;
1482+
const std::string &comment=
1483+
"additional goal to ensure complete trace coverage.";
1484+
sf_it->second.body.insert_before_swap(if_it);
1485+
if_it->make_assertion(false_exprt());
1486+
if_it->source_location.set_comment(comment);
1487+
if_it->source_location.set_property_class("reachability_constraint");
1488+
if_it->source_location.set_function(if_it->function);
1489+
}
1490+
14641491
goto_functions.update();
14651492
return false;
14661493
}

0 commit comments

Comments
 (0)