Manual generation of .gcov files

Description

I need to make https://codecov.io/bash to use already generated .gcov files instead of generating them from .gcno/.gcda files itself.

My compilation flow is more complicated (e.g. compiler runs from several directories, not just the root one) so Codecov’s simple algorithm does not work (e.g. as can be seen from Codecov only coverage for src is uploaded and coverage for tests/ is not).

I see that I can run
codecov -X gcov
Will that be enough for my usecase i.e. will codecov pick up pre-generated .gcov files in this mode ?

CI/CD URL

Codecov Output

+ curl --retry 5 -s https://codecov.io/bash
+ bash codecov.bash -Z

  _____          _
 / ____|        | |
| |     ___   __| | ___  ___ _____   __
| |    / _ \ / _` |/ _ \/ __/ _ \ \ / /
| |___| (_) | (_| |  __/ (_| (_) \ V /
 \_____\___/ \__,_|\___|\___\___/ \_/
                              Bash-1.0.6


==> git version 2.34.1 found
==> curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Release-Date: 2020-01-08
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets
==> GitHub Actions detected.
    Env vars used:
      -> GITHUB_ACTIONS:    true
      -> GITHUB_HEAD_REF:   
      -> GITHUB_REF:        refs/heads/master
      -> GITHUB_REPOSITORY: yugr/valgrind-preload
      -> GITHUB_RUN_ID:     1662172031
      -> GITHUB_SHA:        eb5398f2d69807846d6087a849033e3db510cc2d
      -> GITHUB_WORKFLOW:   CI
    current dir:  /home/runner/work/valgrind-preload/valgrind-preload
    project root: .
--> token set from env
    Yaml not found, that's ok! Learn more at http://docs.codecov.io/docs/codecov-yaml
==> Running gcov in . (disable via -X gcov)
Cannot open source file parent.c
Cannot open source file child.c
File 'src/async_safe.c'
Lines executed:32.61% of 46
Branches executed:17.14% of 35
Taken at least once:8.57% of 35
Calls executed:25.00% of 12
Creating 'src#async_safe.c.gcov'

File '/usr/include/spawn.h'
Lines executed:50.00% of 2
No branches
Calls executed:50.00% of 2
Creating '#usr#include#spawn.h.gcov'

File 'src/pregrind.c'
Lines executed:30.08% of 256
Branches executed:29.89% of 174
Taken at least once:17.82% of 174
Calls executed:26.52% of 132
Creating 'src#pregrind.c.gcov'

File '/usr/include/unistd.h'
Lines executed:0.00% of 7
Branches executed:0.00% of 14
Taken at least once:0.00% of 14
No calls
Creating '#usr#include#unistd.h.gcov'

File 'parent.c'
Lines executed:64.00% of 25
Branches executed:90.00% of 20
Taken at least once:50.00% of 20
Calls executed:30.00% of 20
Creating 'parent.c.gcov'

File 'child.c'
Lines executed:100.00% of 5
No branches
No calls
Creating 'child.c.gcov'

File '/usr/include/x86_64-linux-gnu/bits/stdio2.h'
Lines executed:0.00% of 2
No branches
Calls executed:0.00% of 1
Creating '#usr#include#x86_64-linux-gnu#bits#stdio2.h.gcov'

==> Python coveragepy not found
==> Searching for coverage reports in:
    + .
    -> Found 7 reports
==> Detecting git/mercurial file structure
==> Reading reports
    + ./#usr#include#spawn.h.gcov bytes=11498
    + ./#usr#include#x86_64-linux-gnu#bits#stdio2.h.gcov bytes=18947
    + ./src#pregrind.c.gcov bytes=30990
    + ./parent.c.gcov bytes=32
    + ./child.c.gcov bytes=31
    + ./src#async_safe.c.gcov bytes=5114
    + ./#usr#include#unistd.h.gcov bytes=62374
==> Appending adjustments
    https://docs.codecov.io/docs/fixing-reports
    + Found adjustments
==> Gzipping contents
        4.0K	/tmp/codecov.LzCPOX.gz
==> Uploading reports
    url: https://codecov.io
    query: branch=master&commit=eb5398f2d69807846d6087a849033e3db510cc2d&build=1662172031&build_url=https%3A%2F%2Fgithub.com%2Fyugr%2Fvalgrind-preload%2Factions%2Fruns%2F1662172031&name=&tag=&slug=yugr%2Fvalgrind-preload&service=github-actions&flags=&pr=&job=CI&cmd_args=Z
->  Pinging Codecov
https://codecov.io/upload/v4?package=bash-1.0.6&token=<hidden>&package=bash-1.0.6&token=***&branch=master&commit=eb5398f2d69807846d6087a849033e3db510cc2d&build=1662172031&build_url=https%3A%2F%2Fgithub.com%2Fyugr%2Fvalgrind-preload%2Factions%2Fruns%2F1662172031&name=&tag=&slug=yugr%2Fvalgrind-preload&service=github-actions&flags=&pr=&job=CI&cmd_args=Z
->  Uploading to
https://storage.googleapis.com/codecov/v4/raw/2022-01-06/84EBECC72A9618A259E9045D8D4BAAC5/eb5398f2d69807846d6087a849033e3db510cc2d/41269ce3-b6c3-49d7-b822-897a099015b8.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GOOG1EKKHVKCKHW7KBCGM7IHR55T63V2PAVJWLVFNITJHDU5G6R5IRN3LMWJA%2F20220106%2FUS%2Fs3%2Faws4_request&X-Amz-Date=20220106T082710Z&X-Amz-Expires=10&X-Amz-SignedHeaders=host&X-Amz-Signature=53302d0904b1e01d95d15cd1616fa3934588470c85834a2d0a157d1df48a2ee0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  2140    0     0  100  2140      0  10388 --:--:-- --:--:-- --:--:-- 10388
    -> Reports have been successfully queued for processing at https://codecov.io/github/yugr/valgrind-preload/commit/eb5398f2d69807846d6087a849033e3db510cc2d

Expected Results

N/A

Actual Results

N/A

Additional Information

N/A

1 Like

Hi @yugr, the bash script is being deprecated. If you use -X gcov, that should fix your use case. If not, you can use the -f flag to specify the file to upload. But bear in mind that you will need to move to the new uploader in the future.

@tom thank you. In case someone later finds this interesting I was able to do custom coverage collection at valgrind-preload/travis.sh at master · yugr/valgrind-preload · GitHub