Generate main() for running self-test.

Avoid running test from global constructor as (in skeleton code):

  (global scope)
  static int SKELETONResult = SKELETON::RunTest();

Executing complicated code in global constructors is quite dangerous. As
the order of global constructors being invoked between translation units
is unspecified, we may end up using things from dependent libraries that
haven't been initialized yet.

In our internal build environment, farmhash_unittest is linked against
static version of STL library (more specifically, libc++.a). Running it
gets segfault because RunTest()s access uninitialized `std::cout`.

This commit modifies builder.cc to generate main() in farmhash.cc which
calls RunTest()s for self-test code. There's no functionality changed.

Test plan: pass "make check".
4 files changed