Skip to content

Fix GCOV not working for PHP-7.4 and master branches #4739

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

Closed
wants to merge 1 commit into from

Conversation

gerardroche
Copy link
Contributor

@gerardroche gerardroche commented Sep 23, 2019

Code coverage reports (make lcov), since commit eef8522 (7.4 branch),
generates incorrect coverage and emits warnings. Simplifying
the Makefile.gcov file has the side-effect of resolving the issue.

Processing sapi/cli/php_http_parser.gcda
php-src/lcov_data/sapi/cli/php_http_parser.gcda:stamp mismatch with notes file
geninfo: WARNING: gcov did not create any files for php-src/lcov_data/sapi/cli/php_http_parser.gcda!
...
Processing ext/mbstring/mb_gpc.gcda
php-src/lcov_data/ext/mbstring/mb_gpc.gcda:stamp mismatch with notes file
geninfo: WARNING: gcov did not create any files for php-src/lcov_data/ext/mbstring/mb_gpc.gcda!

Closes: https://bugs.php.net/bug.php?id=52718.
See also: https://bugs.php.net/bug.php?id=78288.

@carusogabriel
Copy link
Contributor

Please see https://externals.io/message/107113.

@gerardroche
Copy link
Contributor Author

gerardroche commented Sep 23, 2019

So it looks there are two issues: generating coverage locally (this PR should fix that) and publishing the coverage which looks complicated and as yet undecided.

Code coverage reports (`make lcov`), since commit eef8522 (7.4 branch),
generates incorrect coverage and emits warnings. Simplifying the
Makefile.gcov file has the side-effect of resolving the issue.

    Processing sapi/cli/php_http_parser.gcda
    php-src/lcov_data/sapi/cli/php_http_parser.gcda:stamp mismatch with notes file
    geninfo: WARNING: gcov did not create any files for php-src/lcov_data/sapi/cli/php_http_parser.gcda!
    ...
    Processing ext/mbstring/mb_gpc.gcda
    php-src/lcov_data/ext/mbstring/mb_gpc.gcda:stamp mismatch with notes file
    geninfo: WARNING: gcov did not create any files for php-src/lcov_data/ext/mbstring/mb_gpc.gcda!

Closes: https://bugs.php.net/bug.php?id=52718.
See also: https://bugs.php.net/bug.php?id=78288.
@gerardroche gerardroche changed the title Fix #78288 GCOV not working for PHP-7.4 and master branches Fix GCOV not working for PHP-7.4 and master branches Sep 24, 2019
@carusogabriel
Copy link
Contributor

So it looks there are two issues: generating coverage locally (this PR should fix that) and publishing the coverage which looks complicated and as yet undecided.

Indeed. Thanks for change the PR message.

@nikic
Copy link
Member

nikic commented Sep 25, 2019

I applied this patch and used

sudo apt install lcov
./configure --enable-debug --enable-lcov CCACHE_DISABLE=1
make lcov-html TESTS="-j6"

Which gives me a lot of warnings:

Processing main/SAPI.gcda
geninfo: WARNING: /home/nikic/php-7.4-gcov/main/SAPI.gcno: Overlong record at end of file!
/home/nikic/php-7.4-gcov/main/SAPI.gcno:version 'A83*', prefer 'A74*'
/home/nikic/php-7.4-gcov/main/SAPI.gcno:no functions found
geninfo: WARNING: gcov did not create any files for /home/nikic/php-7.4-gcov/main/SAPI.gcda!

@nikic
Copy link
Member

nikic commented Sep 25, 2019

Okay, looks like this is gcov vs gcc version mismatch on my side. After running

sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-8 90

the version warning goes away, but instead I get:

Processing main/SAPI.gcda
geninfo: WARNING: /home/nikic/php-7.4-gcov/main/SAPI.gcno: Overlong record at end of file!
geninfo: WARNING: cannot find an entry for #home#nikic#php-7.4-gcov#Zend#zend_hash.h.gcov in .gcno file, skipping file!
geninfo: WARNING: cannot find an entry for #home#nikic#php-7.4-gcov#Zend#zend_string.h.gcov in .gcno file, skipping file!
geninfo: WARNING: cannot find an entry for #home#nikic#php-7.4-gcov#Zend#zend_types.h.gcov in .gcno file, skipping file!
geninfo: WARNING: cannot find an entry for #home#nikic#php-7.4-gcov#main#SAPI.c.gcov in .gcno file, skipping file!

@nikic
Copy link
Member

nikic commented Sep 25, 2019

Based on linux-test-project/lcov#38 it looks like my lcov version is not compatible with GCC 8. After reconfiguring with

./config.nice CC=gcc-7 LTP="lcov --gcov-tool gcov-7"

it works.

As to the patch itself, I guess the disadvantage of this change is that now the ignored files will still be processed and only discarded afterwards. But that doesn't seem like much of a problem nowadays.

