Skip to content
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

[FEATURE] Coverage measurements from CN #93

Open
3 tasks
podhrmic opened this issue May 30, 2024 · 7 comments
Open
3 tasks

[FEATURE] Coverage measurements from CN #93

podhrmic opened this issue May 30, 2024 · 7 comments
Labels
CN Issues related to the CN tool enhancement New feature or request
Milestone

Comments

@podhrmic
Copy link
Collaborator

Summary

When using CN on a large(r) project (such as OpenSUT), measuring code coverage is important. The following metrics should be useful:

  • percentage / LOC of code/functions that have any specs
  • any code excluded from CN checking (maybe hiding behind ifdef or some other directive, excluding the code from being examined)
  • coverage based on types/classes of specifications (see the different classes we mentioned in the proposal)

Acceptance Criteria

  • If CN already provides such metrics, provide documentation how to use it
  • if not, develop appropriate metrics as mentioned above
  • or provide an external tool (not CN) that can provide such metrics
@podhrmic podhrmic added enhancement New feature or request CN Issues related to the CN tool labels May 30, 2024
@podhrmic podhrmic added this to the MVP 2 milestone May 30, 2024
@podhrmic
Copy link
Collaborator Author

@septract does this sound sensible?

@peterohanley
Copy link
Collaborator

We may also want to know which functions have been checked by name. It is possible to use the spec of a function in a header file but not check the function body in another file against that spec, and we'd like to know that this hasn't happened.

@septract
Copy link
Collaborator

septract commented Jun 3, 2024

Yes, this seems like a useful set of measures.

We might also measure the coverage of the specifications themselves. Eg. we can give any function a specification with a false precondition, because this indicates the code cannot be called. But there are more subtle 'bad' specifications which exclude important cases.

This doesn't matter too much for sub-functions, because the specification will be checked at the callsite. So for example, a false precondition will mean a specification cannot be used.

But it becomes very important for top-level specifications where the specification itself is not checked. In this case, a specification may be both true, and allow the function to behave improperly. This is the same as saying the specification does not model the environment properly.

There's a related question whether the post-condition for a top-level specification establishes all the properties that the environment relies on. Eg. the post-condition might only establish True, but perhaps the environment relies on it returning a particular value.

@septract
Copy link
Collaborator

septract commented Jun 3, 2024

A couple of related notions:

  1. Various tools try to detect trivial specifications, eg. specifications with false preconditions. E.g I think Dafny does this.
  2. We might also check path coverage of specifications. Eg. it might be that some path cannot be exercised under the specification precondition. This might indicate that the spec does not achieve good coverage. But it's subtle - the code might be an error handling path that "should not occur".

@septract
Copy link
Collaborator

septract commented Jun 3, 2024

A technique for performing path coverage for a specification would be to use the property-based testing mechanism (once it exists). Then you would use a standard test coverage measure.

@podhrmic
Copy link
Collaborator Author

@thatplguy this is relevant to the discussion with Jim - what is a good next step towards such measurements? Is this something that CN should do, or some other tool that uses CN should provide?

@septract
Copy link
Collaborator

Related: #61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CN Issues related to the CN tool enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants