1 # Copyright 2018, The Android Open Source Project 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 """ 16 Regression Detection test runner class. 17 """ 18 19 # pylint: disable=import-error 20 import constants 21 import test_runner_base 22 23 24 class RegressionTestRunner(test_runner_base.TestRunnerBase): 25 """Regression Test Runner class.""" 26 NAME = 'RegressionTestRunner' 27 EXECUTABLE = 'tradefed.sh' 28 _RUN_CMD = '{exe} run commandAndExit regression -n {args}' 29 _BUILD_REQ = {'tradefed-core'} 30 31 def __init__(self, results_dir): 32 """Init stuff for base class.""" 33 super(RegressionTestRunner, self).__init__(results_dir) 34 self.run_cmd_dict = {'exe': self.EXECUTABLE, 35 'args': ''} 36 37 def run_tests(self, test_infos, extra_args): 38 """Run the list of test_infos. 39 40 Args: 41 test_infos: List of TestInfo. 42 args: Dict of args to add to regression detection test run. 43 """ 44 pre = extra_args.pop(constants.PRE_PATCH_FOLDER) 45 post = extra_args.pop(constants.POST_PATCH_FOLDER) 46 args = ['--pre-patch-metrics', pre, '--post-patch-metrics', post] 47 self.run_cmd_dict['args'] = ' '.join(args) 48 run_cmd = self._RUN_CMD.format(**self.run_cmd_dict) 49 super(RegressionTestRunner, self).run(run_cmd) 50 51 def host_env_check(self): 52 """Check that host env has everything we need. 53 54 We actually can assume the host env is fine because we have the same 55 requirements that atest has. Update this to check for android env vars 56 if that changes. 57 """ 58 pass 59 60 def get_test_runner_build_reqs(self): 61 """Return the build requirements. 62 63 Returns: 64 Set of build targets. 65 """ 66 return self._BUILD_REQ 67