Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Unified Diff: tools/telemetry/telemetry/unittest/run_chromeos_tests.py

Issue 682953002: Add a wrapper for ChromeOS to call into telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: patch for review Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/unittest/run_chromeos_tests.py
diff --git a/tools/telemetry/telemetry/unittest/run_chromeos_tests.py b/tools/telemetry/telemetry/unittest/run_chromeos_tests.py
new file mode 100644
index 0000000000000000000000000000000000000000..2fe5eac7661d272e08d2545bf9a567a72dbfd045
--- /dev/null
+++ b/tools/telemetry/telemetry/unittest/run_chromeos_tests.py
@@ -0,0 +1,68 @@
+# Copyright 2014 The Chromium 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 logging
+import os
+import sys
+
+from telemetry.unittest import gtest_progress_reporter
+from telemetry.unittest import run_tests
+from telemetry.core import util
+
+
+def RunTestsForChromeOS(browser_type, unit_tests, perf_tests):
+ stream = _LoggingOutputStream()
+ error_string = ''
+
+ logging.info('Running telemetry unit tests with browser_type "%s".' %
+ browser_type)
+ ret = _RunOneSetOfTests(browser_type, 'telemetry',
+ os.path.join('telemetry', 'telemetry'),
+ unit_tests, stream)
+ if ret:
+ error_string += 'The unit tests failed.\n'
+
+ logging.info('Running telemetry perf tests with browser_type "%s".' %
+ browser_type)
+ ret = _RunOneSetOfTests(browser_type, 'perf', 'perf', perf_tests, stream)
+ if ret:
+ error_string = 'The perf tests failed.\n'
+
+ return error_string
+
+
+def _RunOneSetOfTests(browser_type, root_dir, sub_dir, tests, stream):
+ top_level_dir = os.path.join(util.GetChromiumSrcDir(), 'tools', root_dir)
achuithb 2014/10/28 01:43:31 I think this should work, but not sure. Besides t
+ sub_dir = os.path.join(util.GetChromiumSrcDir(), 'tools', sub_dir)
+
+ sys.path.append(top_level_dir)
+
+ output_formatters = [gtest_progress_reporter.GTestProgressReporter(stream)]
+ run_tests.config = run_tests.Config(top_level_dir, [sub_dir],
+ output_formatters)
+ return run_tests.RunTestsCommand.main(['--browser', browser_type] + tests)
+
+
+class _LoggingOutputStream(object):
+
+ def __init__(self):
+ self._buffer = []
+
+ def write(self, s):
+ """Buffer a string write. Log it when we encounter a newline."""
+ if '\n' in s:
+ segments = s.split('\n')
+ segments[0] = ''.join(self._buffer + [segments[0]])
+ log_level = logging.getLogger().getEffectiveLevel()
+ try: # TODO(dtu): We need this because of crbug.com/394571
+ logging.getLogger().setLevel(logging.INFO)
+ for line in segments[:-1]:
+ logging.info(line)
+ finally:
+ logging.getLogger().setLevel(log_level)
+ self._buffer = [segments[-1]]
+ else:
+ self._buffer.append(s)
+
+ def flush(self): # pylint: disable=W0612
+ pass
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698