Makefile, libminijail: Invert symbol visibility to allow sane unittesting
libminijail.c contains many helpers that are marked static. For instance,
consumestr and consumebytes are both static yet eminently unittestable.
The options for testing are as follows:
1. Replace "static" with a "private" or "protected" macro which we
undefined during testing.
2. #include "libminijail.c" into the unittests to avoid visibility
challenges.
3. Change default visibility to internal for all functions and data
then invert it during unittesting.
I chose #3. It also has the benefit of creating an optimally stripped
binary and shared object. Using 'internal' visibility also let's the
linker perform more optimizations.
Feedback on this approach is very welcome. In the past, I've chosen
approach #2, but that seems wrong for at least a couple of reasons.
TEST=build, run readelf -s in all the output. .so should show LOCAL for
all internal functions and on executables, private functions should show
INTERNAL. Running strip --unneeded should remove all of the private
linkage which can be checked with readelf -s again
BUG=none
Change-Id: Ifb1f02b4505f2f25d824c067748054520c39d3bf
Reviewed-on: https://gerrit.chromium.org/gerrit/10540
Commit-Ready: Will Drewry <wad@chromium.org>
Tested-by: Will Drewry <wad@chromium.org>
Reviewed-by: Will Drewry <wad@chromium.org>
4 files changed