using gcov and lcov
DESCRIPTION
introduction to gcov and lcovTRANSCRIPT
![Page 2: Using gcov and lcov](https://reader033.vdocument.in/reader033/viewer/2022061122/546fd744af7959b80a8b469e/html5/thumbnails/2.jpg)
2
Agenda
• gcov• lcov• How to apply gcov on ads• Using lcov generate report• Example
![Page 3: Using gcov and lcov](https://reader033.vdocument.in/reader033/viewer/2022061122/546fd744af7959b80a8b469e/html5/thumbnails/3.jpg)
3
Introduction to gcov
• A test coverage program
• Works only on code compiled with GCC
• Collect code coverage data and generate
plain text coverage report
![Page 4: Using gcov and lcov](https://reader033.vdocument.in/reader033/viewer/2022061122/546fd744af7959b80a8b469e/html5/thumbnails/4.jpg)
4
Introduction to lcov
• LCOV is a graphical front-end for GCC's coverage testing
tool gcov. It collects gcov data for multiple source files
and creates HTML pages containing the source code
annotated with coverage information. It also adds
overview pages for easy navigation within the file
structure. LCOV supports statement, function and
branch coverage measurement.
![Page 5: Using gcov and lcov](https://reader033.vdocument.in/reader033/viewer/2022061122/546fd744af7959b80a8b469e/html5/thumbnails/5.jpg)
5
How to apply gcov on ads
• Build adserver with option “--coverage”
– This option is used to compile and link code
instrumented for coverage analysis. The option is
a synonym for -fprofile-arcs -ftest-coverage
(when compiling) and -lgcov (when linking).
![Page 6: Using gcov and lcov](https://reader033.vdocument.in/reader033/viewer/2022061122/546fd744af7959b80a8b469e/html5/thumbnails/6.jpg)
6
How to apply gcov on ads
• Copy ads binary to your own environment
– Export two env GCOV_PREFIX and GCOV_PREFIX_STRIP
– Run ads
– Send request
– To generate code coverage data, exit the program
normally (using kill, not kill -9)
– Some .gcda file is generated
![Page 7: Using gcov and lcov](https://reader033.vdocument.in/reader033/viewer/2022061122/546fd744af7959b80a8b469e/html5/thumbnails/7.jpg)
7
How to generate html report
• Copy all source files and .gcno files from build server to your own
environment
• Copy all .gcda file to your own environment
• lcov -t 'Adserver regression' -o ads_test.info -c -d .
– -t title
– -o output file name
– -c capture coverage data
– -d use data files in DIR
![Page 8: Using gcov and lcov](https://reader033.vdocument.in/reader033/viewer/2022061122/546fd744af7959b80a8b469e/html5/thumbnails/8.jpg)
8
How to generate html report
• genhtml -o result ads_test.info
– -o output folder of the all html contents
– ads_test.info INFO FILE name
![Page 9: Using gcov and lcov](https://reader033.vdocument.in/reader033/viewer/2022061122/546fd744af7959b80a8b469e/html5/thumbnails/9.jpg)
9
How to view the HTML report
• Apache httpd
– /etc/init.d/httpd start
– Copy or link the result folder under /var/www/html/
• Lighttpd
– /usr/local/sbin/lighttpd -f lighttpd_jchen.conf
– Copy or link the result folder under server.document-root
![Page 10: Using gcov and lcov](https://reader033.vdocument.in/reader033/viewer/2022061122/546fd744af7959b80a8b469e/html5/thumbnails/10.jpg)
10
Example
![Page 11: Using gcov and lcov](https://reader033.vdocument.in/reader033/viewer/2022061122/546fd744af7959b80a8b469e/html5/thumbnails/11.jpg)
11
Q & A
![Page 12: Using gcov and lcov](https://reader033.vdocument.in/reader033/viewer/2022061122/546fd744af7959b80a8b469e/html5/thumbnails/12.jpg)
Thank you