@nikic
Copy link
Member

nikic commented Sep 25, 2019

Merged as 9cc1bf5 into 7.4. While at it, I've also added the --no-external flag to exclude system headers.

Would you be interested in also looking into the Azure Pipelines integration, as mentioned in https://externals.io/message/107113?

@nikic nikic closed this Sep 25, 2019
@gerardroche gerardroche deleted the issue/78288 branch September 26, 2019 13:31
@gerardroche
Copy link
Contributor Author

Sometimes warnings can be caused by missing libraries which need to added to the exclusion list. The version of gcov I've been testing against is:

gcov (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
lcov: LCOV version 1.13
genhtml: LCOV version 1.13
gcovr 3.4

gcov.php,net is using LCOV 1.10.

As to the patch itself, I guess the disadvantage of this change is that now the ignored files will still be processed and only discarded afterwards. But that doesn't seem like much of a problem nowadays.

I couldn't find a way around that. It's probably still faster than the alternatives.

I've also added the --no-external flag to exclude system headers.

Nice. The coverage report is starting to look a lot less cluttered.

Would you be interested in also looking into the Azure Pipelines integration, as mentioned in https://externals.io/message/107113?

I'm looking into it. I'll follow up on the mailing list.

gerardroche added a commit to gerardroche/php-src that referenced this pull request Sep 26, 2019
gerardroche added a commit to gerardroche/php-src that referenced this pull request Sep 27, 2019
gerardroche added a commit to gerardroche/php-src that referenced this pull request Sep 27, 2019
gerardroche added a commit to gerardroche/php-src that referenced this pull request Sep 27, 2019
gerardroche added a commit to gerardroche/php-src that referenced this pull request Sep 29, 2019
gerardroche added a commit to gerardroche/php-src that referenced this pull request Sep 29, 2019
gerardroche added a commit to gerardroche/php-src that referenced this pull request Sep 29, 2019
gerardroche added a commit to gerardroche/php-src that referenced this pull request Sep 29, 2019
gerardroche added a commit to gerardroche/php-src that referenced this pull request Sep 29, 2019
gerardroche added a commit to gerardroche/php-src that referenced this pull request Sep 30, 2019
gerardroche added a commit to gerardroche/php-src that referenced this pull request Oct 1, 2019
* Add an Azure Publish Code Coverage Results task
* Add `make gcovr-html` to generate a gcovr test coverage report in HTML
* Add `make gcovr-xml` to generate a gcovr test coverage report in XML
* Remove `test` target dependency from `make lcov-html`; Run the two targets together instead: `make test lcov-html`.

Re: php#4739 (comment)

See: https://externals.io/message/107113,
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-code-coverage-results?view=azure-devops,
and php#4759.
gerardroche added a commit to gerardroche/php-src that referenced this pull request Oct 1, 2019
* Add an Azure Publish Code Coverage Results task
* Add `make gcovr-html` to generate a gcovr test coverage report in HTML
* Add `make gcovr-xml` to generate a gcovr test coverage report in XML
* Remove `test` target dependency from `make lcov-html`; Run the two targets together instead: `make test lcov-html`.

Re: php#4739 (comment)

See: https://externals.io/message/107113,
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-code-coverage-results?view=azure-devops,
and php#4759.
gerardroche added a commit to gerardroche/php-src that referenced this pull request Oct 1, 2019
* Add an Azure Publish Code Coverage Results task
* Add `make gcovr-html` to generate a gcovr test coverage report in HTML
* Add `make gcovr-xml` to generate a gcovr test coverage report in XML
* Remove `test` target dependency from `make lcov-html`; Run the two targets together instead: `make test lcov-html`.

Re: php#4739 (comment)

See: https://externals.io/message/107113,
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-code-coverage-results?view=azure-devops,
and php#4759.
nikic pushed a commit to gerardroche/php-src that referenced this pull request Oct 11, 2019
* Add an Azure Publish Code Coverage Results task
* Add `make gcovr-html` to generate a gcovr test coverage report in HTML
* Add `make gcovr-xml` to generate a gcovr test coverage report in XML
* Remove `test` target dependency from `make lcov-html`; Run the two targets together instead: `make test lcov-html`.

Re: php#4739 (comment)

See: https://externals.io/message/107113,
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-code-coverage-results?view=azure-devops,
and php#4759.
php-pulls pushed a commit that referenced this pull request Oct 11, 2019
* Add an Azure Publish Code Coverage Results task
* Add `make gcovr-html` to generate a gcovr test coverage report in HTML
* Add `make gcovr-xml` to generate a gcovr test coverage report in XML
* Remove `test` target dependency from `make lcov-html`;
  Run the two targets together instead: `make test lcov-html`.

Re: #4739 (comment)

See: https://externals.io/message/107113,
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-code-coverage-results?view=azure-devops,
and #4759.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants