aboutsummaryrefslogtreecommitdiff
path: root/crosperf/results_cache_unittest.py
diff options
context:
space:
mode:
authorZhizhou Yang <zhizhouy@google.com>2019-04-10 14:04:05 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-18 19:52:03 -0700
commitced8957f7a858d5cca66352522e916705f004944 (patch)
tree7777bb88cd76c4d6c97442b8cbe91c39754042cd /crosperf/results_cache_unittest.py
parent5ed02e0990d636f4220ac3259cfe541a296275b6 (diff)
downloadtoolchain-utils-ced8957f7a858d5cca66352522e916705f004944.tar.gz
crosperf: generate perf report with correct debug files
This patch fixes the issue in chromium:946588. This patch makes perf report no longer use hard code debug directories. There are several different situations: 1) When running tests on a downloaded image, it will download debug.tgz from gs, extract it to debug_files in /tmp. Options --symfs and --vmlinux will depend on this directory, and throw a warning to user that --kallsyms cannot be applied. 2) If running with downloaded image and debug.tgz could not work, then we will try to use local build, but give user a warning that it may not match real symbols well. 3) When running tests with local build, try to find debug info from /build/$board directory. Thus, this patch added a new field in label, called 'debug_path', if this is manually set in experiment file, then crosperf will directly use the location. Downloading of debug.tgz will only happen when perf_args is set in global settings. TEST=Passed all unit tests, tested with eve and sand. BUG=chromium:946588 Change-Id: I7f35d1216d912c8526d5501748f951face1273aa Reviewed-on: https://chromium-review.googlesource.com/1561780 Commit-Ready: Zhizhou Yang <zhizhouy@google.com> Tested-by: Zhizhou Yang <zhizhouy@google.com> Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Diffstat (limited to 'crosperf/results_cache_unittest.py')
-rwxr-xr-xcrosperf/results_cache_unittest.py48
1 files changed, 34 insertions, 14 deletions
diff --git a/crosperf/results_cache_unittest.py b/crosperf/results_cache_unittest.py
index fcf2872d..c201c9d8 100755
--- a/crosperf/results_cache_unittest.py
+++ b/crosperf/results_cache_unittest.py
@@ -4,6 +4,7 @@
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+
"""Module of result cache unittest."""
from __future__ import print_function
@@ -193,9 +194,9 @@ class ResultTest(unittest.TestCase):
self.callGatherPerfResults = False
self.mock_logger = mock.Mock(spec=logger.Logger)
self.mock_cmd_exec = mock.Mock(spec=command_executer.CommandExecuter)
- self.mock_label = MockLabel('mock_label', 'chromeos_image', 'autotest_dir',
- '/tmp', 'lumpy', 'remote', 'image_args',
- 'cache_dir', 'average', 'gcc', None)
+ self.mock_label = MockLabel(
+ 'mock_label', 'chromeos_image', 'autotest_dir', 'debug_dir', '/tmp',
+ 'lumpy', 'remote', 'image_args', 'cache_dir', 'average', 'gcc', None)
def testCreateFromRun(self):
result = MockResult.CreateFromRun(logger.GetLogger(), 'average',
@@ -559,14 +560,33 @@ class ResultTest(unittest.TestCase):
self.result.board = 'lumpy'
mock_getpath.return_value = fake_file
self.result.ce.ChrootRunCommand = mock_chrootruncmd
+ mock_chrootruncmd.return_value = 0
+ # Debug path not found
+ self.result.label.debug_path = ''
+ tmp = self.result.GeneratePerfReportFiles()
+ self.assertEqual(tmp, ['/tmp/chroot%s' % fake_file])
+ self.assertEqual(mock_chrootruncmd.call_args_list[0][0],
+ ('/tmp', ('/usr/sbin/perf report -n '
+ '-i %s --stdio > %s') % (fake_file, fake_file)))
+
+ @mock.patch.object(misc, 'GetInsideChrootPath')
+ @mock.patch.object(command_executer.CommandExecuter, 'ChrootRunCommand')
+ def test_generate_perf_report_files_debug(self, mock_chrootruncmd,
+ mock_getpath):
+ fake_file = '/usr/chromeos/chroot/tmp/results/fake_file'
+ self.result.perf_data_files = ['/tmp/results/perf.data']
+ self.result.board = 'lumpy'
+ mock_getpath.return_value = fake_file
+ self.result.ce.ChrootRunCommand = mock_chrootruncmd
+ mock_chrootruncmd.return_value = 0
+ # Debug path found
+ self.result.label.debug_path = '/tmp/debug'
tmp = self.result.GeneratePerfReportFiles()
self.assertEqual(tmp, ['/tmp/chroot%s' % fake_file])
self.assertEqual(mock_chrootruncmd.call_args_list[0][0],
- ('/tmp',
- ('/usr/sbin/perf report -n --symfs /build/lumpy '
- '--vmlinux /build/lumpy/usr/lib/debug/boot/vmlinux '
- '--kallsyms /build/lumpy/boot/System.map-* -i '
- '%s --stdio > %s') % (fake_file, fake_file)))
+ ('/tmp', ('/usr/sbin/perf report -n --symfs /tmp/debug '
+ '--vmlinux /tmp/debug/boot/vmlinux '
+ '-i %s --stdio > %s') % (fake_file, fake_file)))
@mock.patch.object(misc, 'GetOutsideChrootPath')
def test_populate_from_run(self, mock_getpath):
@@ -975,9 +995,9 @@ class TelemetryResultTest(unittest.TestCase):
self.result = None
self.mock_logger = mock.Mock(spec=logger.Logger)
self.mock_cmd_exec = mock.Mock(spec=command_executer.CommandExecuter)
- self.mock_label = MockLabel('mock_label', 'chromeos_image', 'autotest_dir',
- '/tmp', 'lumpy', 'remote', 'image_args',
- 'cache_dir', 'average', 'gcc', None)
+ self.mock_label = MockLabel(
+ 'mock_label', 'chromeos_image', 'autotest_dir', 'debug_dir', '/tmp',
+ 'lumpy', 'remote', 'image_args', 'cache_dir', 'average', 'gcc', None)
self.mock_machine = machine_manager.MockCrosMachine(
'falco.cros', '/tmp/chromeos', 'average')
@@ -1018,9 +1038,9 @@ class ResultsCacheTest(unittest.TestCase):
super(ResultsCacheTest, self).__init__(*args, **kwargs)
self.fakeCacheReturnResult = None
self.mock_logger = mock.Mock(spec=logger.Logger)
- self.mock_label = MockLabel('mock_label', 'chromeos_image', 'autotest_dir',
- '/tmp', 'lumpy', 'remote', 'image_args',
- 'cache_dir', 'average', 'gcc', None)
+ self.mock_label = MockLabel(
+ 'mock_label', 'chromeos_image', 'autotest_dir', 'debug_dir', '/tmp',
+ 'lumpy', 'remote', 'image_args', 'cache_dir', 'average', 'gcc', None)
def setUp(self):
self.results_cache = ResultsCache()