Index: client/bin/site_chrome_test.py |
diff --git a/client/bin/site_chrome_test.py b/client/bin/site_chrome_test.py |
index 4c84d698b95e9ced37ea97c02d4a4d6082c79a5e..38c0354505b4222e319f37c9876b4bc934ee2f13 100644 |
--- a/client/bin/site_chrome_test.py |
+++ b/client/bin/site_chrome_test.py |
@@ -2,35 +2,63 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
-import logging, os, shutil, tempfile, utils |
+import logging, os, shutil, subprocess, tempfile, utils |
from autotest_lib.client.bin import test |
from autotest_lib.client.common_lib import error, site_ui |
class ChromeTestBase(test.test): |
home_dir = None |
+ dep_dir = '/usr/local/chrome' |
def setup(self): |
- self.job.setup_dep(['chrome_test']) |
ericli
2010/11/05 21:40:30
why you want to remove this? I am not sure if it w
Chris Masone
2010/11/09 23:08:24
I undid that now
|
- # create a empty srcdir to prevent the error that checks .version file |
if not os.path.exists(self.srcdir): |
os.mkdir(self.srcdir) |
- def run_chrome_test(self, test_to_run, extra_params = ''): |
- dep = 'chrome_test' |
- dep_dir = os.path.join(self.autodir, 'deps', dep) |
- self.job.install_pkg(dep, 'dep', dep_dir) |
- |
- chrome_dir = '/opt/google/chrome' |
- cr_source_dir = '%s/test_src' % dep_dir |
- test_binary_dir = '%s/test_src/out/Release' % dep_dir |
+ def initialize(self): |
self.home_dir = tempfile.mkdtemp() |
+ |
+ def _generate_prefix(self): |
+ chrome_dir = '/opt/google/chrome' |
+ test_binary_dir = '%s/out/Release' % self.dep_dir |
try: |
setup_cmd = '%s/%s' % (test_binary_dir, |
- 'setup_test_links.sh') |
- utils.system(setup_cmd) |
+ 'setup_test_links.sh') |
+ utils.system(setup_cmd) # this might raise an exception |
+ except error.CmdError, e: |
+ raise error.TestError(e) |
+ return (self.dep_dir, test_binary_dir) |
+ |
+ |
+ def list_chrome_tests(self, test_binary): |
+ cr_source_dir,test_binary_dir = self._generate_prefix() |
+ all_tests = [] |
+ try: |
+ cmd = '%s/%s --gtest_list_tests' % (test_binary_dir, test_binary) |
+ cmd = 'HOME=%s CR_SOURCE_ROOT=%s %s' % (self.home_dir, |
+ cr_source_dir, |
+ site_ui.xcommand(cmd)) |
+ logging.debug("Running %s" % cmd) |
+ test_proc = subprocess.Popen(cmd, |
+ shell=True, |
+ stdout=subprocess.PIPE) |
+ last_suite = None |
+ for line in test_proc.stdout: |
+ stripped = line.lstrip() |
+ if (stripped == line): |
+ last_suite = stripped.rstrip() |
+ else: |
+ all_tests.append(last_suite+stripped.rstrip()) |
+ except OSError, e: |
+ logging.debug(e) |
+ raise error.TestFail('Failed to list tests in %s!' % test_binary) |
+ return all_tests |
+ |
+ def run_chrome_test(self, test_to_run, extra_params = ''): |
+ cr_source_dir,test_binary_dir = self._generate_prefix() |
+ try: |
cmd = '%s/%s %s' % (test_binary_dir, test_to_run, extra_params) |
cmd = 'HOME=%s CR_SOURCE_ROOT=%s %s' % (self.home_dir, |
cr_source_dir, |