Only run one make at a time.

If openssl has not been built, running parallel make processes causes some problems.
	Change on 2015/01/09 by ctiller <ctiller@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83617340
diff --git a/tools/run_tests/jobset.py b/tools/run_tests/jobset.py
index d3a46b6..2ab95ef 100755
--- a/tools/run_tests/jobset.py
+++ b/tools/run_tests/jobset.py
@@ -8,7 +8,7 @@
 import time
 
 
-_MAX_JOBS = 16 * multiprocessing.cpu_count()
+_DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count()
 
 
 def shuffle_iteratable(it):
@@ -81,15 +81,16 @@
 class Jobset(object):
   """Manages one run of jobs."""
 
-  def __init__(self, check_cancelled):
+  def __init__(self, check_cancelled, maxjobs):
     self._running = set()
     self._check_cancelled = check_cancelled
     self._cancelled = False
     self._failures = 0
+    self._maxjobs = maxjobs
 
   def start(self, cmdline):
     """Start a job. Return True on success, False on failure."""
-    while len(self._running) >= _MAX_JOBS:
+    while len(self._running) >= self._maxjobs:
       if self.cancelled(): return False
       self.reap()
     if self.cancelled(): return False
@@ -130,10 +131,10 @@
   return False
 
 
-def run(cmdlines, check_cancelled=_never_cancelled):
-  js = Jobset(check_cancelled)
+def run(cmdlines, check_cancelled=_never_cancelled, maxjobs=None):
+  js = Jobset(check_cancelled,
+              maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS)
   for cmdline in shuffle_iteratable(cmdlines):
     if not js.start(cmdline):
       break
   return js.finish()
-
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 9234682..d678721 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -43,10 +43,10 @@
   # build latest, sharing cpu between the various makes
   if not jobset.run(
       (['make',
-        '-j', '%d' % max(multiprocessing.cpu_count() / len(configs), 1),
+        '-j', '%d' % (multiprocessing.cpu_count() + 1),
         'buildtests_c',
         'CONFIG=%s' % cfg]
-       for cfg in configs), check_cancelled):
+       for cfg in configs), check_cancelled, maxjobs=1):
     sys.exit(1)
 
   # run all the tests