vendredi 26 juin 2015

gcov returns "Unexpected number of functions"

I plan to use gcov to get the coverage info. I start with this toy program

#include <stdio.h>

double foo(double x){
  if (x>0)

    printf("A0\n");
  else
    if (x<-10)
      printf("A0\n");
    else
      printf("A1\n");
  return 0;

}

int main(){
  foo(2);
  foo(-10);
}

My command line is:

  gcc -fprofile-arcs -ftest-coverage -o test test.c
  ./test
  gcov test

But I get this error message using

~ gcov test.c
Unexpected number of functions.
Invalid .gcda File!
~ gcov test.c

My objective is to test the branch and line coverage for the function 'foo'. What command line should I use?

Aucun commentaire:

Enregistrer un commentaire