aboutsummaryrefslogtreecommitdiff
path: root/crosperf/suite_runner.py
diff options
context:
space:
mode:
authorYunlian Jiang <yunlian@google.com>2013-04-23 15:05:05 -0700
committerChromeBot <chrome-bot@google.com>2013-06-06 13:52:33 -0700
commit04dc5dc8547dbfbe524cf35ac39537346ad749bb (patch)
treefdb51e46da30efec2fbf310670b7ad5f5ce8be43 /crosperf/suite_runner.py
parent9fc991900056e20bb940eed243dad0c0516d497b (diff)
downloadtoolchain-utils-04dc5dc8547dbfbe524cf35ac39537346ad749bb.tar.gz
Adding support of telemetry to crosperf
BUG=None TEST=run crosperf with pyauto/telemetry test with/without cache. all pass. Change-Id: If07ac020a9107a79d5780a58fd6dcc924d07f07f Reviewed-on: https://gerrit-int.chromium.org/36594 Reviewed-by: Luis Lozano <llozano@chromium.org> Commit-Queue: Yunlian Jiang <yunlian@google.com> Tested-by: Yunlian Jiang <yunlian@google.com> Reviewed-on: https://gerrit-int.chromium.org/39241 Reviewed-by: Yunlian Jiang <yunlian@google.com>
Diffstat (limited to 'crosperf/suite_runner.py')
-rw-r--r--crosperf/suite_runner.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/crosperf/suite_runner.py b/crosperf/suite_runner.py
new file mode 100644
index 00000000..d89f307d
--- /dev/null
+++ b/crosperf/suite_runner.py
@@ -0,0 +1,83 @@
+#!/usr/bin/python
+
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import time
+
+from utils import command_executer
+
+
+class SuiteRunner(object):
+ """ This defines the interface from crosperf to test script.
+ """
+ def __init__(self, logger_to_use=None):
+ self._logger = logger_to_use
+ self._ce = command_executer.GetCommandExecuter(self._logger)
+ self._ct = command_executer.CommandTerminator()
+
+ def Run(self, machine, label, benchmark, test_args):
+ if benchmark.suite == "telemetry":
+ return self.Telemetry_Run(machine, label, benchmark)
+ else:
+ return self.Pyauto_Run(machine, label, benchmark, test_args)
+
+ def RebootMachine(self, machine_name, chromeos_root):
+ command ="reboot && exit"
+ self._ce.CrosRunCommand(command, machine=machine_name,
+ chromeos_root=chromeos_root)
+ time.sleep(60)
+
+
+ def Pyauto_Run(self, machine, label, benchmark, test_args):
+ """Run the run_remote_test."""
+ options = ""
+ if label.board:
+ options += " --board=%s" % label.board
+ if test_args:
+ options += " %s" % test_args
+ command = "rm -rf /usr/local/autotest/results/*"
+ self._ce.CrosRunCommand(command, machine=machine, username="root",
+ chromeos_root=label.chromeos_root)
+
+ self.RebootMachine(machine, label.chromeos_root)
+
+ command = ("./run_remote_tests.sh --remote=%s %s %s" %
+ (machine, options, benchmark.test_name))
+ return self._ce.ChrootRunCommand(label.chromeos_root,
+ command,
+ True,
+ self._ct)
+
+ def Telemetry_Run(self, machine, label, benchmark):
+ if not os.path.isdir(label.chrome_src):
+ self._logger.GetLogger().LogFatal("Cannot find chrome src dir to"
+ "run telemetry.")
+ rsa_key = os.path.join(label.chromeos_root,
+ "src/scripts/mod_for_test_scripts/ssh_keys/testing_rsa")
+
+ cmd = ("cd {0} && "
+ "./tools/perf/run_multipage_benchmarks "
+ "--browser=cros-chrome "
+ "--output-format=csv "
+ "--remote={1} "
+ "--identity {2} "
+ "{3} {4}".format(label.chrome_src, machine,
+ rsa_key,
+ benchmark.test_name,
+ benchmark.test_args))
+ return self._ce.RunCommand(cmd, return_output=True,
+ print_to_console=False)
+
+ def Terminate(self):
+ self._ct.Terminate()
+
+
+class MockSuiteRunner(object):
+ def __init__(self):
+ pass
+
+ def Run(self, *args):
+ return ["", "", 0]