aboutsummaryrefslogtreecommitdiff
path: root/crosperf/download_images_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/download_images_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/download_images_unittest.py')
-rwxr-xr-xcrosperf/download_images_unittest.py48
1 files changed, 37 insertions, 11 deletions
diff --git a/crosperf/download_images_unittest.py b/crosperf/download_images_unittest.py
index 349a2dbb..8d9b9e72 100755
--- a/crosperf/download_images_unittest.py
+++ b/crosperf/download_images_unittest.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python2
-#
-# Copyright 2014 Google Inc. All Rights Reserved
+#-*- coding: utf-8 -*-
+# Copyright 2019 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.
+
"""Download image unittest."""
from __future__ import print_function
@@ -27,6 +30,7 @@ class ImageDownloaderTestcast(unittest.TestCase):
self.called_uncompress_image = False
self.called_get_build_id = False
self.called_download_autotest_files = False
+ self.called_download_debug_file = False
@mock.patch.object(os, 'makedirs')
@mock.patch.object(os.path, 'exists')
@@ -126,8 +130,8 @@ class ImageDownloaderTestcast(unittest.TestCase):
# 2nd arg must be exception handler
except_handler_string = 'RunCommandExceptionHandler.HandleException'
self.assertTrue(
- except_handler_string in repr(
- mock_cmd_exec.RunCommand.call_args_list[0][1]))
+ except_handler_string in repr(mock_cmd_exec.RunCommand.call_args_list[0]
+ [1]))
# Call 2, should have 2 arguments
self.assertEqual(len(mock_cmd_exec.RunCommand.call_args_list[1]), 2)
@@ -160,13 +164,17 @@ class ImageDownloaderTestcast(unittest.TestCase):
test_chroot = '/usr/local/home/chromeos'
test_build_id = 'remote/lumpy/latest-dev'
test_empty_autotest_path = ''
+ test_empty_debug_path = ''
test_autotest_path = '/tmp/autotest'
+ test_debug_path = '/tmp/debug'
+ perf_args = '-a'
# Set values to test/check.
self.called_download_image = False
self.called_uncompress_image = False
self.called_get_build_id = False
self.called_download_autotest_files = False
+ self.called_download_debug_file = False
# Define fake stub functions for Run to call
def FakeGetBuildID(unused_root, unused_xbuddy_label):
@@ -197,6 +205,12 @@ class ImageDownloaderTestcast(unittest.TestCase):
self.called_download_autotest_files = True
return 'autotest'
+ def FakeDownloadDebugFile(root, build_id):
+ if root or build_id:
+ pass
+ self.called_download_debug_file = True
+ return 'debug'
+
# Initialize downloader
downloader = download_images.ImageDownloader(logger_to_use=MOCK_LOGGER)
@@ -205,46 +219,58 @@ class ImageDownloaderTestcast(unittest.TestCase):
downloader.UncompressImage = FakeUncompressImage
downloader.DownloadImage = GoodDownloadImage
downloader.DownloadAutotestFiles = FakeDownloadAutotestFiles
+ downloader.DownloadDebugFile = FakeDownloadDebugFile
# Call Run.
- image_path, autotest_path = downloader.Run(test_chroot, test_build_id,
- test_empty_autotest_path)
+ image_path, autotest_path, debug_path = downloader.Run(
+ test_chroot, test_build_id, test_empty_autotest_path,
+ test_empty_debug_path, perf_args)
# Make sure it called both _DownloadImage and _UncompressImage
self.assertTrue(self.called_download_image)
self.assertTrue(self.called_uncompress_image)
# Make sure it called DownloadAutotestFiles
self.assertTrue(self.called_download_autotest_files)
- # Make sure it returned an image and autotest path returned from this call
+ # Make sure it called DownloadDebugFile
+ self.assertTrue(self.called_download_debug_file)
+ # Make sure it returned an image and autotest path returned from this call
self.assertTrue(image_path == 'chromiumos_test_image.bin')
self.assertTrue(autotest_path == 'autotest')
+ self.assertTrue(debug_path == 'debug')
- # Call Run with a non-empty autotest path
+ # Call Run with a non-empty autotest and debug path
self.called_download_autotest_files = False
+ self.called_download_debug_file = False
- image_path, autotest_path = downloader.Run(test_chroot, test_build_id,
- test_autotest_path)
+ image_path, autotest_path, debug_path = downloader.Run(
+ test_chroot, test_build_id, test_autotest_path, test_debug_path,
+ perf_args)
# Verify that downloadAutotestFiles was not called
self.assertFalse(self.called_download_autotest_files)
# Make sure it returned the specified autotest path returned from this call
self.assertTrue(autotest_path == test_autotest_path)
+ # Make sure it returned the specified debug path returned from this call
+ self.assertTrue(debug_path == test_debug_path)
# Reset values; Now use fake stub that simulates DownloadImage failing.
self.called_download_image = False
self.called_uncompress_image = False
self.called_download_autotest_files = False
+ self.called_download_debug_file = False
downloader.DownloadImage = BadDownloadImage
# Call Run again.
self.assertRaises(download_images.MissingImage, downloader.Run, test_chroot,
- test_autotest_path, test_build_id)
+ test_autotest_path, test_debug_path, test_build_id,
+ perf_args)
# Verify that UncompressImage and downloadAutotestFiles were not called,
# since _DownloadImage "failed"
self.assertTrue(self.called_download_image)
self.assertFalse(self.called_uncompress_image)
self.assertFalse(self.called_download_autotest_files)
+ self.assertFalse(self.called_download_debug_file)
if __name__ == '__main__':