Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 1 | # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
Rahul Chaudhry | cbc5a26 | 2015-12-30 17:05:14 -0800 | [diff] [blame] | 5 | from __future__ import print_function |
| 6 | |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 7 | import os |
| 8 | import time |
cmtice | e5a746f | 2013-11-25 14:57:10 -0500 | [diff] [blame] | 9 | import shlex |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 10 | |
| 11 | from utils import command_executer |
Caroline Tice | 7057cf6 | 2015-12-10 12:09:40 -0800 | [diff] [blame] | 12 | import test_flag |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 13 | |
Caroline Tice | 9277419 | 2013-09-10 16:29:18 -0700 | [diff] [blame] | 14 | TEST_THAT_PATH = '/usr/bin/test_that' |
| 15 | CHROME_MOUNT_DIR = '/tmp/chrome_root' |
| 16 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 17 | |
| 18 | def GetProfilerArgs(profiler_args): |
cmtice | e5a746f | 2013-11-25 14:57:10 -0500 | [diff] [blame] | 19 | # Remove "--" from in front of profiler args. |
| 20 | args_list = shlex.split(profiler_args) |
| 21 | new_list = [] |
| 22 | for arg in args_list: |
| 23 | if arg[0:2] == '--': |
| 24 | arg = arg[2:] |
| 25 | new_list.append(arg) |
| 26 | args_list = new_list |
| 27 | |
| 28 | # Remove "perf_options=" from middle of profiler args. |
| 29 | new_list = [] |
| 30 | for arg in args_list: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 31 | idx = arg.find('perf_options=') |
cmtice | e5a746f | 2013-11-25 14:57:10 -0500 | [diff] [blame] | 32 | if idx != -1: |
| 33 | prefix = arg[0:idx] |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 34 | suffix = arg[idx + len('perf_options=') + 1:-1] |
cmtice | e5a746f | 2013-11-25 14:57:10 -0500 | [diff] [blame] | 35 | new_arg = prefix + "'" + suffix + "'" |
| 36 | new_list.append(new_arg) |
| 37 | else: |
| 38 | new_list.append(arg) |
| 39 | args_list = new_list |
| 40 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 41 | return ' '.join(args_list) |
Caroline Tice | 9277419 | 2013-09-10 16:29:18 -0700 | [diff] [blame] | 42 | |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 43 | |
| 44 | class SuiteRunner(object): |
Rahul Chaudhry | 3ebd061 | 2015-12-30 18:16:07 -0800 | [diff] [blame^] | 45 | """This defines the interface from crosperf to test script.""" |
Caroline Tice | 9277419 | 2013-09-10 16:29:18 -0700 | [diff] [blame] | 46 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 47 | def __init__(self, |
| 48 | logger_to_use=None, |
| 49 | log_level='verbose', |
| 50 | cmd_exec=None, |
cmtice | 4f0309d | 2014-06-15 13:36:05 -0700 | [diff] [blame] | 51 | cmd_term=None): |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 52 | self._logger = logger_to_use |
cmtice | 1390924 | 2014-03-11 13:38:07 -0700 | [diff] [blame] | 53 | self.log_level = log_level |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 54 | self._ce = cmd_exec or command_executer.GetCommandExecuter( |
| 55 | self._logger, |
| 56 | log_level=self.log_level) |
cmtice | 4f0309d | 2014-06-15 13:36:05 -0700 | [diff] [blame] | 57 | self._ct = cmd_term or command_executer.CommandTerminator() |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 58 | |
cmtice | e5a746f | 2013-11-25 14:57:10 -0500 | [diff] [blame] | 59 | def Run(self, machine, label, benchmark, test_args, profiler_args): |
Luis Lozano | df76222 | 2015-05-19 12:22:37 -0700 | [diff] [blame] | 60 | for i in range(0, benchmark.retries + 1): |
| 61 | self.PinGovernorExecutionFrequencies(machine, label.chromeos_root) |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 62 | if benchmark.suite == 'telemetry': |
Luis Lozano | df76222 | 2015-05-19 12:22:37 -0700 | [diff] [blame] | 63 | ret_tup = self.Telemetry_Run(machine, label, benchmark, profiler_args) |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 64 | elif benchmark.suite == 'telemetry_Crosperf': |
Luis Lozano | df76222 | 2015-05-19 12:22:37 -0700 | [diff] [blame] | 65 | ret_tup = self.Telemetry_Crosperf_Run(machine, label, benchmark, |
| 66 | test_args, profiler_args) |
| 67 | else: |
| 68 | ret_tup = self.Test_That_Run(machine, label, benchmark, test_args, |
| 69 | profiler_args) |
| 70 | if ret_tup[0] != 0: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 71 | self._logger.LogOutput('benchmark %s failed. Retries left: %s' % |
| 72 | (benchmark.name, benchmark.retries - i)) |
Luis Lozano | df76222 | 2015-05-19 12:22:37 -0700 | [diff] [blame] | 73 | elif i > 0: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 74 | self._logger.LogOutput('benchmark %s succeded after %s retries' % |
| 75 | (benchmark.name, i)) |
Luis Lozano | df76222 | 2015-05-19 12:22:37 -0700 | [diff] [blame] | 76 | break |
| 77 | else: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 78 | self._logger.LogOutput('benchmark %s succeded on first try' % |
| 79 | benchmark.name) |
Luis Lozano | df76222 | 2015-05-19 12:22:37 -0700 | [diff] [blame] | 80 | break |
| 81 | return ret_tup |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 82 | |
Luis Lozano | 53c88e9 | 2013-10-08 15:15:48 -0700 | [diff] [blame] | 83 | def GetHighestStaticFrequency(self, machine_name, chromeos_root): |
Rahul Chaudhry | 3ebd061 | 2015-12-30 18:16:07 -0800 | [diff] [blame^] | 84 | """Gets the highest static frequency for the specified machine.""" |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 85 | get_avail_freqs = ('cd /sys/devices/system/cpu/cpu0/cpufreq/; ' |
| 86 | 'if [[ -e scaling_available_frequencies ]]; then ' |
| 87 | ' cat scaling_available_frequencies; ' |
| 88 | 'else ' |
| 89 | ' cat scaling_max_freq ; ' |
| 90 | 'fi') |
Luis Lozano | 036c923 | 2015-12-10 10:47:01 -0800 | [diff] [blame] | 91 | ret, freqs_str, _ = self._ce.CrosRunCommandWOutput( |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 92 | get_avail_freqs, |
| 93 | machine=machine_name, |
| 94 | chromeos_root=chromeos_root) |
| 95 | self._logger.LogFatalIf(ret, 'Could not get available frequencies ' |
| 96 | 'from machine: %s' % machine_name) |
Luis Lozano | 53c88e9 | 2013-10-08 15:15:48 -0700 | [diff] [blame] | 97 | freqs = freqs_str.split() |
Luis Lozano | d0b4612 | 2015-12-07 15:09:33 -0800 | [diff] [blame] | 98 | # We need to make sure that the frequencies are sorted in decreasing |
| 99 | # order |
| 100 | freqs.sort(key=int, reverse=True) |
| 101 | |
Han Shen | fd0b178 | 2014-02-12 15:13:01 -0800 | [diff] [blame] | 102 | ## When there is no scaling_available_frequencies file, |
| 103 | ## we have only 1 choice. |
| 104 | if len(freqs) == 1: |
| 105 | return freqs[0] |
Luis Lozano | 53c88e9 | 2013-10-08 15:15:48 -0700 | [diff] [blame] | 106 | # The dynamic frequency ends with a "1000". So, ignore it if found. |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 107 | if freqs[0].endswith('1000'): |
Luis Lozano | 53c88e9 | 2013-10-08 15:15:48 -0700 | [diff] [blame] | 108 | return freqs[1] |
| 109 | else: |
| 110 | return freqs[0] |
| 111 | |
| 112 | def PinGovernorExecutionFrequencies(self, machine_name, chromeos_root): |
Rahul Chaudhry | 3ebd061 | 2015-12-30 18:16:07 -0800 | [diff] [blame^] | 113 | """Set min and max frequencies to max static frequency.""" |
Luis Lozano | 53c88e9 | 2013-10-08 15:15:48 -0700 | [diff] [blame] | 114 | highest_freq = self.GetHighestStaticFrequency(machine_name, chromeos_root) |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 115 | BASH_FOR = 'for f in {list}; do {body}; done' |
| 116 | CPUFREQ_DIRS = '/sys/devices/system/cpu/cpu*/cpufreq/' |
| 117 | change_max_freq = BASH_FOR.format(list=CPUFREQ_DIRS + 'scaling_max_freq', |
| 118 | body='echo %s > $f' % highest_freq) |
| 119 | change_min_freq = BASH_FOR.format(list=CPUFREQ_DIRS + 'scaling_min_freq', |
| 120 | body='echo %s > $f' % highest_freq) |
| 121 | change_perf_gov = BASH_FOR.format(list=CPUFREQ_DIRS + 'scaling_governor', |
| 122 | body='echo performance > $f') |
| 123 | if self.log_level == 'average': |
| 124 | self._logger.LogOutput('Pinning governor execution frequencies for %s' % |
| 125 | machine_name) |
| 126 | ret = self._ce.CrosRunCommand(' && '.join(( |
| 127 | 'set -e ', change_max_freq, change_min_freq, change_perf_gov)), |
Luis Lozano | 53c88e9 | 2013-10-08 15:15:48 -0700 | [diff] [blame] | 128 | machine=machine_name, |
| 129 | chromeos_root=chromeos_root) |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 130 | self._logger.LogFatalIf(ret, 'Could not pin frequencies on machine: %s' % |
| 131 | machine_name) |
Luis Lozano | 53c88e9 | 2013-10-08 15:15:48 -0700 | [diff] [blame] | 132 | |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 133 | def RebootMachine(self, machine_name, chromeos_root): |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 134 | command = 'reboot && exit' |
| 135 | self._ce.CrosRunCommand(command, |
| 136 | machine=machine_name, |
| 137 | chromeos_root=chromeos_root) |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 138 | time.sleep(60) |
Luis Lozano | 53c88e9 | 2013-10-08 15:15:48 -0700 | [diff] [blame] | 139 | # Whenever we reboot the machine, we need to restore the governor settings. |
| 140 | self.PinGovernorExecutionFrequencies(machine_name, chromeos_root) |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 141 | |
cmtice | e5a746f | 2013-11-25 14:57:10 -0500 | [diff] [blame] | 142 | def Test_That_Run(self, machine, label, benchmark, test_args, profiler_args): |
Caroline Tice | b47bff4 | 2013-08-19 15:59:02 -0700 | [diff] [blame] | 143 | """Run the test_that test..""" |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 144 | options = '' |
Caroline Tice | b47bff4 | 2013-08-19 15:59:02 -0700 | [diff] [blame] | 145 | if label.board: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 146 | options += ' --board=%s' % label.board |
Caroline Tice | b47bff4 | 2013-08-19 15:59:02 -0700 | [diff] [blame] | 147 | if test_args: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 148 | options += ' %s' % test_args |
cmtice | e5a746f | 2013-11-25 14:57:10 -0500 | [diff] [blame] | 149 | if profiler_args: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 150 | self._logger.LogFatal('test_that does not support profiler.') |
| 151 | command = 'rm -rf /usr/local/autotest/results/*' |
| 152 | self._ce.CrosRunCommand(command, |
| 153 | machine=machine, |
Caroline Tice | b47bff4 | 2013-08-19 15:59:02 -0700 | [diff] [blame] | 154 | chromeos_root=label.chromeos_root) |
| 155 | |
cmtice | 98a5369 | 2014-04-16 14:48:47 -0700 | [diff] [blame] | 156 | # We do this because some tests leave the machine in weird states. |
Luis Lozano | 53c88e9 | 2013-10-08 15:15:48 -0700 | [diff] [blame] | 157 | # Rebooting between iterations has proven to help with this. |
Caroline Tice | b47bff4 | 2013-08-19 15:59:02 -0700 | [diff] [blame] | 158 | self.RebootMachine(machine, label.chromeos_root) |
| 159 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 160 | command = ( |
| 161 | ('%s --autotest_dir ~/trunk/src/third_party/autotest/files --fast ' |
| 162 | '%s %s %s') % (TEST_THAT_PATH, options, machine, benchmark.test_name)) |
| 163 | if self.log_level != 'verbose': |
| 164 | self._logger.LogOutput('Running test.') |
| 165 | self._logger.LogOutput('CMD: %s' % command) |
Luis Lozano | 45b53c5 | 2015-09-30 11:36:27 -0700 | [diff] [blame] | 166 | # Use --no-ns-pid so that cros_sdk does not create a different |
| 167 | # process namespace and we can kill process created easily by |
| 168 | # their process group. |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 169 | return self._ce.ChrootRunCommandWOutput(label.chromeos_root, |
| 170 | command, |
| 171 | command_terminator=self._ct, |
| 172 | cros_sdk_options='--no-ns-pid') |
Caroline Tice | b47bff4 | 2013-08-19 15:59:02 -0700 | [diff] [blame] | 173 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 174 | def RemoveTelemetryTempFile(self, machine, chromeos_root): |
| 175 | filename = 'telemetry@%s' % machine |
| 176 | fullname = os.path.join(chromeos_root, 'chroot', 'tmp', filename) |
cmtice | 146058f | 2015-07-24 14:04:12 -0700 | [diff] [blame] | 177 | if os.path.exists(fullname): |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 178 | os.remove(fullname) |
Caroline Tice | 9277419 | 2013-09-10 16:29:18 -0700 | [diff] [blame] | 179 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 180 | def Telemetry_Crosperf_Run(self, machine, label, benchmark, test_args, |
| 181 | profiler_args): |
Caroline Tice | 9277419 | 2013-09-10 16:29:18 -0700 | [diff] [blame] | 182 | if not os.path.isdir(label.chrome_src): |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 183 | self._logger.LogFatal('Cannot find chrome src dir to' |
| 184 | ' run telemetry: %s' % label.chrome_src) |
Caroline Tice | 9277419 | 2013-09-10 16:29:18 -0700 | [diff] [blame] | 185 | |
cmtice | 146058f | 2015-07-24 14:04:12 -0700 | [diff] [blame] | 186 | # Check for and remove temporary file that may have been left by |
| 187 | # previous telemetry runs (and which might prevent this run from |
| 188 | # working). |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 189 | self.RemoveTelemetryTempFile(machine, label.chromeos_root) |
cmtice | 146058f | 2015-07-24 14:04:12 -0700 | [diff] [blame] | 190 | |
Luis Lozano | 004bccb | 2015-03-20 18:19:58 -0700 | [diff] [blame] | 191 | # For telemetry runs, we can use the autotest copy from the source |
| 192 | # location. No need to have one under /build/<board>. |
| 193 | autotest_dir_arg = '--autotest_dir ~/trunk/src/third_party/autotest/files' |
| 194 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 195 | profiler_args = GetProfilerArgs(profiler_args) |
| 196 | fast_arg = '' |
Luis Lozano | 5d7e21d | 2015-03-20 17:57:36 -0700 | [diff] [blame] | 197 | if not profiler_args: |
| 198 | # --fast works unless we are doing profiling (autotest limitation). |
| 199 | # --fast avoids unnecessary copies of syslogs. |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 200 | fast_arg = '--fast' |
| 201 | args_string = '' |
cmtice | e5a746f | 2013-11-25 14:57:10 -0500 | [diff] [blame] | 202 | if test_args: |
| 203 | # Strip double quotes off args (so we can wrap them in single |
| 204 | # quotes, to pass through to Telemetry). |
| 205 | if test_args[0] == '"' and test_args[-1] == '"': |
| 206 | test_args = test_args[1:-1] |
| 207 | args_string = "test_args='%s'" % test_args |
Luis Lozano | 004bccb | 2015-03-20 18:19:58 -0700 | [diff] [blame] | 208 | |
Ting-Yuan Huang | bc2d3d1 | 2015-07-02 13:09:03 +0800 | [diff] [blame] | 209 | cmd = ('{} {} {} --board={} --args="{} run_local={} test={} ' |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 210 | '{}" {} telemetry_Crosperf'.format( |
| 211 | TEST_THAT_PATH, autotest_dir_arg, fast_arg, label.board, |
| 212 | args_string, benchmark.run_local, benchmark.test_name, |
| 213 | profiler_args, machine)) |
Luis Lozano | 5d7e21d | 2015-03-20 17:57:36 -0700 | [diff] [blame] | 214 | |
Luis Lozano | 45b53c5 | 2015-09-30 11:36:27 -0700 | [diff] [blame] | 215 | # Use --no-ns-pid so that cros_sdk does not create a different |
| 216 | # process namespace and we can kill process created easily by their |
| 217 | # process group. |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 218 | chrome_root_options = ('--no-ns-pid ' |
| 219 | '--chrome_root={} --chrome_root_mount={} ' |
Luis Lozano | 45b53c5 | 2015-09-30 11:36:27 -0700 | [diff] [blame] | 220 | "FEATURES=\"-usersandbox\" " |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 221 | 'CHROME_ROOT={}'.format(label.chrome_src, |
| 222 | CHROME_MOUNT_DIR, |
| 223 | CHROME_MOUNT_DIR)) |
| 224 | if self.log_level != 'verbose': |
| 225 | self._logger.LogOutput('Running test.') |
| 226 | self._logger.LogOutput('CMD: %s' % cmd) |
Luis Lozano | 036c923 | 2015-12-10 10:47:01 -0800 | [diff] [blame] | 227 | return self._ce.ChrootRunCommandWOutput( |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 228 | label.chromeos_root, |
| 229 | cmd, |
| 230 | command_terminator=self._ct, |
Luis Lozano | 036c923 | 2015-12-10 10:47:01 -0800 | [diff] [blame] | 231 | cros_sdk_options=chrome_root_options) |
Caroline Tice | 9277419 | 2013-09-10 16:29:18 -0700 | [diff] [blame] | 232 | |
cmtice | 226e3e0 | 2014-04-27 22:28:42 -0700 | [diff] [blame] | 233 | def Telemetry_Run(self, machine, label, benchmark, profiler_args): |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 234 | telemetry_run_path = '' |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 235 | if not os.path.isdir(label.chrome_src): |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 236 | self._logger.LogFatal('Cannot find chrome src dir to' ' run telemetry.') |
cmtice | 98a5369 | 2014-04-16 14:48:47 -0700 | [diff] [blame] | 237 | else: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 238 | telemetry_run_path = os.path.join(label.chrome_src, 'src/tools/perf') |
cmtice | 98a5369 | 2014-04-16 14:48:47 -0700 | [diff] [blame] | 239 | if not os.path.exists(telemetry_run_path): |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 240 | self._logger.LogFatal('Cannot find %s directory.' % telemetry_run_path) |
cmtice | 98a5369 | 2014-04-16 14:48:47 -0700 | [diff] [blame] | 241 | |
cmtice | 226e3e0 | 2014-04-27 22:28:42 -0700 | [diff] [blame] | 242 | if profiler_args: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 243 | self._logger.LogFatal('Telemetry does not support the perf profiler.') |
cmtice | 226e3e0 | 2014-04-27 22:28:42 -0700 | [diff] [blame] | 244 | |
cmtice | 146058f | 2015-07-24 14:04:12 -0700 | [diff] [blame] | 245 | # Check for and remove temporary file that may have been left by |
| 246 | # previous telemetry runs (and which might prevent this run from |
| 247 | # working). |
Caroline Tice | 7057cf6 | 2015-12-10 12:09:40 -0800 | [diff] [blame] | 248 | if not test_flag.GetTestMode(): |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 249 | self.RemoveTelemetryTempFile(machine, label.chromeos_root) |
cmtice | 146058f | 2015-07-24 14:04:12 -0700 | [diff] [blame] | 250 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 251 | rsa_key = os.path.join( |
| 252 | label.chromeos_root, |
| 253 | 'src/scripts/mod_for_test_scripts/ssh_keys/testing_rsa') |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 254 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 255 | cmd = ('cd {0} && ' |
| 256 | './run_measurement ' |
| 257 | '--browser=cros-chrome ' |
| 258 | '--output-format=csv ' |
| 259 | '--remote={1} ' |
| 260 | '--identity {2} ' |
| 261 | '{3} {4}'.format(telemetry_run_path, machine, rsa_key, |
| 262 | benchmark.test_name, benchmark.test_args)) |
| 263 | if self.log_level != 'verbose': |
| 264 | self._logger.LogOutput('Running test.') |
| 265 | self._logger.LogOutput('CMD: %s' % cmd) |
Luis Lozano | 036c923 | 2015-12-10 10:47:01 -0800 | [diff] [blame] | 266 | return self._ce.RunCommandWOutput(cmd, print_to_console=False) |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 267 | |
| 268 | def Terminate(self): |
| 269 | self._ct.Terminate() |
| 270 | |
| 271 | |
| 272 | class MockSuiteRunner(object): |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 273 | |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 274 | def __init__(self): |
Caroline Tice | 9277419 | 2013-09-10 16:29:18 -0700 | [diff] [blame] | 275 | self._true = True |
Yunlian Jiang | 04dc5dc | 2013-04-23 15:05:05 -0700 | [diff] [blame] | 276 | |
Caroline Tice | 9277419 | 2013-09-10 16:29:18 -0700 | [diff] [blame] | 277 | def Run(self, *_args): |
| 278 | if self._true: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 279 | return [0, '', ''] |
Caroline Tice | 9277419 | 2013-09-10 16:29:18 -0700 | [diff] [blame] | 280 | else: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 281 | return [0, '', ''] |