Skip to content

Fix C coverage reporting by using gcov directly#109

Merged
keiji merged 2 commits intomainfrom
fix/c-coverage-reporting-17646278732811453755
Jan 31, 2026
Merged

Fix C coverage reporting by using gcov directly#109
keiji merged 2 commits intomainfrom
fix/c-coverage-reporting-17646278732811453755

Conversation

@keiji
Copy link
Owner

@keiji keiji commented Jan 31, 2026

Modified test/run_coverage.sh to abandon lcov and use gcov directly. This resolves incorrect coverage percentages (5.2%) caused by lcov misinterpreting source files included in test files (wrapper.c in test_wrapper.c). The script now correctly targets the generated .gcda file and parses gcov output to report coverage for wrapper.c specifically.


PR created automatically by Jules for task 17646278732811453755 started by @keiji

Modified `test/run_coverage.sh` to abandon `lcov` and use `gcov` directly.
This resolves incorrect coverage percentages (5.2%) caused by `lcov`
misinterpreting source files included in test files (`wrapper.c` in
`test_wrapper.c`). The script now correctly targets the generated `.gcda`
file and parses `gcov` output to report coverage for `wrapper.c` specifically.

Co-authored-by: keiji <932136+keiji@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist
Copy link

Summary of Changes

Hello @keiji, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the C code coverage reporting mechanism by transitioning from lcov to direct gcov commands. The primary goal is to rectify inaccuracies in coverage percentages, particularly for source files included within test files, ensuring that only relevant code's coverage is measured and reported correctly.

Highlights

  • Coverage Tool Switch: Replaced lcov with direct gcov usage in test/run_coverage.sh to improve C code coverage reporting accuracy.
  • Coverage Accuracy Fix: Resolved an issue where lcov incorrectly reported low coverage (5.2%) due to misinterpreting source files included in test files.
  • Targeted Reporting: Implemented specific parsing of gcov output to ensure accurate coverage reporting solely for wrapper.c.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Contributor

C Wrapper Coverage

Lines executed:89.96% of 269

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to fix C coverage reporting by switching from lcov to gcov. This is a good approach to resolve issues with lcov's handling of included source files. The gcov command in test/run_coverage.sh was malformed and would cause the script to fail; a critical comment with a suggested fix has been retained to make the script functional.

Choose a reason for hiding this comment

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

critical

The gcov command is constructed incorrectly. The -o flag expects a directory containing the object/.gcda files or a specific object file name. The provided argument test_wrapper_cov-test_wrapper.gcda is neither, and this file is not generated by the build process, which will cause the command to fail.

To correctly generate coverage for wrapper.c (which is included in test/test_wrapper.c), you should run gcov on the source file that was compiled. gcov will then find the corresponding .gcno and .gcda files and generate reports for both the main file and any included files.

Suggested change
gcov_out=$(gcov -b -c -o test_wrapper_cov-test_wrapper.gcda wrapper.c)
gcov_out=$(gcov -b -c test/test_wrapper.c)

Copy link
Owner Author

Choose a reason for hiding this comment

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

critical

The gcov command is constructed incorrectly. The -o flag expects a directory containing the object/.gcda files or a specific object file name. The provided argument test_wrapper_cov-test_wrapper.gcda is neither, and this file is not generated by the build process, which will cause the command to fail.

To correctly generate coverage for wrapper.c (which is included in test/test_wrapper.c), you should run gcov on the source file that was compiled. gcov will then find the corresponding .gcno and .gcda files and generate reports for both the main file and any included files.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for the feedback. I have updated the script to run gcov on the compiled source file test/test_wrapper.c as requested.

However, I must retain the -o test_wrapper_cov-test_wrapper.gcda flag. This file is generated by the build process (verified locally). Because gcc is invoked with -o test_wrapper_cov along with multiple source files, it prefixes the auxiliary .gcda and .gcno files with the executable name. Without the explicit -o flag pointing to this specific artifact, gcov fails to locate the coverage data for test/test_wrapper.c.

@github-actions
Copy link
Contributor

Android Code Coverage

Overall Project 86.13% 🍏

There is no coverage information present for the Files changed

Updated `test/run_coverage.sh` to run `gcov` against `test/test_wrapper.c`
instead of `wrapper.c`, addressing review feedback. The explicit `-o` flag
pointing to `test_wrapper_cov-test_wrapper.gcda` is retained as it is
required to locate the prefixed coverage data files generated by GCC.

Co-authored-by: keiji <932136+keiji@users.noreply.github.com>
@github-actions
Copy link
Contributor

C Wrapper Coverage

Lines executed:89.96% of 269

@github-actions
Copy link
Contributor

Android Code Coverage

Overall Project 86.13% 🍏

There is no coverage information present for the Files changed

@keiji keiji merged commit c0847ec into main Jan 31, 2026
2 checks passed
@keiji keiji deleted the fix/c-coverage-reporting-17646278732811453755 branch January 31, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments