autotest: let after-test hooks see exceptions.

The "after iteration hooks" are the first code to run after run_once(),
in both the success and failure cases. This change gives the hooks a
chance to check for a pending exception and log extra information if
needed.

BUG=None
TEST=Verify server/client-side test exceptions are visible in hooks.

Change-Id: I2d8248d329130d515a8e0d8dfd8c6093a253eed3
Previous-Reviewed-on: https://chromium-review.googlesource.com/278025
(cherry picked from commit 287ea4e39b3468c56bee816890dfee209fa3220f)
Reviewed-on: https://chromium-review.googlesource.com/285620
Reviewed-by: Ilja Friedel <ihf@chromium.org>
Commit-Queue: Christopher Grant <cjgrant@chromium.org>
Tested-by: Christopher Grant <cjgrant@chromium.org>
diff --git a/client/common_lib/test.py b/client/common_lib/test.py
index 9b2d536..1d46b83 100644
--- a/client/common_lib/test.py
+++ b/client/common_lib/test.py
@@ -315,6 +315,9 @@
 
             self.postprocess_iteration()
             self.analyze_perf_constraints(constraints)
+        # Catch and re-raise to let after_iteration_hooks see the exception.
+        except:
+            raise
         finally:
             for hook in reversed(self.after_iteration_hooks):
                 hook(self)
diff --git a/server/autoserv b/server/autoserv
index 40c9452..0cf72fb 100755
--- a/server/autoserv
+++ b/server/autoserv
@@ -305,7 +305,7 @@
         faulthandler.register(signal.SIGTERM, all_threads=True, chain=True)
         logging.debug('faulthandler registered on SIGTERM.')
     except ImportError:
-        pass
+        sys.exc_clear()
 
     # Ignore SIGTTOU's generated by output from forked children.
     signal.signal(signal.SIGTTOU, signal.SIG_IGN)