Fix C coverage reporting by using gcov directly#109
Conversation
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>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Summary of ChangesHello @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 Highlights
Using Gemini Code AssistThe 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
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 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
|
C Wrapper Coverage |
There was a problem hiding this comment.
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.
test/run_coverage.sh
Outdated
There was a problem hiding this comment.
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.
| gcov_out=$(gcov -b -c -o test_wrapper_cov-test_wrapper.gcda wrapper.c) | |
| gcov_out=$(gcov -b -c test/test_wrapper.c) |
There was a problem hiding this comment.
The
gcovcommand is constructed incorrectly. The-oflag expects a directory containing the object/.gcdafiles or a specific object file name. The provided argumenttest_wrapper_cov-test_wrapper.gcdais 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 intest/test_wrapper.c), you should rungcovon the source file that was compiled.gcovwill then find the corresponding.gcnoand.gcdafiles and generate reports for both the main file and any included files.
There was a problem hiding this comment.
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.
Android Code Coverage
|
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>
C Wrapper Coverage |
Android Code Coverage
|
Modified
test/run_coverage.shto abandonlcovand usegcovdirectly. This resolves incorrect coverage percentages (5.2%) caused bylcovmisinterpreting source files included in test files (wrapper.cintest_wrapper.c). The script now correctly targets the generated.gcdafile and parsesgcovoutput to report coverage forwrapper.cspecifically.PR created automatically by Jules for task 17646278732811453755 started by @keiji