Subject: Re: Having problems generating a code coverage report

From: Stefan Kaltenbrunner <[email-masked]>
Date: Sat, 14 Feb 2026 09:04:44 +0100

On 1/29/25 02:00, Michael Paquier wrote:
> On Wed, Jan 15, 2025 at 07:51:39PM -0500, Peter Geoghegan wrote:
>> I was able to get the lcov git master branch's tip to produce a
>> Postgres coverage report (same compiler version and OS as before).
>> Unfortunately, I had to use an even grottier incantation to get this
>> to work:
>>
>> make -s coverage-html GENHTML_FLAGS="-q --legend --ignore-errors
>> unmapped,unmapped,empty,empty,inconsistent,inconsistent,corrupt,corrupt,range,range"
>> LCOVFLAGS="--ignore-errors
>> empty,empty,negative,negative,inconsistent,inconsistent"
>>
>> (As you can imagine, I came up with this through pure trial and error.)
> 
> Interesting.  These tricks do not seem to work here with a Debian GID
> host, unfortunately.  I'll try to dig a bit more, this is getting very
> annoying :(

hmm this is now also breaking coverage.postgresql.org (after an upgrade 
to the current debian trixie):

make: Leaving directory 
'/home/coverage/pgsrc/pgsql/src/interfaces/ecpg/test'
/usr/bin/lcov --gcov-tool /usr/bin/gcov -q --no-external -c -i -d . -d . 
-o lcov_base.info
lcov: WARNING: (deprecated) RC option 'lcov_branch_coverage' is 
deprecated.  Consider using 'branch_coverage'. instead. 
(Backward-compatible support will be removed in the future.)
         (use "lcov --ignore-errors deprecated,deprecated ..." to 
suppress this warning)
Message summary:
   1 error message:
     usage: 1
   1 warning message:
     deprecated: 1
lcov: ERROR: (usage) duplicate file ./src/fe_utils/astreamer_gzip.gcno 
in both . and .
         (use "lcov --ignore-errors usage ..." to bypass this error)
make: *** [src/Makefile.global:1064: lcov_base.info] Error 1

This seems to be basically the same issue that Andres patch in this 
thread tries to address by removing one of the -d - applying a similar 
hack locally seems to help a bit until we are running into one of the 
other reported issues:

lcov: WARNING: (inconsistent) 
/home/coverage/pgsrc/pgsql/contrib/bloom/blinsert.c:274: unexecuted 
block on non-branch line with non-zero hit count.  Use "geninfo --rc 
geninfo_unexecuted_blocks=1 to set count to zero.
	(use "lcov --ignore-errors inconsistent,inconsistent ..." to suppress 
this warning)
lcov: ERROR: (negative) Unexpected negative hit count '-5' for line 
/home/coverage/pgsrc/pgsql/src/port/snprintf.c:529" while capturing from 
./src/port/snprintf_shlib.gcda.
	(use "lcov --ignore-errors negative ..." to bypass this error)
Message summary:
   1 error message:
     negative: 1
   2 warning messages:
     deprecated: 1
     inconsistent: 1
make: *** [src/Makefile.global:1069: lcov_test.info] Error 1

While I certainly can try to locally hack around that further to get it 
build it feels wrong to post process/patch our own tree to get 
"official" coverage reporting...

Stefan

---

From: Michael Paquier <[email-masked]>
Date: Mon, 16 Feb 2026 10:49:14 +0900

On Sat, Feb 14, 2026 at 09:04:44AM +0100, Stefan Kaltenbrunner wrote:
> build it feels wrong to post process/patch our own tree to get "official"
> coverage reporting...

Are you using a VPATH build?  That was the only build option that was
causing me problems on Debian GID even with the tweaks proposed by
Andres in a .lcovrc.  Non-vpath under configure and meson worked
unpatched.  With vpath under configure, that worked but the
directories were in a weird state (contrib/ missing from the root
patch, $HOME included).  meson was much slower than the two others.

I have also tried a few more experiments on Fedora 34 lately, that
points to even newer versions of all these tools.  Things are even
more broken moving forward for meson, vpath and non-vpath.  This is
testing things with an unpatched PG tree, just mentioning that it
does not seem to get better as time goes..
--
Michael

---

From: Álvaro Herrera <[email-masked]>
Date: Tue, 17 Feb 2026 18:10:46 +0100

On 2026-Feb-16, Michael Paquier wrote:

> Are you using a VPATH build?

Nope, it's a straight in-tree build.  I made it work after a few more
failed tries with a call like

GENHTML_FLAGS="-q --legend --ignore-errors unmapped,corrupt,inconsistent,range"
LCOVFLAGS="-q --legend --ignore-errors usage"
make coverage-html

... and we have a nice (??) trace of what errors are being ignored.  I
think this is absolutely bonkers, but who knows when or if lcov and its
tools are going to be fixed in a way that allows our tree to be
processed correctly.

However, it appears that there are problems with the CSS, because the
lines are not colored anymore.  I have no idea how to get this to work,
but you can see the result running lcov 2.0 in
https://coverage.postgresql.org/

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/
"You're _really_ hosed if the person doing the hiring doesn't understand
relational systems: you end up with a whole raft of programmers, none of
whom has had a Date with the clue stick."              (Andrew Sullivan)
https://postgr.es/m/[email-masked]