Skip to content

Cover failed assertions #5636

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

14 changes: 8 additions & 6 deletions src/cbmc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ by other mechanism may categorise their properties differently.

### Coverage mode

There is one further BMC mode that differs more fundamentally: when `--cover` is
passed, assertions in the program text are converted into assumptions (these
There is one further BMC mode that differs more fundamentally: when `--cover`
is passed, assertions in the program text are converted into assumptions (these
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to open a massive can of worms here but ... why is this the default? Is this actually useful? Given that there are options for --no-assertions, --no-assumptions and --assert-to-assume (whether they work or even do anything at all ... is an open question) could we make the transformation of assertions and assumptions orthogonal to --cover. It feels like this should be possible and even desirable...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martin-cs I think this is the default because whoever wrote this had the expectation that programs should stop at failed assertions. I suppose we could change it, but I’m always a bit wary about changing defaults.

Copy link
Contributor Author

@hannes-steffenhagen-diffblue hannes-steffenhagen-diffblue Dec 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martin-cs FWIW because cover treats each failed goal as something relating to coverage right now we have to do something with asserts. That said, I think the alternative (just making cover cleverer about how it counts coverage) would be more desirable.

I'd consider that as something we can take a look at in terms of future work though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if you are doing a naive count then, I see the need to do something with pre-existing assertions or otherwise true assertions (generally a good thing) will count against your coverage. Smarter counting would certainly be one way to address this.

It feels to me that making the "doing something about asserts" independent might be a desirable option as well. I can see use-cases for converting to SKIP, to ASSUME and leaving as they are.

Then again, I am not a user of this code at the moment and do not have time to work on it so my views maybe not so important.

must hold for control flow to proceed past them, but are not goals for the
equation solver), while new `assert(false)` statements are added throughout the
source program representing coverage goals. The equation solving process then
proceeds the same as in all-properties mode. Coverage solving is implemented by
`bmc_covert`, but is structurally practically identical to
equation solver; In cases where this behaviour is undesirable you can pass the
`--cover-failed-assertions` which makes coverage checking continue even for
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW shouldn’t this file be under doc rather than src? I don’t really understand our documentation structure...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The READMEs which are in each module are pulled into here: http://cprover.diffblue.com/folder-walkthrough.html (click on cbmc, for example).
We decided to keep them in the source folders so that they are as close as possible to the code.

paths where assertions fail), while new `assert(false)` statements are added
throughout the source program representing coverage goals. The equation solving
process then proceeds the same as in all-properties mode. Coverage solving is
implemented by `bmc_covert`, but is structurally practically identical to
`bmc_all_propertiest`-- only the reporting differs (goals are called "covered"
rather than "failed").

Expand Down