Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Using gcov and lcov

31,196 views

Published on

introduction to gcov and lcov

Published in: Technology
  • Login to see the comments

Using gcov and lcov

  1. 1. Using gcov and lcov<br />Magus Chen<br />maguschen@hotmail.com<br />http://magustest.com/blog/<br />
  2. 2. Agenda<br />gcov<br />lcov<br />How to apply gcov on ads<br />Using lcov generate report<br />Example<br />2<br />
  3. 3. Introduction to gcov<br />A test coverage program<br />Works only on code compiled with GCC<br />Collect code coverage data and generate plain text coverage report<br />3<br />
  4. 4. Introduction to lcov<br />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.<br />4<br />
  5. 5. How to apply gcov on ads<br />Build adserver with option “--coverage”<br />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).<br />5<br />
  6. 6. How to apply gcov on ads<br />Copy ads binary to your own environment <br />Export two envGCOV_PREFIX and GCOV_PREFIX_STRIP <br />Run ads<br />Send request<br />To generate code coverage data, exit the program normally (using kill, not kill -9)<br />Some .gcda file is generated<br />6<br />
  7. 7. How to generate html report<br />Copy all source files and .gcno files from build server to your own environment<br />Copy all .gcda file to your own environment<br />lcov -t 'Adserver regression' -o ads_test.info -c -d .<br />-t title<br />-o output file name<br />-c capture coverage data<br />-d use data files in DIR<br />7<br />
  8. 8. How to generate html report<br />genhtml -o result ads_test.info <br />-o output folder of the all html contents<br />ads_test.info INFO FILE name<br />8<br />
  9. 9. How to view the HTML report<br />Apache httpd<br />/etc/init.d/httpd start<br />Copy or link the result folder under /var/www/html/<br />Lighttpd<br />/usr/local/sbin/lighttpd -f lighttpd_jchen.conf<br />Copy or link the result folder under server.document-root<br />9<br />
  10. 10. Example<br />10<br />
  11. 11. Q & A<br />11<br />
  12. 12. Thank you<br />

×