Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 import sys | 6 import sys |
| 7 import unittest | 7 import unittest |
| 8 import StringIO | 8 import StringIO |
| 9 | 9 |
| 10 import mock # pylint: disable=import-error | 10 import mock # pylint: disable=import-error |
| 11 | 11 |
| 12 from core import path_util | 12 from core import path_util |
| 13 from telemetry import benchmark | |
| 13 import fetch_benchmark_deps | 14 import fetch_benchmark_deps |
| 14 | 15 |
| 15 | 16 |
| 16 def NormPaths(paths): | 17 def NormPaths(paths): |
| 17 return sorted([os.path.normcase(p) for p in paths.splitlines()]) | 18 return sorted([os.path.normcase(p) for p in paths.splitlines()]) |
| 18 | 19 |
| 19 | 20 |
| 20 class FetchBenchmarkDepsUnittest(unittest.TestCase): | 21 class FetchBenchmarkDepsUnittest(unittest.TestCase): |
| 21 """The test guards fetch_benchmark_deps. | 22 """The test guards fetch_benchmark_deps. |
| 22 | 23 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 38 checksums. The expected result can be omitted if the dependencies of | 39 checksums. The expected result can be omitted if the dependencies of |
| 39 specified benchmarks are subject to changes. | 40 specified benchmarks are subject to changes. |
| 40 | 41 |
| 41 Args: | 42 Args: |
| 42 benchmark_name: benchmark name | 43 benchmark_name: benchmark name |
| 43 expected_fetched_file_paths: the expected result. | 44 expected_fetched_file_paths: the expected result. |
| 44 """ | 45 """ |
| 45 sys.argv[1] = benchmark_name | 46 sys.argv[1] = benchmark_name |
| 46 output = StringIO.StringIO() | 47 output = StringIO.StringIO() |
| 47 with mock.patch('telemetry.wpr.archive_info.WprArchiveInfo' | 48 with mock.patch('telemetry.wpr.archive_info.WprArchiveInfo' |
| 48 '.DownloadArchivesIfNeeded') as mock_download: | 49 '.DownloadArchivesIfNeeded') as mock_download: |
|
rnephew (Reviews Here)
2017/02/15 15:04:09
I am doing work to change over to a new version of
| |
| 49 with mock.patch('py_utils.cloud_storage' | 50 with mock.patch('py_utils.cloud_storage' |
| 50 '.GetFilesInDirectoryIfChanged') as mock_get: | 51 '.GetFilesInDirectoryIfChanged') as mock_get: |
| 51 mock_download.return_value = True | 52 mock_download.return_value = True |
| 52 mock_get.GetFilesInDirectoryIfChanged.return_value = True | 53 mock_get.GetFilesInDirectoryIfChanged.return_value = True |
| 53 fetch_benchmark_deps.main(output) | 54 fetch_benchmark_deps.main(output) |
| 54 for f in output.getvalue().splitlines(): | 55 for f in output.getvalue().splitlines(): |
| 55 fullpath = os.path.join(path_util.GetChromiumSrcDir(), f) | 56 fullpath = os.path.join(path_util.GetChromiumSrcDir(), f) |
| 56 sha1path = fullpath + '.sha1' | 57 sha1path = fullpath + '.sha1' |
| 57 self.assertTrue(os.path.isfile(sha1path)) | 58 self.assertTrue(os.path.isfile(sha1path)) |
| 58 if expected_fetched_file_paths: | 59 if expected_fetched_file_paths: |
| 59 self.assertEquals(expected_fetched_file_paths, | 60 self.assertEquals(expected_fetched_file_paths, |
| 60 NormPaths(output.getvalue())) | 61 NormPaths(output.getvalue())) |
| 61 | 62 |
| 63 @benchmark.Disabled('chromeos') # crbug.com/692278 | |
| 62 def testFetchWPRs(self): | 64 def testFetchWPRs(self): |
| 63 self._RunFetchBenchmarkDepsTest('smoothness.top_25_smooth') | 65 self._RunFetchBenchmarkDepsTest('smoothness.top_25_smooth') |
| 64 | 66 |
| 65 def testFetchServingDirs(self): | 67 def testFetchServingDirs(self): |
| 66 self._RunFetchBenchmarkDepsTest('media.tough_video_cases') | 68 self._RunFetchBenchmarkDepsTest('media.tough_video_cases') |
| 67 | 69 |
| 68 def testFetchOctane(self): | 70 def testFetchOctane(self): |
| 69 octane_wpr_path = os.path.join( | 71 octane_wpr_path = os.path.join( |
| 70 os.path.dirname(__file__), 'page_sets', 'data', 'octane_002.wpr') | 72 os.path.dirname(__file__), 'page_sets', 'data', 'octane_002.wpr') |
| 71 expected = os.path.relpath(octane_wpr_path, | 73 expected = os.path.relpath(octane_wpr_path, |
| 72 path_util.GetChromiumSrcDir()) | 74 path_util.GetChromiumSrcDir()) |
| 73 self._RunFetchBenchmarkDepsTest('octane', NormPaths(expected)) | 75 self._RunFetchBenchmarkDepsTest('octane', NormPaths(expected)) |
| OLD | NEW |