-
Notifications
You must be signed in to change notification settings - Fork 274
Add array initialisation support in default goto-harness. #4234
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
Add array initialisation support in default goto-harness. #4234
Conversation
c3fed2e
to
071a1f9
Compare
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.
We'll also need to update user documentation ideally with usage examples and current limitations (no support for globals and struct members for dynamic arrays atm)
@@ -42,6 +43,12 @@ struct function_call_harness_generatort::implt | |||
recursive_initialization_configt recursive_initialization_config; | |||
std::unique_ptr<recursive_initializationt> recursive_initialization; | |||
|
|||
std::set<irep_idt> function_parameters_to_treat_as_arrays; | |||
std::set<irep_idt> function_arguments_to_treat_as_arrays; |
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.
I don't particularly enjoy the solution we have here - basically, we need to keep track of the names of function arguments as declared on the function, and their mapping to parameters, and which parameters the array initialisation applies to etc...
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.
This is just a note, we don't need to do it right now.
@@ -37,7 +38,16 @@ void recursive_initializationt::initialize( | |||
} | |||
else if(type.id() == ID_pointer) | |||
{ | |||
initialize_pointer(lhs, depth, known_tags, body); | |||
if( |
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.
This could have been solved more elegantly if we used a handler chain pattern as the test-gen team does for their harness generation. Didn't want to do this atm because this was mostly about porting existing functionality, but might be worth converting this at some point.
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.
This is just a note, we don't need to do it right now.
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.
Looks good.
Superb. The less time anyone needs to spend 'reverse-engineering' context/boundary conditions/ edge case coverage - is all company time that can be used for other purposes. A huge win at little cost. I am delighted to see that you're keeping this in mind (& I know Fotis also shares this perspective). |
071a1f9
to
8f03071
Compare
Note that some of the examples don’t quite work atm due to a bug that has a pending fix in another PR |
078f14b
to
9b6a4b2
Compare
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.
A couple of comments, but also a rebase and making-CI-happy is required.
regression/goto-harness/pointer-to-array-function-parameters-min-size/test.desc
Outdated
Show resolved
Hide resolved
9b6a4b2
to
0ad43fd
Compare
for the function we are calling in goto-harness. Before this we had a function called setup_parameters_and_call_entry_function, and now we have split it up into declare_arguments and call_function. This is so we can do some handling between declaring arguments and calling the function. Co-authored-by: Fotis Koutoulakis <[email protected]> Co-authored-by: Hannes Steffenhagen <[email protected]>
Add non-det initialization of statically sized arrays. This does element-wise initialisation. Co-authored-by: Fotis Koutoulakis <[email protected]> Co-authored-by: Hannes Steffenhagen <[email protected]>
0ad43fd
to
151dfd2
Compare
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.
This PR failed Diffblue compatibility checks (cbmc commit: 0ad43fd).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102341655
Status will be re-evaluated on next push.
Common spurious failures:
-
the cbmc commit has disappeared in the mean time (e.g. in a force-push)
-
the author is not in the list of contributors (e.g. first-time contributors).
-
the compatibility was already broken by an earlier merge.
151dfd2
to
07c31d7
Compare
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.
This PR failed Diffblue compatibility checks (cbmc commit: 151dfd2).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102349568
Status will be re-evaluated on next push.
Common spurious failures:
-
the cbmc commit has disappeared in the mean time (e.g. in a force-push)
-
the author is not in the list of contributors (e.g. first-time contributors).
-
the compatibility was already broken by an earlier merge.
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 07c31d7).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102353668
07c31d7
to
5904fec
Compare
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 5904fec).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102477427
5904fec
to
1be00d6
Compare
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.
Rough.
That random argument-dependent-static variable is VERY suspicious.
Small helper to convert a program argument to size_t and throw an exception if it doesn't work. Co-authored-by: Fotis Koutoulakis <[email protected]> Co-authored-by: Hannes Steffenhagen <[email protected]>
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 1be00d6).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102514471
c248ef3
to
8b2d421
Compare
Create and non-det initialise of pointers to arrays making sure that they actually point at arrays. Also allows binding function parameters to the size of the array parameter. Only works with function parameters at the moment, not with struct members or globals. Also adds tests. Co-authored-by: Fotis Koutoulakis <[email protected]> Co-authored-by: Hannes Steffenhagen <[email protected]>
Added a debugging helper function. It was worth keeping it around even after debugging. Co-authored-by: Fotis Koutoulakis <[email protected]> Co-authored-by: Hannes Steffenhagen <[email protected]>
This adds some user documentation to goto-harness. Currently only includes documentation for the call-function harness, not the memory-snapshot harness
8b2d421
to
0ea5c31
Compare
@@ -23,5 +23,11 @@ if [ -e "${name}-mod.gb" ] ; then | |||
rm -f "${name}-mod.gb" | |||
fi | |||
|
|||
$goto_harness "${name}.gb" "${name}-mod.gb" --harness-function-name $entry_point ${args} | |||
$cbmc --function $entry_point "${name}-mod.gb" --unwind 20 --unwinding-assertions | |||
# `# some comment` is an inline comment - basically, cause bash to execute an empty command |
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.
Nice!
@@ -31,6 +31,8 @@ struct recursive_initialization_configt | |||
std::set<irep_idt> pointers_to_treat_as_arrays; | |||
std::set<irep_idt> variables_that_hold_array_sizes; | |||
std::map<irep_idt, irep_idt> array_name_to_associated_array_size_variable; | |||
|
|||
std::string to_string() const; // for debugging purposes |
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.
If to_string()
is only meant to be used for debugging purposes, is it worth wrapping it in #if DEBUG
?
|
||
We have two types of harnesses we can generate for now: | ||
|
||
* The `memory-snapshot` harness. TODO: Daniel can document this. |
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.
There's more than one 'Daniel'....
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.
Maybe explicitly reference the PR (#4261)?
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 0ea5c31).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102542412
Joint work by me and @hannes-steffenhagen-diffblue on adding support for statically and dynamically sized arrays non-deterministic initialisation on the
function-call
harness in the new goto-harness tool.