-
Notifications
You must be signed in to change notification settings - Fork 276
Add cover goals verifier [blocks: 3969] #3968
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
Merged
peterschrammel
merged 10 commits into
diffblue:develop
from
peterschrammel:cover-verifier
Feb 1, 2019
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
52f813e
Inline in class declaration is implicit
peterschrammel 92cceff
Get all property IDs from a trace
peterschrammel 67b2588
Fix and document goto trace storage insert
peterschrammel cb9e287
Extend goto trace storage to coverage traces
peterschrammel 7f14fb3
Add reporting utils for covering goals
peterschrammel c4e93de
Add goto verifier for covering goals
peterschrammel 27e3efd
Fix unit test dependencies
peterschrammel 5d5d61b
Add C test input generator
peterschrammel 29509e5
Use goto verifier for --cover in CBMC
peterschrammel 969f5d6
Update goto-checker docs
peterschrammel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
/*******************************************************************\ | ||
|
||
Module: Test Input Generator for C | ||
|
||
Author: Daniel Kroening, Peter Schrammel | ||
|
||
\*******************************************************************/ | ||
|
||
/// \file | ||
/// Test Input Generator for C | ||
|
||
#include "c_test_input_generator.h" | ||
|
||
#include <goto-checker/goto_trace_storage.h> | ||
|
||
#include <langapi/language_util.h> | ||
|
||
#include <util/json.h> | ||
#include <util/json_irep.h> | ||
#include <util/options.h> | ||
#include <util/string_utils.h> | ||
#include <util/xml.h> | ||
#include <util/xml_irep.h> | ||
|
||
#include <goto-programs/json_expr.h> | ||
#include <goto-programs/json_goto_trace.h> | ||
#include <goto-programs/xml_expr.h> | ||
#include <goto-programs/xml_goto_trace.h> | ||
|
||
c_test_input_generatort::c_test_input_generatort( | ||
ui_message_handlert &ui_message_handler, | ||
const optionst &options) | ||
: ui_message_handler(ui_message_handler), options(options) | ||
{ | ||
} | ||
|
||
void test_inputst::output_plain_text( | ||
std::ostream &out, | ||
const namespacet &ns, | ||
const goto_tracet &goto_trace) const | ||
{ | ||
const auto input_assignments = | ||
make_range(goto_trace.steps) | ||
.filter([](const goto_trace_stept &step) { return step.is_input(); }) | ||
.map([ns](const goto_trace_stept &step) { | ||
return id2string(step.io_id) + '=' + | ||
from_expr(ns, step.function_id, step.io_args.front()); | ||
}); | ||
join_strings(out, input_assignments.begin(), input_assignments.end(), ", "); | ||
out << '\n'; | ||
} | ||
|
||
json_objectt test_inputst::to_json( | ||
const namespacet &ns, | ||
const goto_tracet &goto_trace, | ||
bool print_trace) const | ||
{ | ||
json_objectt json_result; | ||
json_arrayt &json_inputs = json_result["inputs"].make_array(); | ||
|
||
for(const auto &step : goto_trace.steps) | ||
{ | ||
if(step.is_input()) | ||
{ | ||
json_objectt json_input({{"id", json_stringt(step.io_id)}}); | ||
if(step.io_args.size() == 1) | ||
json_input["value"] = | ||
json(step.io_args.front(), ns, ns.lookup(step.function_id).mode); | ||
json_inputs.push_back(std::move(json_input)); | ||
} | ||
} | ||
|
||
json_arrayt goal_refs; | ||
for(const auto &goal_id : goto_trace.get_all_property_ids()) | ||
{ | ||
goal_refs.push_back(json_stringt(goal_id)); | ||
} | ||
json_result["coveredGoals"] = std::move(goal_refs); | ||
return json_result; | ||
} | ||
|
||
xmlt test_inputst::to_xml( | ||
const namespacet &ns, | ||
const goto_tracet &goto_trace, | ||
bool print_trace) const | ||
{ | ||
xmlt xml_result("test"); | ||
if(print_trace) | ||
{ | ||
convert(ns, goto_trace, xml_result.new_element()); | ||
} | ||
else | ||
{ | ||
xmlt &xml_test = xml_result.new_element("inputs"); | ||
|
||
for(const auto &step : goto_trace.steps) | ||
{ | ||
if(step.is_input()) | ||
{ | ||
xmlt &xml_input = xml_test.new_element("input"); | ||
xml_input.set_attribute("id", id2string(step.io_id)); | ||
if(step.io_args.size() == 1) | ||
xml_input.new_element("value") = xml(step.io_args.front(), ns); | ||
} | ||
} | ||
} | ||
|
||
for(const auto &goal_id : goto_trace.get_all_property_ids()) | ||
{ | ||
xmlt &xml_goal = xml_result.new_element("goal"); | ||
xml_goal.set_attribute("id", id2string(goal_id)); | ||
} | ||
|
||
return xml_result; | ||
} | ||
|
||
test_inputst c_test_input_generatort:: | ||
operator()(const goto_tracet &goto_trace, const namespacet &ns) | ||
{ | ||
test_inputst test_inputs; | ||
return test_inputs; | ||
} | ||
|
||
void c_test_input_generatort::operator()(const goto_trace_storaget &traces) | ||
{ | ||
const namespacet &ns = traces.get_namespace(); | ||
const bool print_trace = options.get_bool_option("trace"); | ||
messaget log(ui_message_handler); | ||
switch(ui_message_handler.get_ui()) | ||
{ | ||
case ui_message_handlert::uit::PLAIN: | ||
log.result() << "\nTest suite:\n"; | ||
for(const auto trace : traces.all()) | ||
{ | ||
test_inputst test_inputs = (*this)(trace, ns); | ||
test_inputs.output_plain_text(log.result(), ns, trace); | ||
} | ||
log.result() << messaget::eom; | ||
break; | ||
case ui_message_handlert::uit::JSON_UI: | ||
{ | ||
if(log.status().tellp() > 0) | ||
log.status() << messaget::eom; // force end of previous message | ||
json_stream_objectt &json_result = | ||
ui_message_handler.get_json_stream().push_back_stream_object(); | ||
json_stream_arrayt &tests_array = | ||
json_result.push_back_stream_array("tests"); | ||
|
||
for(const auto trace : traces.all()) | ||
{ | ||
test_inputst test_inputs = (*this)(trace, ns); | ||
tests_array.push_back(test_inputs.to_json(ns, trace, print_trace)); | ||
} | ||
break; | ||
} | ||
case ui_message_handlert::uit::XML_UI: | ||
for(const auto trace : traces.all()) | ||
{ | ||
test_inputst test_inputs = (*this)(trace, ns); | ||
log.result() << test_inputs.to_xml(ns, trace, print_trace); | ||
} | ||
break; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/*******************************************************************\ | ||
|
||
Module: Test Input Generator for C | ||
|
||
Author: Daniel Kroening, Peter Schrammel | ||
|
||
\*******************************************************************/ | ||
|
||
/// \file | ||
/// Test Input Generator for C | ||
|
||
#ifndef CPROVER_CBMC_C_TEST_INPUT_GENERATOR_H | ||
#define CPROVER_CBMC_C_TEST_INPUT_GENERATOR_H | ||
|
||
#include <iosfwd> | ||
|
||
#include <util/ui_message.h> | ||
|
||
class goto_tracet; | ||
class goto_trace_storaget; | ||
class json_objectt; | ||
class namespacet; | ||
class optionst; | ||
|
||
class test_inputst | ||
{ | ||
public: | ||
/// Outputs the test inputs in plain text format | ||
void output_plain_text( | ||
std::ostream &out, | ||
const namespacet &ns, | ||
const goto_tracet &goto_trace) const; | ||
|
||
/// Returns the test inputs in JSON format | ||
/// including the trace if desired | ||
json_objectt to_json( | ||
const namespacet &ns, | ||
const goto_tracet &goto_trace, | ||
bool print_trace) const; | ||
|
||
/// Returns the test inputs in XML format | ||
/// including the trace if desired | ||
xmlt to_xml( | ||
const namespacet &ns, | ||
const goto_tracet &goto_trace, | ||
bool print_trace) const; | ||
}; | ||
|
||
class c_test_input_generatort | ||
{ | ||
public: | ||
c_test_input_generatort( | ||
ui_message_handlert &ui_message_handler, | ||
const optionst &options); | ||
|
||
/// Extracts test inputs for all traces and outputs them | ||
void operator()(const goto_trace_storaget &); | ||
|
||
protected: | ||
ui_message_handlert &ui_message_handler; | ||
const optionst &options; | ||
|
||
/// Extracts test inputs from the given \p goto_trace | ||
test_inputst operator()(const goto_tracet &goto_trace, const namespacet &ns); | ||
}; | ||
|
||
#endif // CPROVER_CBMC_C_TEST_INPUT_GENERATOR_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea which commit exactly fixed this? Might be good to merge this change into that other commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Squashed and amended commit message