Reputation: 103
I built glib link with coverage.
glib
uses the meson
build system which requires the build to be generated in a separate directory.
I run gcov
on each gcno
file generated in order to get function coverage. I am interested in coverage broken down by function.
I ran into two problems:
1- For gcno
files inside the build directory I get errors like
File '../glib/gcharset.c'
Lines executed:11.40% of 228
Creating 'gcharset.c.gcov'
Cannot open source file ../glib/gcharset.c
File '../glib/gstrfuncs.h'
Lines executed:100.00% of 1
Creating 'gstrfuncs.h.gcov'
Cannot open source file ../glib/gstrfuncs.h
I solved this by moving all the gcno
and gcda
files into a newly created directory in the root src directory of glib called coverage_files
. This way this relative path for the c files would be work.
2- The second problem is the one I am currently stuck on. I get coverage for some functions exceeding 100%.
Function 'g_get_charset'
Lines executed:106.25% of 16
This is seen across many functions in different files and I can't figure out why or how this is even possible.
This is an example of the output for one gcno
file.
gcov -f gcharset.c.gcno
Function 'g_get_language_names_with_category'
Lines executed:0.00% of 26
Function 'g_get_language_names'
Lines executed:0.00% of 2
Function 'language_names_cache_free'
Lines executed:0.00% of 6
Function 'guess_category_value'
Lines executed:0.00% of 14
Function 'g_get_locale_variants'
Lines executed:0.00% of 6
Function 'append_locale_variants'
Lines executed:0.00% of 22
Function 'explode_locale'
Lines executed:0.00% of 19
Function 'unalias_lang'
Lines executed:0.00% of 14
Function 'read_aliases'
Lines executed:0.00% of 24
Function 'g_get_console_charset'
Lines executed:0.00% of 2
Function 'g_get_codeset'
Lines executed:0.00% of 3
Function '_g_get_ctype_charset'
Lines executed:0.00% of 14
Function '_g_get_time_charset'
Lines executed:0.00% of 14
Function 'g_get_charset'
Lines executed:106.25% of 16
Function 'charset_cache_free'
Lines executed:0.00% of 6
Function 'g_utf8_get_charset_internal'
Lines executed:58.82% of 17
Function '_g_charset_get_aliases'
Lines executed:0.00% of 3
Function 'get_alias_hash'
Lines executed:0.00% of 21
File '../glib/gcharset.c'
Lines executed:11.40% of 228
Creating 'gcharset.c.gcov'
File '../glib/gstrfuncs.h'
Lines executed:100.00% of 1
Creating 'gstrfuncs.h.gcov'
Lines executed:11.79% of 229
Upvotes: 0
Views: 32