[crosperf] Fix status reporting for multiple iters inside a single run.

If a single benchmark run contains multiple iterations (like
BootPerfServer), then only the first internal iteration was getting the
correct pass/fail status, so even though everything passed the report
title would claim 1 pass and 9 fails (for 10 internal iterations).
This fixes that.

BUG=chromium:426960
TEST=Ran BootPerfServer with change. Now shows correct number of
passes/fails for the iterations.

Change-Id: I9638b39c94692fd754698e64d89cb22c10e9d479
Reviewed-on: https://chromium-review.googlesource.com/470547
Commit-Ready: Caroline Tice <cmtice@chromium.org>
Tested-by: Caroline Tice <cmtice@chromium.org>
Reviewed-by: George Burgess <gbiv@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
diff --git a/crosperf/results_organizer.py b/crosperf/results_organizer.py
index 6297202..b764185 100644
--- a/crosperf/results_organizer.py
+++ b/crosperf/results_organizer.py
@@ -47,6 +47,17 @@
   return [func() for _ in xrange(times)]
 
 
+def _DictWithReturnValues(retval, pass_fail):
+  """Create a new dictionary pre-populated with success/fail values."""
+  new_dict = {}
+  # Note: 0 is a valid retval; test to make sure it's not None.
+  if retval is not None:
+    new_dict['retval'] = retval
+  if pass_fail:
+    new_dict[''] = pass_fail
+  return new_dict
+
+
 def _GetNonDupLabel(max_dup, runs):
   """Create new list for the runs of the same label.
 
@@ -61,8 +72,12 @@
   """
   new_runs = []
   for run in runs:
+    run_retval = run.get('retval', None)
+    run_pass_fail = run.get('', None)
     new_run = {}
-    added_runs = _Repeat(dict, max_dup)
+    # pylint: disable=cell-var-from-loop
+    added_runs = _Repeat(
+        lambda: _DictWithReturnValues(run_retval, run_pass_fail), max_dup)
     for key, value in run.iteritems():
       match = _DUP_KEY_REGEX.match(key)
       if not match: