crosperf: make run_tests use our new test runner

This is three small changes in one.

The main attraction is no functional change. The benefits we see are:
A. less cluttered output
B. total wall time of test running is down from 18s to
   13s on my machine, since the test runner spawns all
   tests in parallel

The second change is that we now set PYTHONPATH for linting. Otherwise,
we'll see errors about bad imports.

Finally, this fixes a test. It appears that the parameters of this
assertRaises function have been accidentally flipped, though that works
without issue outside of the chroot. To understand why, consider that
assertRaises has two forms that act completely differently:

self.assertRaises(Exception, foo)

Which causes self.assertRaises to run foo(), and expect that foo()
raises an Exception.

Additionally, it can be used like so:

with self.assertRaises(Exception):
  foo()

Which causes assertRaises to intercept any Exception that the block
under it may throw.

The difference between the in-chroot and out-of-chroot Python is simple:
outside of the chroot, the default value for the second arg to
assertRaises -- not counting `self` -- is None. Inside of the chroot,
they have a special, hidden sentinel value that it defaults to.

So, *outside* of the chroot, `self.assertRaises(Exception)` is
equivalent to `self.assertRaises(Exception, None)`, so the latter
returns a context object that tries to catch an exception.

Inside of the chroot, `self.assertRaises(Exception, None)` is not
equivalent to `self.assertRaises(Exception)`, and `None` is called as
though it was a function.

Since the removed code was `self.assertRaises(foo, None)`, outside of
the chroot, we'd just be returned a context object that we dropped on
the floor. Inside of the chroot, `self.assertRaises(foo, None)` would
try to call `None()`, fail, then try to say
`issubclass(exception_that_calling_none_raised, foo)`, but foo is a
function, so `issubclass` would raise on its own.

For those keeping score at home, the chroot's behavior was introduced in
upstream Python in 7f71e04cb510c24be337a22350324dc8a28e9775, which
landed in the 2.7.10 release. It wasn't until 2.7.11 that the revert
049060c249a83b69c4841ed37b7f4303f9ad7dd7 took effect. For more, the bug
was https://bugs.python.org/issue24134

BUG=None
TEST=./run_tests.sh

Change-Id: I58c398caafde03242ed3ca7530bf9a819fae99e2
Reviewed-on: https://chromium-review.googlesource.com/1548399
Commit-Ready: George Burgess <gbiv@chromium.org>
Tested-by: George Burgess <gbiv@chromium.org>
Reviewed-by: Caroline Tice <cmtice@chromium.org>
diff --git a/crosperf/machine_manager_unittest.py b/crosperf/machine_manager_unittest.py
index ee2542f..3663ab8 100755
--- a/crosperf/machine_manager_unittest.py
+++ b/crosperf/machine_manager_unittest.py
@@ -4,6 +4,7 @@
 # Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
+
 """Unittest for machine_manager."""
 
 from __future__ import print_function
@@ -250,8 +251,6 @@
 
   @mock.patch.object(command_executer.CommandExecuter, 'CrosRunCommandWOutput')
   def test_try_to_lock_machine(self, mock_cros_runcmd):
-    self.assertRaises(self.mm._TryToLockMachine, None)
-
     mock_cros_runcmd.return_value = [0, 'false_lock_checksum', '']
     self.mock_cmd_exec.CrosRunCommandWOutput = mock_cros_runcmd
     self.mm._machines = []
diff --git a/crosperf/run_tests.sh b/crosperf/run_tests.sh
index 78a2b9f..d70fc99 100755
--- a/crosperf/run_tests.sh
+++ b/crosperf/run_tests.sh
@@ -3,30 +3,4 @@
 # Copyright 2011 Google Inc. All Rights Reserved.
 # Author: raymes@google.com (Raymes Khoury)
 
-# Make sure the base toolchain-utils directory is in our PYTHONPATH before
-# trying to run this script.
-export PYTHONPATH+=":.."
-
-num_tests=0
-num_failed=0
-
-for test in $(find -name \*test.py); do
-  echo RUNNING: ${test}
-  ((num_tests++))
-  if ! ./${test} ; then
-    echo
-    echo "*** Test Failed! (${test}) ***"
-    echo
-    ((num_failed++))
-  fi
-done
-
-echo
-
-if [ ${num_failed} -eq 0 ] ; then
-  echo "ALL TESTS PASSED (${num_tests} ran)"
-  exit 0
-fi
-
-echo "${num_failed} TESTS FAILED (out of ${num_tests})"
-exit 1
+../run_tests_for.py .
diff --git a/toolchain_utils_githooks/check-style b/toolchain_utils_githooks/check-style
index fa06fa3..c844b1e 100755
--- a/toolchain_utils_githooks/check-style
+++ b/toolchain_utils_githooks/check-style
@@ -12,6 +12,13 @@
 fi
 
 mydir="$(dirname "$(readlink -m "$0")")"
+pydir="${mydir}/.."
+
+if [[ -z "${PYTHONPATH:-}" ]]; then
+  export PYTHONPATH="${pydir}"
+else
+  export PYTHONPATH="${pydir}:${PYTHONPATH}"
+fi
 
 tempfiles=()
 rm_tempfiles() {