gcov problem with shared libs and autotools

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Can someone help me get some test coverage stats from gcov for files built out
of the source tree into a shared library using autotools please?

The directory structure is this:
project
    - configure.ac
    - src
        - libsrc.h
        - libsrc.cpp
        - Makefile.am
    - tests
        - unit
            - test.cpp
            - Makefile.am
    - build (see below)

I've added the --coverage flag to both mylib_la_CFLAGS and mylib_la_LDFLAGS in
src/Makefile.am; I've also added it into AM_CXXFLAGS and test_LDFLAGS in
tests/unit/Makefile.am.

On compilation I get all the appropriate .gcno files, but when I run the
executable the only .gcda file I get is test.gcda, not the required libsrc.gcda:

project (src and tests as above)
    - build
        - src
            - libsrc.o
            - libsrc.gcno
            - .libs
                - libsrc.o
                - libsrc.gcno
                - mylib.so
        - tests
            - unit
                - test.o
                - test.gcno
                - test.gcda
                - test (the executable)

Both libsrc.o object files in build/src and build/src/.libs are identical, as
are the libsrc.gcno files in the same directories.

I've seen this thread --> https://gcc.gnu.org/ml/gcc-help/2010-09/msg00134.html,
which says the .gcda file should end up in build/src/.libs, but it isn't there.
If I run
strings mylib.so | grep gcda
as per that thread it gives me project/build/src/.libs/libsrc.gcda, but then no
.gcda file actually gets written there.

I'm using ubuntu v14.04 with gcc v4.8.1.

I'm aware of the GCOV_PREFIX/_STRIP environment options, but even if I use those
to tell gcov to write .gcda files elsewhere there's still only ever the
test.gcda file written. I'm not really concerned where libsrc.gcda gets written
to, as long as it gets written, coz I can deal with that afterwards.

So far the only solution I've come up with to get coverage of libsrc.cpp, i.e.
to get the .gcda file, is to soft link libsrc.h/cpp into project/tests/unit, and
add it into test_SOURCES in tests/unit/Makefile.am and actually build it as part
of the executable and ignore the library, but that's both unwieldy, not great
for extending much, and just plain smells!!

Anyone got any ideas?

Thanks,
Jools





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux