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

Harness output individual files #3360

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Alexander-Aghili
Copy link

Resolves #3356

  1. Changes allow for directory with individual output of files named by the full harness name. --output-into-files command line argument will allow for placing all output of individual harnesses into files named by the full harness pretty_name. The output directory is either --target-dir or a hard coded default: "kani_output" directory. (These can be changed if there is a better interface). Still prints output to std::out exactly as previous.
  2. Previously, all output was placed into std::out. This will allow for some control over output. It will also enable easier parsing of harness output.
  3. Only solved Harness Output in Individual Files #3356 but could be expanded to include more features.
  4. Ran manually to check the flags and output behaved as expected. Indeed:
    --output-into-files enabled will place output into individual files, disabled will not
    --output-terse will create terse output to command line, regular output to individual files if --output-into-files is enabled.
    --target-dir will place output into target-dir directory when --output-into-files is enabled, and will not place file output when disabled.

Let me know if you need specific explanations of code segments, a clean list of all the testing configurations, or any feature enhancement for greater configuration options.

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

@Alexander-Aghili Alexander-Aghili requested a review from a team as a code owner July 19, 2024 05:02
}
}

fn get_target_dir(&self) -> String {
Copy link
Contributor

@celinval celinval Jul 19, 2024

Choose a reason for hiding this comment

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

Can you please rename this to result_output_dir to separate these files from the other artifacts that Kani may generate? Also, can you return a Result<PathBuf> instead?

Comment on lines 139 to 143
self.args.target_dir
.clone()
.map_or_else(|| "./kani_output".to_string(), |dir| {
format!("{}/", dir.into_os_string().into_string().unwrap())
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe something like:

Suggested change
self.args.target_dir
.clone()
.map_or_else(|| "./kani_output".to_string(), |dir| {
format!("{}/", dir.into_os_string().into_string().unwrap())
})
let target_dir = self.args.target_dir
.clone()
.map_or_else(|| current_dir(), |dir| Ok(dir))?;
let outdir = target_dir.join("kani_results");
fs::create_dir_all(&outdir)?; // This is a no-op if directory exists.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I will get to fixing this on late Sunday or Monday as I am away this weekend. Thanks for the review!

@@ -275,6 +275,10 @@ pub struct VerificationArgs {
)]
pub synthesize_loop_contracts: bool,

//Harness Output into individual files
#[arg(long, hide_short_help = true, requires("enable_unstable"))]
Copy link
Contributor

Choose a reason for hiding this comment

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

I forgot to mention. We are deprecating enable_unstable, so can you please make sure the new feature can be enabled via -Z unstable-options instead?

Copy link
Author

Choose a reason for hiding this comment

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

Hi there, is there any example of how to do that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, unfortunately this cannot be done with clap directly. Here is an example:

if self.coverage
&& !self.common_args.unstable_features.contains(UnstableFeature::LineCoverage)
{
return Err(Error::raw(
ErrorKind::MissingRequiredArgument,
"The `--coverage` argument is unstable and requires `-Z \
line-coverage` to be used.",
));
}

In this case, you can use UnstableFeature::UnstableOptions.

@jaisnan
Copy link
Contributor

jaisnan commented Jul 21, 2024

This output format is untested as of this PR. I'd like to see one regression test added at least. This isn't a blocking request, but likely something we want to add immediately, maybe in a follow up PR.

@Alexander-Aghili
Copy link
Author

This output format is untested as of this PR. I'd like to see one regression test added at least. This isn't a blocking request, but likely something we want to add immediately, maybe in a follow up PR.

I agree that tests should be added. I'd be fine adding it as a component of this PR or as a separate one, whichever is easier for you guys.

@Alexander-Aghili
Copy link
Author

Hey guys, sorry I haven't gotten to this in a minute. I was testing this on a server used by my research group, but my laptop's SSD failed with my ssh key so I can't really access the server at the moment. Should be fixed in a couple days. Thanks for the patience.

@Alexander-Aghili
Copy link
Author

Okay I tested it and added the -Z --unstable-options instead of --enable-unstable. Do we still want to add tests as a part of this PR?

@jaisnan
Copy link
Contributor

jaisnan commented Jul 31, 2024

Okay I tested it and added the -Z --unstable-options instead of --enable-unstable. Do we still want to add tests as a part of this PR?

I'm okay without a regression for this specific output format since its a really special case and testing will involve some work. I can take that up in a follow up PR. You might want to do the following though (in order of priorities),

Required :-

  1. Fix existing regression tests that are failing
  2. Add comments on the functions related to processing the output.
  3. Format the code with cargo fmt and run cargo clippy on it once.

Optionally

  1. Create an issue to test the new output format.

@Alexander-Aghili
Copy link
Author

Hey there, I've done most of it but I ran into this issue when running regression tests:
ERROR: CBMC version is 5.89.0, expected at least 5.95.0
How can I upgrade the CBMC version?

@artemagvanian
Copy link
Contributor

Hey there, I've done most of it but I ran into this issue when running regression tests: ERROR: CBMC version is 5.89.0, expected at least 5.95.0 How can I upgrade the CBMC version?

You can re-run the script responsible for installing the dependencies to install the appropriate CBMC version. Here is a link to the wiki page that explains what exactly to run: https://model-checking.github.io/kani/build-from-source.html#dependencies.

@zhassan-aws
Copy link
Contributor

If you're using a Mac, run:

./scripts/setup/macos/install_cbmc.sh

If you're using Ubuntu, run:

./scripts/setup/ubuntu/install_cbmc.sh

@Alexander-Aghili
Copy link
Author

Alexander-Aghili commented Aug 4, 2024

I don't want to be the bottleneck on this but in short, I am having a difficult time upgrading because of permissions issues on my remote server, and thus, if others want to try and fix the regression tests, then that is fine as well. Otherwise I am going to have to spend some time fixing the issue on the server I do my development work on and I'm out of town at the moment.

@feliperodri feliperodri added the [E] User Experience An UX enhancement for an existing feature. Including deprecation of an existing one. label Aug 6, 2024
@jaisnan
Copy link
Contributor

jaisnan commented Aug 14, 2024

I don't want to be the bottleneck on this but in short, I am having a difficult time upgrading because of permissions issues on my remote server, and thus, if others want to try and fix the regression tests, then that is fine as well. Otherwise I am going to have to spend some time fixing the issue on the server I do my development work on and I'm out of town at the moment.

Hi @Alexander-Aghili, the regression tests should pass now after the fix from @celinval. You should be able to resume development if you have the time to add tests. If not, please let us know and we can take on the task of adding a test on this PR 😄

@Alexander-Aghili
Copy link
Author

Hi guys,
Sorry for taking so long, I've been out on holiday. I made an issue for adding regression tests. Do we want to complete that in this PR? If not, what needs to be done with this PR to merge it? If we do, how should the regression test be done?

@jaisnan
Copy link
Contributor

jaisnan commented Aug 20, 2024

Hi guys, Sorry for taking so long, I've been out on holiday. I made an issue for adding regression tests. Do we want to complete that in this PR? If not, what needs to be done with this PR to merge it? If we do, how should the regression test be done?

For this pr to be merged, we are looking for at least something that uses the new flag and ensure Kani still succeeds. It doesn't need to check that the files exist, just needs to test that Kani doesn't break. If you can add that, I am OK with merging the PR. Lmk if thats putting too much on your plate, and I can take over this PR and add those changes myself as well. In any case, thank you very much for the changes :D.

@Alexander-Aghili
Copy link
Author

I swear I'm not as flaky as I seem but my computer's screen just broke and I'm going to have to get it replaced which might take some time. If you want to take it over and finish the PR feel free to do so otherwise I'll get on it immediately when I can.

@jaisnan
Copy link
Contributor

jaisnan commented Aug 20, 2024

I swear I'm not as flaky as I seem but my computer's screen just broke and I'm going to have to get it replaced which might take some time. If you want to take it over and finish the PR feel free to do so otherwise I'll get on it immediately when I can.

No worries :D

@Alexander-Aghili
Copy link
Author

Finally getting back around to this. I will be creating that test and merging in the new base, then asking for a review to be merged.

@jaisnan jaisnan removed their assignment Sep 18, 2024
@jaisnan
Copy link
Contributor

jaisnan commented Sep 18, 2024

Finally getting back around to this. I will be creating that test and merging in the new base, then asking for a review to be merged.

Awesome, thank you!

@Alexander-Aghili
Copy link
Author

Hey, I was checking the other UI tests and they verify the validity of the response by running a proof in a main.rs file and checking it with an expected output which is a single txt. With the proper output being a directory, how should I handle that? Also, do you use git merge or git rebase when updating the git structure?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[E] User Experience An UX enhancement for an existing feature. Including deprecation of an existing one.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Harness Output in Individual Files
6 participants