toolchain-utils: add block list for histograms output

Histograms of some tests such as loading.desktop are very different from
their chart-json counterpart. It seems it is almost impossible to parse
these tests without case-by-case parsing. Parse chart-json output of these tests instead.

BUG=chromium:984713

TEST=local tests

Change-Id: I225567a1be9d401b5dd0c1f682184e581ac4acce
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1714125
Tested-by: Jian Cai <jiancai@google.com>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
diff --git a/crosperf/results_cache.py b/crosperf/results_cache.py
index 6124dbe..57b8090 100644
--- a/crosperf/results_cache.py
+++ b/crosperf/results_cache.py
@@ -29,6 +29,9 @@
 AUTOTEST_TARBALL = 'autotest.tbz2'
 PERF_RESULTS_FILE = 'perf-results.txt'
 CACHE_KEYS_FILE = 'cache_keys.txt'
+HISTOGRAMS_BLOCKLIST = {
+    'loading.desktop',
+}
 
 
 class Result(object):
@@ -251,7 +254,8 @@
     return out
 
   def GetResultsFile(self):
-    if self.suite == 'telemetry_Crosperf':
+    if self.suite == 'telemetry_Crosperf' and \
+        self.test_name not in HISTOGRAMS_BLOCKLIST:
       return self.FindFilesInResultsDir('-name histograms.json').splitlines()
     return self.FindFilesInResultsDir('-name results-chart.json').splitlines()
 
@@ -264,7 +268,8 @@
   def GetDataMeasurementsFiles(self):
     result = self.FindFilesInResultsDir('-name perf_measurements').splitlines()
     if not result:
-      if self.suite == 'telemetry_Crosperf':
+      if self.suite == 'telemetry_Crosperf' and \
+          self.test_name not in HISTOGRAMS_BLOCKLIST:
         result = \
             self.FindFilesInResultsDir('-name histograms.json').splitlines()
       else:
@@ -450,9 +455,15 @@
     # Note that this function doesn't know anything about whether there is a
     # cache hit or miss. It should process results agnostic of the cache hit
     # state.
-    if self.results_file and self.suite == 'telemetry_Crosperf' and \
-        'histograms.json' in self.results_file[0]:
+    # FIXME: Properly parse histograms results of the tests in the blocklist
+    if self.results_file and \
+        self.suite == 'telemetry_Crosperf' and \
+        'histograms.json' in self.results_file[0] and \
+        self.test_name not in HISTOGRAMS_BLOCKLIST:
       self.keyvals = self.ProcessHistogramsResults()
+    elif self.results_file and self.suite == 'telemetry_Crosperf' and \
+        'histograms.json' in self.results_file[0]:
+      self.keyvals = self.ProcessChartResults()
     elif self.results_file and self.suite != 'telemetry_Crosperf' and \
         'results-chart.json' in self.results_file[0]:
       self.keyvals = self.ProcessChartResults()