Extension coverage

Started by Gabriel Furstenheim Milerudover 8 years ago5 messagesgeneral
Jump to latest
#1Gabriel Furstenheim Milerud
furstenheim@gmail.com

Hello,

I'm trying to measure test coverage on an extension. I've built postgres
with the --enable-coverage flag:

$ cd $POSTGRES_SOURCE_DIR
$ ./configure --enable-coverage
$ make
$ make install

The I built my extension against this postgres server

$ cd $EXTENSION_SOURCE_DIR
$ make install && make installcheck

the extension is built fine and the test run. However, I see no difference
with a normal installation without the flag.

Then I run the following target (
https://stackoverflow.com/questions/31417900/how-to-run-coverage-report-on-a-postgres-extension
)
coverage:
lcov --no-external -d . -c -o lcov.info
genhtml --show-details --legend --output-directory=coverage
--title=PostgreSQL --num-spaces=4 --prefix=./src/ `find . -name lcov.info
-print`

But it complains that there are no .gcda files
geninfo: WARNING: no .gcda files found in . - skipping!
and it errors.
genhtml: ERROR: no valid records found in tracefile ./lcov.info

Is this the way to measure coverage on an extension? Am I missing some step?

Thanks in advance
Gabriel Fürstenheim

#2Michael Paquier
michael@paquier.xyz
In reply to: Gabriel Furstenheim Milerud (#1)
Re: Extension coverage

On Sat, Aug 26, 2017 at 2:59 AM, Gabriel Furstenheim Milerud
<furstenheim@gmail.com> wrote:

The I built my extension against this postgres server

$ cd $EXTENSION_SOURCE_DIR
$ make install && make installcheck

the extension is built fine and the test run. However, I see no difference
with a normal installation without the flag.

Then I run the following target
(https://stackoverflow.com/questions/31417900/how-to-run-coverage-report-on-a-postgres-extension)
coverage:
lcov --no-external -d . -c -o lcov.info
genhtml --show-details --legend --output-directory=coverage
--title=PostgreSQL --num-spaces=4 --prefix=./src/ `find . -name lcov.info
-print`

But it complains that there are no .gcda files
geninfo: WARNING: no .gcda files found in . - skipping!
and it errors.
genhtml: ERROR: no valid records found in tracefile ./lcov.info

Is this the way to measure coverage on an extension? Am I missing some step?

This error is a bit weird, what you are showing here has nothing
wrong. I do work with this coverage target and postgres extensions,
and the following steps allow me to generate a text report of coverage
when compiling any extension with a Postgres build having
--enable-coverage:
make install
make installcheck
make coverage
Trying to use coverage-html from an external extension leads to an error:
$ make coverage-html
rm -rf coverage
mkdir coverage
/home/ioltas/extra/bin/genhtml --show-details --legend
--output-directory=coverage --title=PostgreSQL --num-spaces=4
--prefix= `find . -name lcov.info -print`
genhtml: Option prefix requires an argument
Use genhtml --help to get usage information

But this bit is easy enough to fix by enforcing the value of
abs_top_srcdir when running the command "make coverage-html".
--
Michael

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Gabriel Furstenheim Milerud
furstenheim@gmail.com
In reply to: Michael Paquier (#2)
Re: Extension coverage

Not sure I follow. Do you have an example that I could check?
I have the impression that my problem is that no .gcda files are created.
If I just run the lcov part:
lcov -d . -c -o lcov.info

I get
Found gcov version: 5.4.0
Scanning . for .gcda files ...
geninfo: WARNING: no .gcda files found in . - skipping!
Finished .info-file creation

and an empty file lcov.info is created.

Just to check, I've tried running make coverage and make coverage-html on
the folder of postgres instead of the extension and that works.

On 26 August 2017 at 06:40, Michael Paquier <michael.paquier@gmail.com>
wrote:

Show quoted text

On Sat, Aug 26, 2017 at 2:59 AM, Gabriel Furstenheim Milerud
<furstenheim@gmail.com> wrote:

The I built my extension against this postgres server

$ cd $EXTENSION_SOURCE_DIR
$ make install && make installcheck

the extension is built fine and the test run. However, I see no

difference

with a normal installation without the flag.

Then I run the following target
(https://stackoverflow.com/questions/31417900/how-to-run-

coverage-report-on-a-postgres-extension)

coverage:
lcov --no-external -d . -c -o lcov.info
genhtml --show-details --legend --output-directory=coverage
--title=PostgreSQL --num-spaces=4 --prefix=./src/ `find . -name

lcov.info

-print`

But it complains that there are no .gcda files
geninfo: WARNING: no .gcda files found in . - skipping!
and it errors.
genhtml: ERROR: no valid records found in tracefile ./lcov.info

Is this the way to measure coverage on an extension? Am I missing some

step?

This error is a bit weird, what you are showing here has nothing
wrong. I do work with this coverage target and postgres extensions,
and the following steps allow me to generate a text report of coverage
when compiling any extension with a Postgres build having
--enable-coverage:
make install
make installcheck
make coverage
Trying to use coverage-html from an external extension leads to an error:
$ make coverage-html
rm -rf coverage
mkdir coverage
/home/ioltas/extra/bin/genhtml --show-details --legend
--output-directory=coverage --title=PostgreSQL --num-spaces=4
--prefix= `find . -name lcov.info -print`
genhtml: Option prefix requires an argument
Use genhtml --help to get usage information

But this bit is easy enough to fix by enforcing the value of
abs_top_srcdir when running the command "make coverage-html".
--
Michael

#4Michael Paquier
michael@paquier.xyz
In reply to: Gabriel Furstenheim Milerud (#3)
Re: Extension coverage

On Sat, Aug 26, 2017 at 6:28 PM, Gabriel Furstenheim Milerud
<furstenheim@gmail.com> wrote:

Not sure I follow. Do you have an example that I could check?
I have the impression that my problem is that no .gcda files are created. If
I just run the lcov part:
lcov -d . -c -o lcov.info

I get
Found gcov version: 5.4.0
Scanning . for .gcda files ...
geninfo: WARNING: no .gcda files found in . - skipping!
Finished .info-file creation

and an empty file lcov.info is created.

Just to check, I've tried running make coverage and make coverage-html on
the folder of postgres instead of the extension and that works.

There is no need to complicate your Makefile with a custom coverage
target, which is, at least it seems to me, the origin of the problems
you are seeing here. So you could just use the one that Postgres' PGXS
provides. Here is a simple Makefile I have used for coverage testing
with an extension:
https://github.com/michaelpq/pg_plugins/blob/master/decoder_raw/Makefile
If you enforce abs_top_srcdir=$(pwd) with make coverage, or
coverage-html if you want, then both are able to work properly. At
least for me they do.
--
Michael

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#5Gabriel Furstenheim Milerud
furstenheim@gmail.com
In reply to: Michael Paquier (#4)
Re: Extension coverage

Great thanks, didn't realize that I was already importing coverage from
pgxs.

BTW, it fixed itself alone. At some point it started creating the .gcda
files and making the target.

On 28 August 2017 at 08:34, Michael Paquier <michael.paquier@gmail.com>
wrote:

Show quoted text

On Sat, Aug 26, 2017 at 6:28 PM, Gabriel Furstenheim Milerud
<furstenheim@gmail.com> wrote:

Not sure I follow. Do you have an example that I could check?
I have the impression that my problem is that no .gcda files are

created. If

I just run the lcov part:
lcov -d . -c -o lcov.info

I get
Found gcov version: 5.4.0
Scanning . for .gcda files ...
geninfo: WARNING: no .gcda files found in . - skipping!
Finished .info-file creation

and an empty file lcov.info is created.

Just to check, I've tried running make coverage and make coverage-html on
the folder of postgres instead of the extension and that works.

There is no need to complicate your Makefile with a custom coverage
target, which is, at least it seems to me, the origin of the problems
you are seeing here. So you could just use the one that Postgres' PGXS
provides. Here is a simple Makefile I have used for coverage testing
with an extension:
https://github.com/michaelpq/pg_plugins/blob/master/decoder_raw/Makefile
If you enforce abs_top_srcdir=$(pwd) with make coverage, or
coverage-html if you want, then both are able to work properly. At
least for me they do.
--
Michael