Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

[WIP] Coverage Analysis #20

Merged
merged 4 commits into from
Jan 5, 2018
Merged

[WIP] Coverage Analysis #20

merged 4 commits into from
Jan 5, 2018

Conversation

lght
Copy link
Contributor

@lght lght commented Dec 21, 2017

This is an attempt to get coverage reporting working for Solaris. Currently available tooling cargo-cov works nicely for generating branch and line-coverage statistics, and getting an HTML-formatted report.

For our purposes, however, we need a format we can upload to Coveralls (for that nice green badge :)

My current working(?) solution is to use llvm-cov gcov to generate .gcov files from .gcda/.gcno files produced by cargo-cov. Ideally this will be one step in the near future.

It is possible to achieve a one-step solution either patching cargo-cov to get intermediate gcov output, or with a script that automates .gcov generation with llvm-cov gcov.

Will update this PR as progress is made.

lght added 3 commits December 19, 2017 10:08
Configure solaris to use solc as its compiler.
Removed unnecessary `-o .` flag for specifying output directory.
Solc already outputs to the appropriate directory, and the flag
incorrectly creates a new directory.
Initial writeup on how to get coverage manually, using cargo-cov and
llvm-cov to get .gcov files with branching statistic and line coverage.

Working on automating the process.
solc/src/lib.rs Outdated
@@ -3,7 +3,7 @@ mod platform {
use std::process::Command;

pub fn solc() -> Command {
Command::new("solcjs")
Command::new("solc")
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the reason behind this change? Currently we only require npm install -g solc, which installs solcjs. Do we need to use CPP version for some reason?

Copy link
Collaborator

Choose a reason for hiding this comment

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

While I agree with you that compiler change shouldn't be included in this PR, the general idea is to move to solc — I personally have much shorter compile times with it. (Eventually, we want to get rid of a separate compiler requirement at all, which is tracked in #8 )

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree that #8 is the best option, but I don't think it's going to happen soon. For me currently compile time of contracts is negligible compare to compilation time of all solaris dependencies. Also solcjs is way easier to install, which is pretty important for later adoption.

I would be in favour of detecting which of the two is available (with solc being prefered) and using that one, but indeed should be part of separate PR.

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 would be in favour of detecting which of the two is available (with solc being prefered) and using that one, but indeed should be part of separate PR.

This compiler change got rolled into the commits with this branch by mistake. I have another branch (lght-solc) which tracks these changes. I can make a PR for that branch, and attempt some detection of what is available on the system.

I personally have much shorter compile times with it.

^ same for me, and is my main motivation for moving away from solcjs. Because of the current CI setup (and proper separation of concerns), I will revert the compiler changes in this PR.

Copy link
Collaborator

@kirushik kirushik left a comment

Choose a reason for hiding this comment

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

Please fix the build and rollback the compiler change. I totally support @tomusdrw idea about autodetecting the available compiler -- as a separate PR we can easily do right now.

Other than that -- the wrteup is pretty solid and easy to understand, let's merge it soon!

@lght
Copy link
Contributor Author

lght commented Dec 22, 2017

I totally support @tomusdrw idea about autodetecting the available compiler -- as a separate PR we can easily do right now

As do I, this change was a mistake on my part. Reverted the changes :)

the wrteup is pretty solid and easy to understand, let's merge it soon!

Thanks :) I'll keep making changes as I learn more about the available tooling.

Apparently there is an issue with Rust profiling picking up on generic functions (see this issue in cargo-cov). So this approach may work for some basic coverage statistics, but not a long-term / ideal solution by any stretch.

Copy link
Collaborator

@kirushik kirushik left a comment

Choose a reason for hiding this comment

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

:shipit:

@lght
Copy link
Contributor Author

lght commented Dec 26, 2017

I need to get @marco-c and @kennytm a [insert-beverage-of-choice]!

Wouldn't have been able to get this tooling together without their work.

@kirushik
Copy link
Collaborator

kirushik commented Dec 27, 2017

@lght do you want to wait for a second review, or we can merge this now?

@marco-c
Copy link

marco-c commented Jan 4, 2018

@lght glad to help!

I've read your guide, are you mixing GCC/LLVM compiled code? mozilla/grcov#25 would make grcov work fine with a mix of GCC/LLVM gcda/gcno files. I haven't prioritized it yet because I don't need it for my purposes, but I can raise its priority if you need it.

Another option would be to split the GCC and LLVM files into two different directories, then run grcov once with the GCC files, once with the LLVM files and once to merge the two.

Note also that grcov doesn't need llvm-cov to be installed, as it is using the LLVM API directly to parse the gcda/gcno files.

@tomusdrw tomusdrw merged commit 1782233 into master Jan 5, 2018
@tomusdrw tomusdrw deleted the coverage branch January 5, 2018 10:34
@lght
Copy link
Contributor Author

lght commented Jan 9, 2018

Another option would be to split the GCC and LLVM files into two different directories, then run grcov once with the GCC files, once with the LLVM files and once to merge the two.

I like this idea a lot. Would make analysis of FFI/Native components easier. Something like "want analysis of wrapped C components, only run GCC grcov pass". Will look into helping with mozilla/grcov#25. Using the headers to determine GCC/LLVM, splitting them inside a tmp working folder, then running the two passes seems like it might work for below feature.

Note also that grcov doesn't need llvm-cov to be installed, as it is using the LLVM API directly to parse the gcda/gcno files.

Did not realize this, makes sense now tho.

are you mixing GCC/LLVM compiled code

Yes. Parity has a number of components that are Rust wrappers around C/C++ code. Is there a way to instrument the build to use all clang?

@marco-c
Copy link

marco-c commented Aug 30, 2018

Just wanted to let you know that mozilla/grcov#25 has been fixed, so there's no longer any issue with mixing code compiled by GCC and LLVM.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants