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