Ahmad Sharif | 0dcbc4b | 2012-02-02 16:37:18 -0800 | [diff] [blame^] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # Copyright 2011 Google Inc. All Rights Reserved. |
| 4 | |
| 5 | from utils import command_executer |
| 6 | from utils import utils |
| 7 | |
| 8 | |
| 9 | class AutotestRunner(object): |
| 10 | def __init__(self, logger_to_use=None): |
| 11 | self._logger = logger_to_use |
| 12 | self._ce = command_executer.GetCommandExecuter(self._logger) |
| 13 | self._ct = command_executer.CommandTerminator() |
| 14 | |
| 15 | def Run(self, machine_name, chromeos_root, board, autotest_name, |
| 16 | autotest_args, profile_counters, profile_type): |
| 17 | if profile_counters and profile_type: |
| 18 | profiler_args = "-e " + " -e ".join(profile_counters) |
| 19 | # TODO(asharif): Add an option to do -g. |
| 20 | autotest_args += (" --profile --profiler_args='%s' --profile_type='%s'" |
| 21 | % (profiler_args, profile_type)) |
| 22 | options = "" |
| 23 | if board: |
| 24 | options += " --board=%s" % board |
| 25 | if autotest_args: |
| 26 | options += " %s" % autotest_args |
| 27 | command = ("./run_remote_tests.sh --remote=%s %s %s" % |
| 28 | (machine_name, options, autotest_name)) |
| 29 | return self._ce.ChrootRunCommand(chromeos_root, command, True, self._ct) |
| 30 | |
| 31 | def Terminate(self): |
| 32 | self._ct.Terminate() |
| 33 | |
| 34 | |
| 35 | class MockAutotestRunner(object): |
| 36 | def __init__(self): |
| 37 | pass |
| 38 | |
| 39 | def Run(self, *args): |
| 40 | return ["", "", 0] |