Code coverage check tool-gcov usage in Linux

Source: Internet
Author: User
Tags gcov
1. Add the compilation and link parameters:-fprofile-arcs-ftest-coverage. Take eclipse as an example. Add the preceding parameters to a C ++ project:
Project-> properties-> C/C ++ build-> Settings-> gcc C ++ compiler-> command: Enter g ++-fprofile-arcs-ftest-coverage

Project-> properties-> C/C ++ build-> Settings-> gcc C ++ linker-> command: Enter g ++-fprofile-arcs-ftest-coverage

2. Clear and build the entire project. 3. Run an executable file or test. 4. Generate a coverage report for a file. For example: sudo gcov ../src/clist. cpp-o ../debug/src/Because gcov needs to read and create files, we recommend that you use sudo for execution... /Src/clist. cpp indicates the source file to be analyzed. The-O parameter indicates that after the. o file is executed, clist. cpp. gcov is generated in the current directory. This is the coverage report of the file. 5. view the coverage report and view the clist. cpp. gcov file. The Rows marked with "####" indicate the rows that have not been overwritten. Supplement: CodeThe coverage rate check works with unit tests to improve the code quality test!
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.