diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-06-06 14:56:05 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-07-10 15:20:09 -0400 |
commit | f7d654b81e1a65803c22bb53fc1d3a2021d87d50 (patch) | |
tree | f97ef47c02419b0d38f03b85ad62f745e653cf41 /src/or/include.am | |
parent | fab99844fc324b2c9d415b1b1c192a25cf1c4230 (diff) | |
download | tor-f7d654b81e1a65803c22bb53fc1d3a2021d87d50.tar.gz tor-f7d654b81e1a65803c22bb53fc1d3a2021d87d50.zip |
Start work on fancy compiler tricks to expose extra stuff to our tests
This is mainly a matter of automake trickery: we build each static
library in two versions now: one with the TOR_UNIT_TESTS macro
defined, and one without. When TOR_UNIT_TESTS is defined, we can
enable mocking and expose more functions. When it's not defined, we
can lock the binary down more.
The alternatives would be to have alternate build modes: a "testing
configuration" for building the libraries with test support, and a
"production configuration" for building them without. I don't favor
that approach, since I think it would mean more people runnning
binaries build for testing, or more people not running unit tests.
Diffstat (limited to 'src/or/include.am')
-rw-r--r-- | src/or/include.am | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/or/include.am b/src/or/include.am index 65dbeff53e..91b9bfce72 100644 --- a/src/or/include.am +++ b/src/or/include.am @@ -1,5 +1,10 @@ bin_PROGRAMS+= src/or/tor -noinst_LIBRARIES+= src/or/libtor.a +noinst_LIBRARIES += \ + src/or/libtor.a +if UNITTESTS_ENABLED +noinst_LIBRARIES += \ + src/or/libtor-testing.a +endif if BUILD_NT_SERVICES tor_platform_source=src/or/ntmain.c @@ -21,7 +26,7 @@ else onion_ntor_source= endif -src_or_libtor_a_SOURCES = \ +LIBTOR_A_SOURCES = \ src/or/addressmap.c \ src/or/buffers.c \ src/or/channel.c \ @@ -77,6 +82,9 @@ src_or_libtor_a_SOURCES = \ $(onion_ntor_source) \ src/or/config_codedigest.c +src_or_libtor_a_SOURCES = $(LIBTOR_A_SOURCES) +src_or_libtor_testing_a_SOURCES = $(LIBTOR_A_SOURCES) + #libtor_a_LIBADD = ../common/libor.a ../common/libor-crypto.a \ # ../common/libor-event.a @@ -90,6 +98,8 @@ AM_CPPFLAGS += -DSHARE_DATADIR="\"$(datadir)\"" \ -DLOCALSTATEDIR="\"$(localstatedir)\"" \ -DBINDIR="\"$(bindir)\"" +src_or_libtor_testing_a_CPPFLAGS = -DTOR_UNIT_TESTS $(AM_CPPFLAGS) + # -L flags need to go in LDFLAGS. -l flags need to go in LDADD. # This seems to matter nowhere but on windows, but I assure you that it # matters a lot there, and is quite hard to debug if you forget to do it. |