Skip to content

feat: add concrete playback support for multiple failing harnesses - #1558

Merged
adpaco merged 11 commits into
model-checking:mainfrom
sanjit-bhat:mult-harnesses
Aug 25, 2022
Merged

adpaco merged 11 commits into
model-checking:mainfrom
sanjit-bhat:mult-harnesses

Conversation

@sanjit-bhat

Copy link
Copy Markdown
Contributor

Description of changes:

Previously, the concrete playback feature did not work for in-place modification of multiple unit tests for failing harnesses. We had mitigated this issue by requiring the --harness argument. In this PR, we remove the restriction by sorting the harnesses according to greater start line gets computed earlier. This makes the source file updates not interfere with the line numbers computed before any updates happened.

Resolved issues:

Resolves #1506.

Call-outs:

I needed to compare the line numbers as actual numbers, not as strings (the way they were before). I figured I might as well just convert their types to numbers in the first place.

Testing:

  • How is this change tested?

There is a multiple harness test that checks that later harnesses are generated earlier.

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@sanjit-bhat sanjit-bhat self-assigned this Aug 19, 2022
@sanjit-bhat
sanjit-bhat requested a review from a team as a code owner August 19, 2022 15:51
@sanjit-bhat
sanjit-bhat requested a review from celinval August 19, 2022 17:31
@celinval celinval self-assigned this Aug 19, 2022
// SPDX-License-Identifier: Apache-2.0 OR MIT

// kani-flags: --harness harness --enable-unstable --concrete-playback=Print
// kani-flags: --enable-unstable --concrete-playback=Print

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A little off-topic, but... Why are we writing --concrete-playback=Print in our tests? The options mentioned in the docs are [print|inplace], should we make this case-sensitive?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. I changed it to --concrete-playback=print.

I think we should keep it as case-insensitive since our kani-driver arguments seem to follow a lower-case standard while the Rust enum conventions use upper case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe our flags all follow kebab-case, but unfortunately the arguments don't. We turned case-insensitive to go around this, but ideally we should configure everything to be consistent. I couldn't find any easy fix with structopts though and we would need to migrate to using clap directly.

Comment thread kani-driver/src/main.rs Resolved
@sanjit-bhat
sanjit-bhat requested review from adpaco and removed request for celinval August 24, 2022 18:37

@celinval celinval left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I just have one comment about using slice sort instead of generating new harness vector. I think it's cleaner.

Comment thread kani-driver/src/metadata.rs Outdated
/// appearing harnesses get processed earlier.
/// This is necessary for the concrete playback feature (with in-place unit test modification)
/// because it guarantees that injected unit tests will not change the location of to-be-processed harnesses.
pub fn sort_harnesses(harnesses: &[HarnessMetadata]) -> Vec<HarnessMetadata> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Originally, I called sort directly on the slice (I think this is what you are recommending). Then, @adpaco-aws commented that I should return a new vector, so I changed the code. These two recommendation seem to conflict. Which one would you like me to do?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, sorry, I didn't see that comment.

You can leave it as is.

Comment thread kani-driver/src/metadata.rs Outdated
/// appearing harnesses get processed earlier.
/// This is necessary for the concrete playback feature (with in-place unit test modification)
/// because it guarantees that injected unit tests will not change the location of to-be-processed harnesses.
pub fn sort_harnesses(harnesses: &[HarnessMetadata]) -> Vec<HarnessMetadata> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: sort_by_location or something like that since correctness depend on what we are sorting it by.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Updated func name.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks

@sanjit-bhat
sanjit-bhat requested review from adpaco and celinval and removed request for adpaco and celinval August 24, 2022 21:48
@adpaco
adpaco merged commit 5574f5d into model-checking:main Aug 25, 2022
@sanjit-bhat
sanjit-bhat deleted the mult-harnesses branch September 1, 2022 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support adding concrete playback tests for multiple failing harnesses

3 participants