Measuring test coverage of GSL with GCOV

Z. zell08v@gmail.com
Thu May 9 20:23:00 GMT 2019


Hello,

I want to use GCOV to measure how many statement/functions of GNU
Scientific Library (GSL) have been reached by a user-defined program.

The user-defined program is an example from GSL’s manual:
https://www.gnu.org/software/gsl/manual/html_node/Example-statistical-programs.html.
Something llke

*#include <stdio.h> *
*#include <gsl/gsl_statistics.h> *

*int *
*main(void) *
*{ *
*  double data[5] = {17.2, 18.1, 16.5, 18.3, 12.6}; *
*... *
*  smallest = gsl_stats_min(data, 1, 5); *
*… *
*return 0; *
*} *

First,  I compiled GSL with relevant flags:  ./configure
CFLAGS="-fprofile-arcs -ftest-coverage -g -O0”

Then, I compiled and linked the example program to GSL: gcc -fprofile-arcs
-ftest-coverage -g -O0 example.c -lgsl -lgslcblas -lm

At last I ran the example program: LD_LIBRARY_PATH=/usr/local/lib ./a.out

But, I could only see example.gcov, namely, only coverage info for the
example seems to be  produced.  Where did it go wrong? How can I also get
coverage for the code in GSL part?

Thanks.

Zhoulai



More information about the Gcc-help mailing list