Skip to content

build: remove --enable-lcov-branch-coverage - #30192

Merged
fanquake merged 1 commit into
bitcoin:masterfrom
fanquake:support_lcov_2
Jun 3, 2024
Merged

fanquake merged 1 commit into
bitcoin:masterfrom
fanquake:support_lcov_2

Conversation

@fanquake

@fanquake fanquake commented May 29, 2024 •

Copy link
Copy Markdown
Member

This supports lcov 2.x in the sense that we are no-longer hardcoding version specific options, and instead will use the LCOV_OPTS variable (which is the more flexible thing to do in any case). It's also quite likely that devs are already having to pass extra options to lcov 2.x, given it's more stringent in terms of coverage generation and error checking. See this thread for an example: linux-test-project/lcov#238.

Tested on one machine (LCOV 2.0, gcc 13.2) with:

./autogen.sh
./configure --enable-lcov CXXFLAGS="-fprofile-update=prefer-atomic" LCOV_OPTS="--rc branch_coverage=1 --ignore-errors mismatch"
make
make cov
<snip>
Processing file src/netaddress.cpp
  lines=521 hit=480 functions=72 hit=72 branches=675 hit=499
Overall coverage rate:
  lines......: 81.8% (79362 of 97002 lines)
  functions......: 77.8% (10356 of 13310 functions)
  branches......: 49.6% (130628 of 263196 branches)

and another machine (LCOV 2.1, Clang 18.1.3) with:

./autogen.sh
./configure --enable-lcov CC=clang CXX=clang++ LCOV_OPTS="--rc branch_coverage=1 --ignore-errors mismatch,inconsistent"
make
make cov
<snip>
    Processing file src/util/strencodings.cpp
      lines=315 hit=311 functions=38 hit=38 branches=425 hit=357
    Overall coverage rate:
      source files: 622
      lines.......: 79.8% (70311 of 88132 lines)
      functions...: 78.1% (13968 of 17881 functions)
      branches....: 44.5% (157551 of 354317 branches)
    Message summary:
      101 warning messages:
        count: 1
        inconsistent: 100
      3528 ignore messages:
        inconsistent: 3528

Related to #28468.

@DrahtBot

DrahtBot commented May 29, 2024 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK theuni, hebasto
Stale ACK maflcko

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

@maflcko maflcko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

utACK b08e07070085edf8cb5fda55d8849188fd83cfc6

Comment thread doc/release-notes-xxxxx.md Resolved

@hebasto hebasto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK 462e761672d387c98e729e920a4102feaedc53cb. A similar approach was used in hebasto#191.

@DrahtBot
DrahtBot requested a review from maflcko May 29, 2024 15:11

@theuni theuni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe this only works because you've exported LCOV_OPTS and it makes it into the make env?

If you use ./configure LCOV_OPTS="--rc branch_coverage=1" as you seem to be recommending:

branch coverage can be enabled by setting LCOV_OPTS=... when configuring

I don't think it'd work.

That could be fixed with a plain AC_SUBST(LCOV_OPTS), which would also document it.

@fanquake

Copy link
Copy Markdown
Member Author

Right. I started this way, and then think I swapped to exporting because it was less annoying. Might actually just update the docs I'm adding, unless you have a preference?

@theuni

theuni commented May 29, 2024

Copy link
Copy Markdown
Member

I don't like the idea of recommending undocumented vars, so I'd prefer the AC_SUBST unless you're opposed.

@fanquake

Copy link
Copy Markdown
Member Author

Ah yea, we won't get it in help. I'll update this tomorrow.

This supports lcov 2.x in the sense that we are no-longer hardcoding
version specific options, and instead will use the `LCOV_OPTS` variable
(which is the more correct/flexible thing to do in any case). It's also
quite likely that devs are already having to pass extra options to lcov
2.x, given it's more stringent in terms of coverage generation and error
checking. See this thread for an example:
linux-test-project/lcov#238.

Added an example to the developer notes.

Tested on one machine (LCOV 2.0, gcc 13.2) with:
```bash
./autogen.sh
./configure --enable-lcov CXXFLAGS="-fprofile-update=prefer-atomic" LCOV_OPTS="--rc branch_coverage=1 --ignore-errors mismatch"
make
make cov
<snip>
Processing file src/netaddress.cpp
  lines=521 hit=480 functions=72 hit=72 branches=675 hit=499
Overall coverage rate:
  lines......: 81.8% (79362 of 97002 lines)
  functions......: 77.8% (10356 of 13310 functions)
  branches......: 49.6% (130628 of 263196 branches)
```

and another machine (LCOV 2.1, Clang 18.1.3) with:
```bash
./autogen.sh
./configure --enable-lcov CC=clang CXX=clang++ LCOV_OPTS="--rc branch_coverage=1 --ignore-errors mismatch,inconsistent"
make
make cov
<snip>
Processing file src/util/strencodings.cpp
  lines=315 hit=311 functions=38 hit=38 branches=425 hit=357
Overall coverage rate:
  source files: 622
  lines.......: 79.8% (70311 of 88132 lines)
  functions...: 78.1% (13968 of 17881 functions)
  branches....: 44.5% (157551 of 354317 branches)
Message summary:
  101 warning messages:
    count: 1
    inconsistent: 100
  3528 ignore messages:
    inconsistent: 3528
```
@fanquake

Copy link
Copy Markdown
Member Author

Updated, rebased, and re-tested, also with LCOV 2.1 (built from source) (updated PR description).

@theuni theuni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

utACK cbd4640

@DrahtBot
DrahtBot requested a review from hebasto May 30, 2024 16:58

@hebasto hebasto left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK cbd4640, tested on Ubuntu 24.04.

Comment thread doc/developer-notes.md
Comment on lines +500 to +503
Additional LCOV options can be specified using `LCOV_OPTS`, but may be dependant
on the version of LCOV. For example, when using LCOV `2.x`, branch coverage can be
enabled by setting `LCOV_OPTS="--rc branch_coverage=1"`, when configuring.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not only "when configuring". Providing LCOV_OPTS variable when building the cov or cov_fuzz targets also works and improves flexibility:

./configure --enable-lcov CXXFLAGS="-fprofile-update=prefer-atomic"
make
make cov LCOV_OPTS="--rc branch_coverage=1 --ignore-errors mismatch"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not only "when configuring".

Sure. This is just one example.

@fanquake
fanquake merged commit f7c0ddf into bitcoin:master Jun 3, 2024
@fanquake
fanquake deleted the support_lcov_2 branch June 3, 2024 09:11
@fanquake fanquake mentioned this pull request Jun 3, 2024
1 task done
@hebasto

hebasto commented Jun 6, 2024

Copy link
Copy Markdown
Member

CMake's hebasto#191 is built on top of this PR change.

@bitcoin bitcoin locked and limited conversation to collaborators Jun 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants