Teach cbuildbot to retry the VMTest stage.

BUG=chromium:309041, chromium:254166
TEST=Add flake, verify it retries.
TEST=Run all unit tests.

Change-Id: I49c6ec5cb8255c1d664100a6562959cf1e9aad97
Reviewed-on: https://chromium-review.googlesource.com/173751
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: David James <davidjames@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 63f04bf..2cbe2af 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -403,8 +403,9 @@
       # results.) In this case, attribute the exception to any stages that
       # didn't report back correctly (if any).
       for stage in stage_objs:
-        if not results_lib.Results.StageHasResults(stage.name):
-          results_lib.Results.Record(stage.name, ex, str(ex))
+        for name in stage.GetStageNames():
+          if not results_lib.Results.StageHasResults(name):
+            results_lib.Results.Record(name, ex, str(ex))
 
       raise
 
@@ -430,11 +431,13 @@
     stage_list = []
     if self.options.chrome_sdk and self.build_config['chrome_sdk']:
       stage_list.append([stages.ChromeSDKStage, board, archive_stage])
-    stage_list += [[stages.VMTestStage, board, archive_stage],
-                   [stages.SignerTestStage, board, archive_stage],
-                   [stages.UnitTestStage, board],
-                   [stages.UploadPrebuiltsStage, board, archive_stage],
-                   [stages.DevInstallerPrebuiltsStage, board, archive_stage]]
+    stage_list += [
+        [stages.RetryStage, 1, stages.VMTestStage, board, archive_stage],
+        [stages.SignerTestStage, board, archive_stage],
+        [stages.UnitTestStage, board],
+        [stages.UploadPrebuiltsStage, board, archive_stage],
+        [stages.DevInstallerPrebuiltsStage, board, archive_stage]
+    ]
 
     # We can not run hw tests without archiving the payloads.
     if self.options.archive: