autotest: Make poll_for_condition log the error before raising an exception

When a test fails or errors out (via raising one of the derived TestError or
TestFail exceptions), autotest displays the <test name>.ERROR log file to help
debug the reason for the test failure.

Many of our test failures are caused due to timeouts while waiting for a
condition using poll_for_condition and these do not get logged to the ERROR log
file.

This CL adds a logging.error call with the error description to
poll_for_condition before the exception is raised to signify test failure. Also
added logging to a couple of other places where some custom TestError exceptions
are raised.

BUG=none
TEST=Caused a deliberate timeout failure on login_CryptohomeMounted by reducing the timeout
     to a very small value. The test ERROR file now contained the timeout error message.

Change-Id: I4915e2dd3eaf72de562c0ccf53429b8ed8f6bf04
Reviewed-on: http://gerrit.chromium.org/gerrit/6115
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Gaurav Shah <gauravsh@chromium.org>
diff --git a/client/bin/site_utils.py b/client/bin/site_utils.py
index 100fe86..0935c2a 100644
--- a/client/bin/site_utils.py
+++ b/client/bin/site_utils.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+# Copyright (c) 2011 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.
 
@@ -62,12 +62,14 @@
             return
         if time.time() + sleep_interval - start_time > timeout:
             if exception:
+                logging.error(exception)
                 raise exception
 
             if desc:
                 desc = 'Timed out waiting for condition: %s' % desc
             else:
                 desc = 'Timed out waiting for unnamed condition'
+            logging.error(desc)
             raise TimeoutError, desc
 
         time.sleep(sleep_interval)