| 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 base64 | 5 import base64 |
| 6 import collections | 6 import collections |
| 7 import json | 7 import json |
| 8 | 8 |
| 9 | 9 |
| 10 def perform_bisect(api, **flags): # pragma: no cover | 10 def perform_bisect(api, **flags): # pragma: no cover |
| 11 try: | 11 bisect_config = api.m.properties.get('bisect_config') |
| 12 bisect_config = api.m.properties.get('bisect_config') | 12 assert isinstance(bisect_config, collections.Mapping) |
| 13 assert isinstance(bisect_config, collections.Mapping) | 13 bisector = api.create_bisector(bisect_config, **flags) |
| 14 bisector = api.create_bisector(bisect_config, **flags) | 14 with api.m.step.nest('Gathering reference values'): |
| 15 with api.m.step.nest('Gathering reference values'): | 15 _gather_reference_range(api, bisector) |
| 16 _gather_reference_range(api, bisector) | 16 if (not bisector.failed and bisector.check_improvement_direction() and |
| 17 if (not bisector.failed and bisector.check_improvement_direction() and | 17 bisector.check_initial_confidence()): |
| 18 bisector.check_initial_confidence()): | 18 if bisector.check_reach_adjacent_revision(bisector.good_rev): |
| 19 if bisector.check_reach_adjacent_revision(bisector.good_rev): | 19 # Only show this step if bisect has reached adjacent revisions. |
| 20 # Only show this step if bisect has reached adjacent revisions. | 20 with api.m.step.nest(str('Check bisect finished on revision ' + |
| 21 with api.m.step.nest(str('Check bisect finished on revision ' + | 21 bisector.good_rev.revision_string())): |
| 22 bisector.good_rev.revision_string())): | 22 if bisector.check_bisect_finished(bisector.good_rev): |
| 23 if bisector.check_bisect_finished(bisector.good_rev): | 23 bisector.bisect_over = True |
| 24 bisector.bisect_over = True | 24 if not bisector.bisect_over: |
| 25 if not bisector.bisect_over: | 25 _bisect_main_loop(bisector) |
| 26 _bisect_main_loop(bisector) | 26 else: |
| 27 else: | 27 bisector.bisect_over = True |
| 28 bisector.bisect_over = True | 28 bisector.print_result_debug_info() |
| 29 bisector.print_result_debug_info() | 29 bisector.post_result(halt_on_failure=True) |
| 30 bisector.post_result(halt_on_failure=True) | |
| 31 except api.m.step.StepFailure: | |
| 32 if api.m.chromium.c.TARGET_PLATFORM == 'android': | |
| 33 api.m.chromium_android.device_status_check() | |
| 34 connected_devices = api.m.chromium_android.devices() | |
| 35 tested_devices = api.m.bisect_tester.devices_tested | |
| 36 available_devices = [device for device in connected_devices | |
| 37 if device not in tested_devices] | |
| 38 if available_devices: | |
| 39 serial_number = available_devices[0] | |
| 40 api.m.bisect_tester.device_to_test = serial_number | |
| 41 api.m.bisect_tester.devices_tested.append(serial_number) | |
| 42 perform_bisect(api,**flags) | |
| 43 else: | |
| 44 raise | |
| 45 else: | |
| 46 raise | |
| 47 | 30 |
| 48 | 31 |
| 49 def _gather_reference_range(api, bisector): # pragma: no cover | 32 def _gather_reference_range(api, bisector): # pragma: no cover |
| 50 bisector.good_rev.start_job() | 33 bisector.good_rev.start_job() |
| 51 bisector.bad_rev.start_job() | 34 bisector.bad_rev.start_job() |
| 52 bisector.wait_for_all([bisector.good_rev, bisector.bad_rev]) | 35 bisector.wait_for_all([bisector.good_rev, bisector.bad_rev]) |
| 53 if bisector.good_rev.failed: | 36 if bisector.good_rev.failed: |
| 54 bisector.surface_result('REF_RANGE_FAIL') | 37 bisector.surface_result('REF_RANGE_FAIL') |
| 55 api.m.halt('Testing the "good" revision failed') | 38 api.m.halt('Testing the "good" revision failed') |
| 56 bisector.failed = True | 39 bisector.failed = True |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 revision_to_check.start_job() | 64 revision_to_check.start_job() |
| 82 bisector.wait_for(revision_to_check) | 65 bisector.wait_for(revision_to_check) |
| 83 | 66 |
| 84 if bisector.check_reach_adjacent_revision(revision_to_check): | 67 if bisector.check_reach_adjacent_revision(revision_to_check): |
| 85 # Only show this step if bisect has reached adjacent revisions. | 68 # Only show this step if bisect has reached adjacent revisions. |
| 86 with bisector.api.m.step.nest( | 69 with bisector.api.m.step.nest( |
| 87 str('Check bisect finished on revision ' + | 70 str('Check bisect finished on revision ' + |
| 88 revision_to_check.revision_string())): | 71 revision_to_check.revision_string())): |
| 89 if bisector.check_bisect_finished(revision_to_check): | 72 if bisector.check_bisect_finished(revision_to_check): |
| 90 bisector.bisect_over = True | 73 bisector.bisect_over = True |
| OLD | NEW |