Only the public API of a library is exported, so when a program is dynamically linked to the DSO (Dynamic Shared Object), it can only use the public functions.
So how do you unit test the private classes of your library?
There is a simple solution, having a Libtool convenience library that contains the whole code of the library, but without an
-export linker flag, so that all functions can still be accessed. You then link that *.la file to your unit tests and also to the real library where you add the appropriate
When you run
make in verbose mode with
make V=1, you see that the libtool commands statically link the convenience static library (a file with the *.a extension) into the unit test programs and into the DSO.
That way the *.c files are compiled only once, and adding a unit test to the
testsuite/Makefile.am is straightforward.