test-lib: support running tests under valgrind in parallel
commitad0e6233320b004f0d686f6887c803e508607bd2
authorThomas Rast <trast@inf.ethz.ch>
Sun, 23 Jun 2013 18:12:59 +0000 (23 20:12 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 23 Jun 2013 19:24:06 +0000 (23 12:24 -0700)
tree92e9c9256b79904a8bc6c4e37c5aa0692d2ed83b
parente939e15d241e942662b9f88f6127ab470ab0a0b9
test-lib: support running tests under valgrind in parallel

With the new --valgrind-parallel=<n> option, we support running the
tests in a single test script under valgrind in parallel using 'n'
processes.

This really follows the dumbest approach possible, as follows:

* We spawn the test script 'n' times, using a throw-away
  TEST_OUTPUT_DIRECTORY.  Each of the instances is given options that
  ensures that it only runs every n-th test under valgrind, but
  together they cover the entire range.

* We add up the numbers from the individual tests, and provide the
  usual output.

This is really a gross hack at this point, and should be improved.  In
particular we should keep the actual outputs somewhere more easily
discoverable, and summarize them to the user.

Nevertheless, this is already workable and gives a speedup of more
than 2 on a dual-core (hyperthreaded) machine, using n=4.  This is
expected since the overhead of valgrind is so big (on the order of 20x
under good conditions, and a large startup overhead at every git
invocation) that redundantly running the non-valgrind tests in between
is not that expensive.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh