Add a VM test timeout

When VM test hangs, it would eventually get killed with no output or
archived artifacts for debugging. This CL wraps VM test with a
timeout, so that test artifacts can be archived by cbuildbot in this
case.

BUG=chromium:370224
TEST=`buildbot/run_tests` passes

Change-Id: Ib55ab061c14e6325b961261797c41530c6695400
Reviewed-on: https://chromium-review.googlesource.com/198288
Reviewed-by: David James <davidjames@chromium.org>
Commit-Queue: Yu-Ju Hong <yjhong@chromium.org>
Tested-by: Yu-Ju Hong <yjhong@chromium.org>
diff --git a/buildbot/cbuildbot_stages.py b/buildbot/cbuildbot_stages.py
index 5676857..6359049 100644
--- a/buildbot/cbuildbot_stages.py
+++ b/buildbot/cbuildbot_stages.py
@@ -2794,6 +2794,8 @@
   option_name = 'tests'
   config_name = 'vm_tests'
 
+  VM_TEST_TIMEOUT = 60 * 60
+
   def _PrintFailedTests(self, results_path, test_basename):
     """Print links to failed tests.
 
@@ -2894,7 +2896,8 @@
     try:
       for test_type in self._run.config.vm_tests:
         cros_build_lib.Info('Running VM test %s.', test_type)
-        self._RunTest(test_type, test_results_dir)
+        with timeout_util.Timeout(self.VM_TEST_TIMEOUT):
+          self._RunTest(test_type, test_results_dir)
 
     except Exception:
       cros_build_lib.Error(_VM_TEST_ERROR_MSG %