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

A few output improvements #976

Merged
merged 9 commits into from
Mar 29, 2022
Merged

Conversation

celinval
Copy link
Contributor

@celinval celinval commented Mar 23, 2022

Description of changes:

  1. Disable reach assertions when running --visualize.
  2. Fix the file path in the compiler to use local file path.
    • Note that using the local file path is not recommended to generate artifacts that can be shared, but I don't this we have that use case today.
  3. Try to be smart when displaying the file path to either do relative to current directory or to home.
    • This makes the output much nicer when the file path is deep into the hierarchy.

Resolved issues:

Call-outs:

Here is an example of the new output:

Check 16: std::boxed::Box::<T, A>::into_unique.assertion.1                                                                                                                               
         - Status: SUCCESS                                                                                                                                                               
         - Description: "resume instruction"                                                                                                                                             
         - Location: ~/.rustup/toolchains/nightly-2022-03-09-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1087:5 in function std::boxed::Box::<T, A>::into_un
ique                                                                                                                                                                                     
                                                                                                                                                                                         
Check 17: same_file.assertion.2                                                                                                                                                          
         - Status: SUCCESS                                                                                                                                                               
         - Description: "assertion failed: cond"                                                             
         - Location: main.rs:13:5 in function same_file  

Testing:

  • How is this change tested?

  • Is this a refactor change?

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.

@celinval celinval requested a review from a team as a code owner March 23, 2022 22:04
@@ -0,0 +1,7 @@
module/mod.rs:10:5 in function module::not_empty
main.rs:13:5 in function same_file
~/.rustup/toolchains
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not confident we should include this expectation, but this prevents us from inadvertently use remapped path. Open to suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

RUSTUP_HOME can be overriden (see https://rust-lang.github.io/rustup/environment-variables.html), so in the current form, the test may fail for users who override it.

If you're trying to make sure the path is not of the form: /rustc/1eb72580d076935a3e590deb6e5813a5aef3eca4/library/core/src/mem/mod.rs, perhaps just check for toolchains/nightly-?

@jaisnan
Copy link
Contributor

jaisnan commented Mar 23, 2022

Could you add some screenshot or add an example output improvement to the description of this PR? (Maybe the same example as the test file so it's easier to suggest what to add to the expected file)


pub fn assertion_reach_checks(&self) -> bool {
// Turn them off when visualizing an error trace.
!self.no_assertion_reach_checks && !self.visualize
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. I've been meaning to fix that.

if not self.filename:
return None

if not path.exists(self.filename):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary for what comes after? Checking if the file exists can be expensive (since it involves an OS/filesystem operation) which can slow things down quite a bit if we're checking the path for every check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that this fixed an issue that I saw before, but I couldn't reproduce it. So I'm removing this. :)

I added a few tests to hopefully ensure that I didn't miss anything.

@@ -0,0 +1,7 @@
module/mod.rs:10:5 in function module::not_empty
main.rs:13:5 in function same_file
~/.rustup/toolchains
Copy link
Contributor

Choose a reason for hiding this comment

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

RUSTUP_HOME can be overriden (see https://rust-lang.github.io/rustup/environment-variables.html), so in the current form, the test may fail for users who override it.

If you're trying to make sure the path is not of the form: /rustc/1eb72580d076935a3e590deb6e5813a5aef3eca4/library/core/src/mem/mod.rs, perhaps just check for toolchains/nightly-?

Should we make it relative to the project dir instead??
Unfortunately, the output changes depending on the directory where the
regression is running from, so we cannot check that logic.
@celinval celinval force-pushed the output-improvements branch from 9607350 to 25bca14 Compare March 28, 2022 22:04
@@ -0,0 +1,102 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR MIT
import unittest
Copy link
Contributor

Choose a reason for hiding this comment

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

Much needed! Thanks for adding this unit test module!

Nit: should we renamed it to test_cbmc_parser.py to make it more clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

@celinval celinval merged commit 4ad542f into model-checking:main Mar 29, 2022
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 22, 2022
* Disable reach assertions in visualize mode
* Make file location relative to current dir
* Add unit tests
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 25, 2022
* Disable reach assertions in visualize mode
* Make file location relative to current dir
* Add unit tests
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 26, 2022
* Disable reach assertions in visualize mode
* Make file location relative to current dir
* Add unit tests
tedinski pushed a commit that referenced this pull request Apr 27, 2022
* Disable reach assertions in visualize mode
* Make file location relative to current dir
* Add unit tests
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.

3 participants