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 from slave import recipe_api | 5 from slave import recipe_api |
6 | 6 |
7 | 7 |
8 class AmpApi(recipe_api.RecipeApi): | 8 class AmpApi(recipe_api.RecipeApi): |
9 | 9 |
10 def __init__(self, *args, **kwargs): | 10 def __init__(self, *args, **kwargs): |
11 super(AmpApi, self).__init__(*args, **kwargs) | 11 super(AmpApi, self).__init__(*args, **kwargs) |
12 self._trigger_file_dir = None | 12 self._trigger_file_dir = None |
13 self._base_results_dir = None | 13 self._base_results_dir = None |
14 | 14 |
| 15 def setup(self): |
| 16 """Sets up necessary configs.""" |
| 17 self.m.chromium_android.set_config('base_config') |
| 18 |
15 @recipe_api.non_step | 19 @recipe_api.non_step |
16 def _get_trigger_dir(self): | 20 def _get_trigger_dir(self): |
17 if not self._trigger_file_dir: | 21 if not self._trigger_file_dir: |
18 self._trigger_file_dir = self.m.path.mkdtemp('amp_trigger') | 22 self._trigger_file_dir = self.m.path.mkdtemp('amp_trigger') |
19 return self._trigger_file_dir | 23 return self._trigger_file_dir |
20 | 24 |
21 @recipe_api.non_step | 25 @recipe_api.non_step |
22 def _get_trigger_file_for_suite(self, suite): | 26 def _get_trigger_file_for_suite(self, suite): |
23 return self._get_trigger_dir().join('%s.json' % suite) | 27 return self._get_trigger_dir().join('%s.json' % suite) |
24 | 28 |
(...skipping 26 matching lines...) Expand all Loading... |
51 | 55 |
52 step_test_data = lambda: self.m.json.test_api.output({ | 56 step_test_data = lambda: self.m.json.test_api.output({ |
53 'env': { | 57 'env': { |
54 'device': { | 58 'device': { |
55 'brand': 'Foo', | 59 'brand': 'Foo', |
56 'name': 'Fone', | 60 'name': 'Fone', |
57 'os_version': '1.2.3', | 61 'os_version': '1.2.3', |
58 }, | 62 }, |
59 }, | 63 }, |
60 }) | 64 }) |
61 step_result = self.m.python( | 65 step_result = self.m.chromium_android.test_runner( |
62 '[trigger] %s' % suite, | 66 '[trigger] %s' % suite, |
63 self.m.path['checkout'].join('build', 'android', 'test_runner.py'), | |
64 args=args, | 67 args=args, |
65 step_test_data=step_test_data) | 68 step_test_data=step_test_data) |
66 trigger_data = step_result.json.output | 69 trigger_data = step_result.json.output |
67 try: | 70 try: |
68 device_data = trigger_data['env']['device'] | 71 device_data = trigger_data['env']['device'] |
69 step_result.presentation.step_text = 'on %s %s %s' % ( | 72 step_result.presentation.step_text = 'on %s %s %s' % ( |
70 device_data['brand'], | 73 device_data['brand'], |
71 device_data['name'], | 74 device_data['name'], |
72 device_data['os_version']) | 75 device_data['os_version']) |
73 except KeyError: | 76 except KeyError: |
(...skipping 28 matching lines...) Expand all Loading... |
102 device_data['brand'], | 105 device_data['brand'], |
103 device_data['name'], | 106 device_data['name'], |
104 device_data['os_version']) | 107 device_data['os_version']) |
105 except KeyError: | 108 except KeyError: |
106 device_data = None | 109 device_data = None |
107 device_info_text = 'unable to find device info' | 110 device_info_text = 'unable to find device info' |
108 | 111 |
109 if verbose: | 112 if verbose: |
110 args += ['--verbose'] | 113 args += ['--verbose'] |
111 try: | 114 try: |
112 step_result = self.m.python( | 115 step_result = self.m.chromium_android.test_runner( |
113 '[collect] %s' % suite, | 116 '[collect] %s' % suite, |
114 self.m.path['checkout'].join('build', 'android', 'test_runner.py'), | |
115 args=args) | 117 args=args) |
116 except self.m.step.StepFailure as f: | 118 except self.m.step.StepFailure as f: |
117 step_result = f.result | 119 step_result = f.result |
118 raise | 120 raise |
119 finally: | 121 finally: |
120 step_result.presentation.step_text = device_info_text | 122 step_result.presentation.step_text = device_info_text |
121 if (not device_data and | 123 if (not device_data and |
122 step_result.presentation.status != self.m.step.FAILURE): | 124 step_result.presentation.status == self.m.step.SUCCESS): |
123 step_result.presentation.status = self.m.step.WARNING | 125 step_result.presentation.status = self.m.step.WARNING |
124 | 126 |
125 def upload_logcat_to_gs(self, bucket, suite): | 127 def upload_logcat_to_gs(self, bucket, suite): |
126 """Upload the logcat file returned from the appurify results to | 128 """Upload the logcat file returned from the appurify results to |
127 Google Storage. | 129 Google Storage. |
128 """ | 130 """ |
129 step_result = self.m.json.read( | 131 step_result = self.m.json.read( |
130 '[upload logcat] load %s data' % suite, | 132 '[upload logcat] load %s data' % suite, |
131 self._get_trigger_file_for_suite(suite), | 133 self._get_trigger_file_for_suite(suite), |
132 step_test_data=lambda: self.m.json.test_api.output({ | 134 step_test_data=lambda: self.m.json.test_api.output({ |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 amp_args += ['--device-oem', d] | 246 amp_args += ['--device-oem', d] |
245 | 247 |
246 for d in device_os or []: | 248 for d in device_os or []: |
247 amp_args += ['--remote-device-os', d] | 249 amp_args += ['--remote-device-os', d] |
248 | 250 |
249 if device_timeout: | 251 if device_timeout: |
250 amp_args += ['--remote-device-timeout', device_timeout] | 252 amp_args += ['--remote-device-timeout', device_timeout] |
251 | 253 |
252 return amp_args | 254 return amp_args |
253 | 255 |
OLD | NEW |