| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 re | 6 import re |
| 7 import shutil | 7 import shutil |
| 8 import sys | 8 import sys |
| 9 import unittest | 9 import unittest |
| 10 | 10 |
| 11 SRC = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir) | 11 SRC = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir) |
| 12 sys.path.append(os.path.join(SRC, 'third_party', 'pymock')) | 12 sys.path.append(os.path.join(SRC, 'third_party', 'pymock')) |
| 13 | 13 |
| 14 import bisect_perf_regression | 14 import bisect_perf_regression |
| 15 import bisect_results | 15 import bisect_results |
| 16 import mock | 16 import mock |
| 17 import source_control | 17 import source_control as source_control_module |
| 18 | 18 |
| 19 | 19 |
| 20 def _GetBisectPerformanceMetricsInstance(): | 20 def _GetBisectPerformanceMetricsInstance(): |
| 21 """Returns an instance of the BisectPerformanceMetrics class.""" | 21 """Returns an instance of the BisectPerformanceMetrics class.""" |
| 22 options_dict = { | 22 options_dict = { |
| 23 'debug_ignore_build': True, | 23 'debug_ignore_build': True, |
| 24 'debug_ignore_sync': True, | 24 'debug_ignore_sync': True, |
| 25 'debug_ignore_perf_test': True, | 25 'debug_ignore_perf_test': True, |
| 26 'command': 'fake_command', | 26 'command': 'fake_command', |
| 27 'metric': 'fake/metric', | 27 'metric': 'fake/metric', |
| 28 'good_revision': 280000, | 28 'good_revision': 280000, |
| 29 'bad_revision': 280005, | 29 'bad_revision': 280005, |
| 30 } | 30 } |
| 31 bisect_options = bisect_perf_regression.BisectOptions.FromDict(options_dict) | 31 bisect_options = bisect_perf_regression.BisectOptions.FromDict(options_dict) |
| 32 source_control = source_control_module.DetermineAndCreateSourceControl( |
| 33 bisect_options) |
| 32 bisect_instance = bisect_perf_regression.BisectPerformanceMetrics( | 34 bisect_instance = bisect_perf_regression.BisectPerformanceMetrics( |
| 33 bisect_options) | 35 source_control, bisect_options) |
| 34 return bisect_instance | 36 return bisect_instance |
| 35 | 37 |
| 36 | 38 |
| 37 class BisectPerfRegressionTest(unittest.TestCase): | 39 class BisectPerfRegressionTest(unittest.TestCase): |
| 38 """Test case for other functions and classes in bisect-perf-regression.py.""" | 40 """Test case for other functions and classes in bisect-perf-regression.py.""" |
| 39 | 41 |
| 40 def setUp(self): | 42 def setUp(self): |
| 41 self.cwd = os.getcwd() | 43 self.cwd = os.getcwd() |
| 42 os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__), | 44 os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__), |
| 43 os.path.pardir, os.path.pardir))) | 45 os.path.pardir, os.path.pardir))) |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 command that works; before some revisions, the browser name that Telemetry | 200 command that works; before some revisions, the browser name that Telemetry |
| 199 expects is different in some cases, but we want it to work anyway. | 201 expects is different in some cases, but we want it to work anyway. |
| 200 | 202 |
| 201 Specifically, only for android: | 203 Specifically, only for android: |
| 202 After r276628, only android-chrome-shell works. | 204 After r276628, only android-chrome-shell works. |
| 203 Prior to r274857, only android-chromium-testshell works. | 205 Prior to r274857, only android-chromium-testshell works. |
| 204 In the range [274857, 276628], both work. | 206 In the range [274857, 276628], both work. |
| 205 """ | 207 """ |
| 206 bisect_options = bisect_perf_regression.BisectOptions() | 208 bisect_options = bisect_perf_regression.BisectOptions() |
| 207 bisect_options.output_buildbot_annotations = None | 209 bisect_options.output_buildbot_annotations = None |
| 210 source_control = source_control_module.DetermineAndCreateSourceControl( |
| 211 bisect_options) |
| 208 bisect_instance = bisect_perf_regression.BisectPerformanceMetrics( | 212 bisect_instance = bisect_perf_regression.BisectPerformanceMetrics( |
| 209 bisect_options) | 213 source_control, bisect_options) |
| 210 bisect_instance.opts.target_platform = target_platform | 214 bisect_instance.opts.target_platform = target_platform |
| 211 git_revision = source_control.ResolveToRevision( | 215 git_revision = bisect_instance.source_control.ResolveToRevision( |
| 212 revision, 'chromium', bisect_perf_regression.DEPOT_DEPS_NAME, 100) | 216 revision, 'chromium', bisect_perf_regression.DEPOT_DEPS_NAME, 100) |
| 213 depot = 'chromium' | 217 depot = 'chromium' |
| 214 command = bisect_instance.GetCompatibleCommand( | 218 command = bisect_instance.GetCompatibleCommand( |
| 215 original_command, git_revision, depot) | 219 original_command, git_revision, depot) |
| 216 self.assertEqual(expected_command, command) | 220 self.assertEqual(expected_command, command) |
| 217 | 221 |
| 218 def testGetCompatibleCommand_ChangeToTestShell(self): | 222 def testGetCompatibleCommand_ChangeToTestShell(self): |
| 219 # For revisions <= r274857, only android-chromium-testshell is used. | 223 # For revisions <= r274857, only android-chromium-testshell is used. |
| 220 self._AssertCompatibleCommand( | 224 self._AssertCompatibleCommand( |
| 221 'tools/perf/run_benchmark -v --browser=android-chromium-testshell foo', | 225 'tools/perf/run_benchmark -v --browser=android-chromium-testshell foo', |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 bisect_instance = _GetBisectPerformanceMetricsInstance() | 268 bisect_instance = _GetBisectPerformanceMetricsInstance() |
| 265 results = bisect_instance.Run(bisect_instance.opts.command, | 269 results = bisect_instance.Run(bisect_instance.opts.command, |
| 266 bisect_instance.opts.bad_revision, | 270 bisect_instance.opts.bad_revision, |
| 267 bisect_instance.opts.good_revision, | 271 bisect_instance.opts.good_revision, |
| 268 bisect_instance.opts.metric) | 272 bisect_instance.opts.metric) |
| 269 bisect_instance.FormatAndPrintResults(results) | 273 bisect_instance.FormatAndPrintResults(results) |
| 270 finally: | 274 finally: |
| 271 shutil.rmtree = old_rmtree | 275 shutil.rmtree = old_rmtree |
| 272 | 276 |
| 273 def testGetCommitPosition(self): | 277 def testGetCommitPosition(self): |
| 278 bisect_instance = _GetBisectPerformanceMetricsInstance() |
| 274 cp_git_rev = '7017a81991de983e12ab50dfc071c70e06979531' | 279 cp_git_rev = '7017a81991de983e12ab50dfc071c70e06979531' |
| 275 self.assertEqual(291765, source_control.GetCommitPosition(cp_git_rev)) | 280 self.assertEqual( |
| 281 291765, bisect_instance.source_control.GetCommitPosition(cp_git_rev)) |
| 276 | 282 |
| 277 svn_git_rev = 'e6db23a037cad47299a94b155b95eebd1ee61a58' | 283 svn_git_rev = 'e6db23a037cad47299a94b155b95eebd1ee61a58' |
| 278 self.assertEqual(291467, source_control.GetCommitPosition(svn_git_rev)) | 284 self.assertEqual( |
| 285 291467, bisect_instance.source_control.GetCommitPosition(svn_git_rev)) |
| 279 | 286 |
| 280 def testGetCommitPositionForV8(self): | 287 def testGetCommitPositionForV8(self): |
| 281 bisect_instance = _GetBisectPerformanceMetricsInstance() | 288 bisect_instance = _GetBisectPerformanceMetricsInstance() |
| 282 v8_rev = '21d700eedcdd6570eff22ece724b63a5eefe78cb' | 289 v8_rev = '21d700eedcdd6570eff22ece724b63a5eefe78cb' |
| 283 depot_path = os.path.join(bisect_instance.src_cwd, 'v8') | 290 depot_path = os.path.join(bisect_instance.src_cwd, 'v8') |
| 284 self.assertEqual( | 291 self.assertEqual( |
| 285 23634, source_control.GetCommitPosition(v8_rev, depot_path)) | 292 23634, |
| 293 bisect_instance.source_control.GetCommitPosition(v8_rev, depot_path)) |
| 286 | 294 |
| 287 def testGetCommitPositionForWebKit(self): | 295 def testGetCommitPositionForWebKit(self): |
| 288 bisect_instance = _GetBisectPerformanceMetricsInstance() | 296 bisect_instance = _GetBisectPerformanceMetricsInstance() |
| 289 wk_rev = 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61' | 297 wk_rev = 'a94d028e0f2c77f159b3dac95eb90c3b4cf48c61' |
| 290 depot_path = os.path.join(bisect_instance.src_cwd, 'third_party', 'WebKit') | 298 depot_path = os.path.join(bisect_instance.src_cwd, 'third_party', 'WebKit') |
| 291 self.assertEqual( | 299 self.assertEqual( |
| 292 181660, source_control.GetCommitPosition(wk_rev, depot_path)) | 300 181660, |
| 301 bisect_instance.source_control.GetCommitPosition(wk_rev, depot_path)) |
| 293 | 302 |
| 294 def testUpdateDepsContent(self): | 303 def testUpdateDepsContent(self): |
| 295 bisect_instance = _GetBisectPerformanceMetricsInstance() | 304 bisect_instance = _GetBisectPerformanceMetricsInstance() |
| 296 deps_file = 'DEPS' | 305 deps_file = 'DEPS' |
| 297 # We are intentionally reading DEPS file contents instead of string literal | 306 # We are intentionally reading DEPS file contents instead of string literal |
| 298 # with few lines from DEPS because to check if the format we are expecting | 307 # with few lines from DEPS because to check if the format we are expecting |
| 299 # to search is not changed in DEPS content. | 308 # to search is not changed in DEPS content. |
| 300 # TODO (prasadv): Add a separate test to validate the DEPS contents with the | 309 # TODO (prasadv): Add a separate test to validate the DEPS contents with the |
| 301 # format that bisect script expects. | 310 # format that bisect script expects. |
| 302 deps_contents = bisect_perf_regression.ReadStringFromFile(deps_file) | 311 deps_contents = bisect_perf_regression.ReadStringFromFile(deps_file) |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 '--diff=%s' % patch_content | 500 '--diff=%s' % patch_content |
| 492 ], (None, 0)) | 501 ], (None, 0)) |
| 493 ] | 502 ] |
| 494 self._SetupRunGitMock(try_cmd) | 503 self._SetupRunGitMock(try_cmd) |
| 495 bisect_perf_regression._BuilderTryjob( | 504 bisect_perf_regression._BuilderTryjob( |
| 496 git_revision, bot_name, bisect_job_name, patch) | 505 git_revision, bot_name, bisect_job_name, patch) |
| 497 | 506 |
| 498 | 507 |
| 499 if __name__ == '__main__': | 508 if __name__ == '__main__': |
| 500 unittest.main() | 509 unittest.main() |
| OLD | NEW |