Kuang-che Wu | 875c89a | 2020-01-08 14:30:55 +0800 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 2 | # -*- coding: utf-8 -*- |
| 3 | # Copyright 2018 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | """Diagnose ChromeOS autotest regressions. |
| 7 | |
| 8 | This is integrated bisection utility. Given ChromeOS, Chrome, Android source |
Kuang-che Wu | 927231f | 2018-07-24 14:21:56 +0800 | [diff] [blame] | 9 | tree, and necessary parameters, this script can determine which components to |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 10 | bisect, and hopefully output the culprit CL of regression. |
| 11 | |
| 12 | Sometimes the script failed to figure out the final CL for various reasons, it |
| 13 | will cut down the search range as narrow as it can. |
| 14 | """ |
| 15 | from __future__ import print_function |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 16 | import logging |
| 17 | import os |
| 18 | |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 19 | from bisect_kit import cros_lab_util |
| 20 | from bisect_kit import cros_util |
| 21 | from bisect_kit import diagnoser_cros |
Kuang-che Wu | e121fae | 2018-11-09 16:18:39 +0800 | [diff] [blame] | 22 | from bisect_kit import errors |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 23 | from bisect_kit import util |
Kuang-che Wu | d8fc957 | 2018-10-03 21:00:41 +0800 | [diff] [blame] | 24 | import setup_cros_bisect |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 25 | |
| 26 | logger = logging.getLogger(__name__) |
| 27 | |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 28 | |
Kuang-che Wu | 22aa9d4 | 2019-01-25 10:35:33 +0800 | [diff] [blame] | 29 | def get_test_dependency_labels(config): |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 30 | # Assume "DEPENDENCIES" is identical between the period of |
| 31 | # `old` and `new` version. |
Kuang-che Wu | 7f82c6f | 2019-08-12 14:29:28 +0800 | [diff] [blame] | 32 | autotest_dir = os.path.join(config['chromeos_root'], |
| 33 | cros_util.prebuilt_autotest_dir) |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 34 | info = cros_util.get_autotest_test_info(autotest_dir, config['test_name']) |
Kuang-che Wu | 0f1c3b0 | 2019-01-10 01:21:01 +0800 | [diff] [blame] | 35 | assert info, 'incorrect test name? %s' % config['test_name'] |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 36 | |
Kuang-che Wu | 22aa9d4 | 2019-01-25 10:35:33 +0800 | [diff] [blame] | 37 | extra_labels = [] |
| 38 | dependencies = info.variables.get('DEPENDENCIES', '') |
| 39 | for label in dependencies.split(','): |
| 40 | label = label.strip() |
| 41 | # Skip non-machine labels |
| 42 | if not label or label in ['cleanup-reboot']: |
| 43 | continue |
| 44 | extra_labels.append(label) |
| 45 | |
| 46 | return extra_labels |
| 47 | |
| 48 | |
Kuang-che Wu | 32f2724 | 2019-05-16 17:34:50 +0800 | [diff] [blame] | 49 | class DiagnoseAutotestCommandLine(diagnoser_cros.DiagnoseCommandLineBase): |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 50 | """Diagnose command line interface.""" |
Kuang-che Wu | d8fc957 | 2018-10-03 21:00:41 +0800 | [diff] [blame] | 51 | |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 52 | def check_options(self, opts, path_factory): |
Kuang-che Wu | 6d91b8c | 2020-11-24 20:14:35 +0800 | [diff] [blame] | 53 | super().check_options(opts, path_factory) |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 54 | |
Kuang-che Wu | 85c613c | 2019-01-09 15:46:11 +0800 | [diff] [blame] | 55 | is_cts = ( |
| 56 | opts.cts_revision or opts.cts_abi or opts.cts_prefix or |
| 57 | opts.cts_module or opts.cts_test or opts.cts_timeout) |
| 58 | if is_cts: |
| 59 | if opts.test_name or opts.metric or opts.args: |
| 60 | self.argument_parser.error( |
| 61 | 'do not specify --test_name, --metric, --args for CTS/GTS tests') |
Kuang-che Wu | b91b151 | 2019-05-29 15:16:29 +0800 | [diff] [blame] | 62 | if not opts.cts_prefix: |
| 63 | self.argument_parser.error( |
| 64 | '--cts_prefix should be specified for CTS/GTS tests') |
| 65 | if not opts.cts_module: |
| 66 | self.argument_parser.error( |
| 67 | '--cts_module should be specified for CTS/GTS tests') |
Kuang-che Wu | 85c613c | 2019-01-09 15:46:11 +0800 | [diff] [blame] | 68 | opts.test_name = '%s.tradefed-run-test' % opts.cts_prefix |
Kuang-che Wu | 32f2724 | 2019-05-16 17:34:50 +0800 | [diff] [blame] | 69 | elif not opts.test_name: |
| 70 | self.argument_parser.error( |
| 71 | '--test_name should be specified if not CTS/GTS tests') |
Kuang-che Wu | 85c613c | 2019-01-09 15:46:11 +0800 | [diff] [blame] | 72 | |
Kuang-che Wu | 32f2724 | 2019-05-16 17:34:50 +0800 | [diff] [blame] | 73 | def init_hook(self, opts): |
| 74 | self.states.config.update( |
Kuang-che Wu | 85c613c | 2019-01-09 15:46:11 +0800 | [diff] [blame] | 75 | cts_revision=opts.cts_revision, |
| 76 | cts_abi=opts.cts_abi, |
| 77 | cts_prefix=opts.cts_prefix, |
| 78 | cts_module=opts.cts_module, |
| 79 | cts_test=opts.cts_test, |
| 80 | cts_timeout=opts.cts_timeout, |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 81 | test_that_args=opts.args, |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 82 | ) |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 83 | |
Kuang-che Wu | 7f82c6f | 2019-08-12 14:29:28 +0800 | [diff] [blame] | 84 | # Unpack old autotest prebuilt, assume following information don't change |
| 85 | # between versions: |
| 86 | # - what chrome binaries to run |
| 87 | # - dependency labels for DUT allocation |
| 88 | common_switch_cmd, _common_eval_cmd = self._build_cmds() |
Kuang-che Wu | d1b7415 | 2020-05-20 08:46:46 +0800 | [diff] [blame] | 89 | util.check_call(*(common_switch_cmd + |
| 90 | [self.config['old'], '--dut', opts.dut])) |
Kuang-che Wu | 7f82c6f | 2019-08-12 14:29:28 +0800 | [diff] [blame] | 91 | |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 92 | def _build_cmds(self): |
| 93 | # prebuilt version will be specified later. |
Kuang-che Wu | 7f82c6f | 2019-08-12 14:29:28 +0800 | [diff] [blame] | 94 | common_switch_cmd = [ |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 95 | './switch_autotest_prebuilt.py', |
Kuang-che Wu | 99e808f | 2019-06-26 12:17:32 +0800 | [diff] [blame] | 96 | '--chromeos_root', |
| 97 | self.config['chromeos_root'], |
| 98 | '--board', |
| 99 | self.config['board'], |
| 100 | ] |
Kuang-che Wu | 85c613c | 2019-01-09 15:46:11 +0800 | [diff] [blame] | 101 | if self.config['test_name'] and not self.config['cts_test']: |
Kuang-che Wu | 7f82c6f | 2019-08-12 14:29:28 +0800 | [diff] [blame] | 102 | common_switch_cmd += ['--test_name', self.config['test_name']] |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 103 | |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 104 | common_eval_cmd = [ |
| 105 | './eval_cros_autotest.py', |
| 106 | '--chromeos_root', self.config['chromeos_root'], |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 107 | ] # yapf: disable |
Kuang-che Wu | 85c613c | 2019-01-09 15:46:11 +0800 | [diff] [blame] | 108 | if self.config['test_name'] and not self.config['cts_test']: |
| 109 | common_eval_cmd += ['--test_name', self.config['test_name']] |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 110 | if self.config['metric']: |
| 111 | common_eval_cmd += [ |
| 112 | '--metric', self.config['metric'], |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 113 | ] # yapf: disable |
Kuang-che Wu | 32f2724 | 2019-05-16 17:34:50 +0800 | [diff] [blame] | 114 | if self.config['fail_to_pass']: |
Kuang-che Wu | 0a4304a | 2019-01-19 01:32:11 +0800 | [diff] [blame] | 115 | common_eval_cmd.append('--fail_to_pass') |
Kuang-che Wu | da3abfe | 2019-03-21 14:48:12 +0800 | [diff] [blame] | 116 | if self.config['reboot_before_test']: |
| 117 | common_eval_cmd.append('--reboot_before_test') |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 118 | if self.config['test_that_args']: |
| 119 | common_eval_cmd += ['--args', self.config['test_that_args']] |
Kuang-che Wu | d4603d7 | 2018-11-29 17:51:21 +0800 | [diff] [blame] | 120 | if self.config['test_name'].startswith('telemetry_'): |
| 121 | common_eval_cmd += ['--chrome_root', self.config['chrome_root']] |
Kuang-che Wu | 85c613c | 2019-01-09 15:46:11 +0800 | [diff] [blame] | 122 | |
| 123 | for arg_name in [ |
| 124 | 'cts_revision', 'cts_abi', 'cts_prefix', 'cts_module', 'cts_test', |
| 125 | 'cts_timeout' |
| 126 | ]: |
| 127 | if self.config.get(arg_name) is not None: |
| 128 | common_eval_cmd += ['--%s' % arg_name, str(self.config[arg_name])] |
| 129 | |
Kuang-che Wu | 7f82c6f | 2019-08-12 14:29:28 +0800 | [diff] [blame] | 130 | return common_switch_cmd, common_eval_cmd |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 131 | |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 132 | def cmd_run(self, opts): |
| 133 | del opts # unused |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 134 | |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 135 | self.states.load() |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 136 | |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 137 | try: |
| 138 | path_factory = setup_cros_bisect.DefaultProjectPathFactory( |
| 139 | self.config['mirror_base'], self.config['work_base'], |
| 140 | self.config['session']) |
Kuang-che Wu | 7f82c6f | 2019-08-12 14:29:28 +0800 | [diff] [blame] | 141 | common_switch_cmd, common_eval_cmd = self._build_cmds() |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 142 | |
Kuang-che Wu | 30039b1 | 2021-01-18 10:10:33 +0800 | [diff] [blame] | 143 | lease_reason = cros_lab_util.make_lease_reason(self.config['session']) |
Kuang-che Wu | 0c9b794 | 2019-10-30 16:55:39 +0800 | [diff] [blame] | 144 | with cros_lab_util.dut_manager( |
Kuang-che Wu | 30039b1 | 2021-01-18 10:10:33 +0800 | [diff] [blame] | 145 | self.config['dut'], |
| 146 | lease_reason, lambda: diagnoser_cros.grab_dut(self.config)) as dut: |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 147 | if not dut: |
| 148 | raise errors.NoDutAvailable('unable to allocate DUT') |
Kuang-che Wu | 0c9b794 | 2019-10-30 16:55:39 +0800 | [diff] [blame] | 149 | |
Kuang-che Wu | 7cb08df | 2019-06-04 19:12:29 +0800 | [diff] [blame] | 150 | if not cros_util.is_good_dut(dut): |
| 151 | if not cros_lab_util.repair(dut): |
| 152 | raise errors.ExternalError('Not a good DUT and unable to repair') |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 153 | if self.config['dut'] == cros_lab_util.LAB_DUT: |
| 154 | self.config['allocated_dut'] = dut |
| 155 | self.states.save() |
| 156 | common_eval_cmd.append(dut) |
| 157 | |
Kuang-che Wu | 7f82c6f | 2019-08-12 14:29:28 +0800 | [diff] [blame] | 158 | util.check_call('./switch_cros_localbuild.py', '--nobuild', |
| 159 | '--chromeos_root', self.config['chromeos_root'], |
| 160 | '--chromeos_mirror', self.config['chromeos_mirror'], |
Kuang-che Wu | 0ebbf7c | 2019-08-28 18:19:19 +0800 | [diff] [blame] | 161 | '--board', self.config['board'], self.config['new']) |
Kuang-che Wu | 7f82c6f | 2019-08-12 14:29:28 +0800 | [diff] [blame] | 162 | |
Kuang-che Wu | 186071a | 2019-03-28 17:11:41 +0800 | [diff] [blame] | 163 | diagnoser = diagnoser_cros.CrosDiagnoser(self.states, path_factory, |
| 164 | self.config, dut) |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 165 | |
Kuang-che Wu | fd2ea5e | 2019-06-10 20:40:17 +0800 | [diff] [blame] | 166 | eval_cmd = common_eval_cmd + ['--prebuilt'] |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 167 | # Do not specify version for autotest prebuilt switching here. The trick |
| 168 | # is that version number is obtained via bisector's environment variable |
| 169 | # CROS_VERSION. |
Kuang-che Wu | 7f82c6f | 2019-08-12 14:29:28 +0800 | [diff] [blame] | 170 | extra_switch_cmd = common_switch_cmd |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 171 | diagnoser.narrow_down_chromeos_prebuilt( |
| 172 | self.config['old'], |
| 173 | self.config['new'], |
| 174 | eval_cmd, |
Kuang-che Wu | 7f82c6f | 2019-08-12 14:29:28 +0800 | [diff] [blame] | 175 | extra_switch_cmd=extra_switch_cmd) |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 176 | |
| 177 | diagnoser.switch_chromeos_to_old(force=self.config['always_reflash']) |
Kuang-che Wu | d1b7415 | 2020-05-20 08:46:46 +0800 | [diff] [blame] | 178 | util.check_call(*(common_switch_cmd + |
| 179 | [diagnoser.cros_old, '--dut', dut])) |
Kuang-che Wu | c8c495d | 2019-08-19 17:48:58 +0800 | [diff] [blame] | 180 | dut_os_version = cros_util.query_dut_short_version(dut) |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 181 | |
| 182 | try: |
| 183 | if diagnoser.narrow_down_android(eval_cmd): |
| 184 | return |
Kuang-che Wu | ec566f3 | 2019-03-07 16:53:32 +0800 | [diff] [blame] | 185 | except errors.DiagnoseContradiction: |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 186 | raise |
| 187 | except Exception: |
Kuang-che Wu | c93d0f9 | 2020-05-20 20:55:23 +0800 | [diff] [blame] | 188 | diagnoser.make_decision( |
Kuang-che Wu | e4435b4 | 2020-05-21 20:06:24 +0800 | [diff] [blame] | 189 | 'Exception in Android bisector before verification; ' |
| 190 | 'assume the culprit is not inside Android and continue') |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 191 | # Assume it's ok to leave random version of android prebuilt on DUT. |
| 192 | |
Kuang-che Wu | c8c495d | 2019-08-19 17:48:58 +0800 | [diff] [blame] | 193 | # Sanity check. The OS version should not change after android bisect. |
Kuang-che Wu | 523bdf2 | 2019-08-20 12:11:09 +0800 | [diff] [blame] | 194 | assert dut_os_version == cros_util.query_dut_short_version(dut), \ |
Kuang-che Wu | 5940031 | 2020-11-10 14:53:54 +0800 | [diff] [blame] | 195 | 'Someone else reflashed the DUT. DUT locking is not respected?' |
Kuang-che Wu | c8c495d | 2019-08-19 17:48:58 +0800 | [diff] [blame] | 196 | |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 197 | eval_cmd = common_eval_cmd + ['--prebuilt'] |
Kuang-che Wu | fd2ea5e | 2019-06-10 20:40:17 +0800 | [diff] [blame] | 198 | |
Kuang-che Wu | da9cb70 | 2019-11-11 14:40:56 +0800 | [diff] [blame] | 199 | chrome_with_tests = bool(self.config['test_name']) # not CTS/GTS |
| 200 | if chrome_with_tests: |
Kuang-che Wu | fd2ea5e | 2019-06-10 20:40:17 +0800 | [diff] [blame] | 201 | # Now, the version of autotest on the DUT is unknown and may be even |
| 202 | # not installed. Invoke the test once here, so |
| 203 | # - make sure autotest-deps is installed, with expected version |
Kuang-che Wu | da9cb70 | 2019-11-11 14:40:56 +0800 | [diff] [blame] | 204 | # - autotest-deps is installed first, so our chrome test binaries |
Kuang-che Wu | fd2ea5e | 2019-06-10 20:40:17 +0800 | [diff] [blame] | 205 | # won't be reset to default version during bisection. |
| 206 | # It's acceptable to spend extra time to run test once because |
| 207 | # - only few tests do so |
| 208 | # - tests are migrating away from autotest |
| 209 | util.call(*eval_cmd) |
| 210 | |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 211 | try: |
Zheng-Jie Chang | 7a076a5 | 2020-05-31 13:03:37 +0800 | [diff] [blame] | 212 | buildbucket_build = ( |
| 213 | cros_util.is_buildbucket_buildable(self.config['old']) and |
| 214 | self.config['enable_buildbucket_chrome']) |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 215 | if diagnoser.narrow_down_chrome( |
Zheng-Jie Chang | 7a076a5 | 2020-05-31 13:03:37 +0800 | [diff] [blame] | 216 | eval_cmd, |
| 217 | buildbucket_build=buildbucket_build, |
| 218 | with_tests=chrome_with_tests): |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 219 | return |
Kuang-che Wu | ec566f3 | 2019-03-07 16:53:32 +0800 | [diff] [blame] | 220 | except errors.DiagnoseContradiction: |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 221 | raise |
| 222 | except Exception: |
Kuang-che Wu | c93d0f9 | 2020-05-20 20:55:23 +0800 | [diff] [blame] | 223 | diagnoser.make_decision( |
Kuang-che Wu | e4435b4 | 2020-05-21 20:06:24 +0800 | [diff] [blame] | 224 | 'Exception in Chrome bisector before verification; ' |
| 225 | 'assume the culprit is not inside Chrome and continue') |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 226 | |
Zheng-Jie Chang | 7a076a5 | 2020-05-31 13:03:37 +0800 | [diff] [blame] | 227 | if not self.config['chrome_deploy_image'] and not buildbucket_build: |
Kuang-che Wu | de5bfc3 | 2019-09-12 21:56:48 +0800 | [diff] [blame] | 228 | # Sanity check. The OS version should not change after chrome bisect. |
| 229 | assert dut_os_version == cros_util.query_dut_short_version(dut), \ |
Kuang-che Wu | 5940031 | 2020-11-10 14:53:54 +0800 | [diff] [blame] | 230 | 'Someone else reflashed the DUT. DUT locking is not respected?' |
Kuang-che Wu | c8c495d | 2019-08-19 17:48:58 +0800 | [diff] [blame] | 231 | |
Zheng-Jie Chang | 61a645a | 2020-04-29 10:12:13 +0800 | [diff] [blame] | 232 | buildbucket_build = ( |
| 233 | cros_util.is_buildbucket_buildable(self.config['old']) and |
| 234 | not self.config['disable_buildbucket_chromeos']) |
| 235 | |
| 236 | if not buildbucket_build: |
Zheng-Jie Chang | 181be6f | 2020-03-17 16:16:08 +0800 | [diff] [blame] | 237 | eval_cmd = common_eval_cmd |
| 238 | extra_switch_cmd = None |
Zheng-Jie Chang | d3fd8f1 | 2020-04-14 11:41:06 +0800 | [diff] [blame] | 239 | else: |
| 240 | eval_cmd = common_eval_cmd + ['--prebuilt'] |
| 241 | extra_switch_cmd = common_switch_cmd |
Zheng-Jie Chang | 181be6f | 2020-03-17 16:16:08 +0800 | [diff] [blame] | 242 | diagnoser.narrow_down_chromeos_localbuild( |
Zheng-Jie Chang | 61a645a | 2020-04-29 10:12:13 +0800 | [diff] [blame] | 243 | eval_cmd, buildbucket_build, extra_switch_cmd=extra_switch_cmd) |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 244 | logger.info('%s done', __file__) |
| 245 | except Exception as e: |
| 246 | logger.exception('got exception; stop') |
| 247 | exception_name = e.__class__.__name__ |
| 248 | self.states.add_history( |
Kuang-che Wu | 0c2cb92 | 2020-06-16 23:34:53 +0800 | [diff] [blame] | 249 | 'failed', |
| 250 | text='%s: %s' % (exception_name, e), |
| 251 | exception=exception_name) |
Kuang-che Wu | 8b65409 | 2018-11-09 17:56:25 +0800 | [diff] [blame] | 252 | |
Kuang-che Wu | 32f2724 | 2019-05-16 17:34:50 +0800 | [diff] [blame] | 253 | def create_argument_parser_hook(self, parser_init): |
Kuang-che Wu | 85c613c | 2019-01-09 15:46:11 +0800 | [diff] [blame] | 254 | group = parser_init.add_argument_group(title='Options for CTS/GTS tests') |
| 255 | group.add_argument('--cts_revision', help='CTS revision, like "9.0_r3"') |
Kuang-che Wu | 63f836a | 2019-02-21 16:33:32 +0000 | [diff] [blame] | 256 | group.add_argument('--cts_abi', choices=['arm', 'x86']) |
Kuang-che Wu | 85c613c | 2019-01-09 15:46:11 +0800 | [diff] [blame] | 257 | group.add_argument( |
| 258 | '--cts_prefix', |
| 259 | help='Prefix of autotest test name, ' |
| 260 | 'like cheets_CTS_N, cheets_CTS_P, cheets_GTS') |
| 261 | group.add_argument( |
| 262 | '--cts_module', help='CTS/GTS module name, like "CtsCameraTestCases"') |
| 263 | group.add_argument( |
| 264 | '--cts_test', |
| 265 | help='CTS/GTS test name, like ' |
| 266 | '"android.hardware.cts.CameraTest#testDisplayOrientation"') |
| 267 | group.add_argument('--cts_timeout', type=float, help='timeout, in seconds') |
| 268 | |
Kuang-che Wu | a41525a | 2018-10-17 23:52:24 +0800 | [diff] [blame] | 269 | group = parser_init.add_argument_group(title='Options passed to test_that') |
| 270 | group.add_argument( |
| 271 | '--args', |
| 272 | help='Extra args passed to "test_that --args"; Overrides the default') |
| 273 | |
Kuang-che Wu | 1fcc022 | 2018-07-07 16:43:22 +0800 | [diff] [blame] | 274 | |
| 275 | if __name__ == '__main__': |
Kuang-che Wu | 32f2724 | 2019-05-16 17:34:50 +0800 | [diff] [blame] | 276 | DiagnoseAutotestCommandLine().main() |