OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import copy | 5 import copy |
6 import fnmatch | 6 import fnmatch |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 | 9 |
10 from pylib import android_commands | 10 from pylib import android_commands |
(...skipping 15 matching lines...) Expand all Loading... |
26 exe: if True, use the executable-based test runner. | 26 exe: if True, use the executable-based test runner. |
27 option_test_suite: the test_suite specified as an option. | 27 option_test_suite: the test_suite specified as an option. |
28 build_type: 'Release' or 'Debug'. | 28 build_type: 'Release' or 'Debug'. |
29 | 29 |
30 Returns: | 30 Returns: |
31 A list of tuples containing the suite and absolute path. | 31 A list of tuples containing the suite and absolute path. |
32 Ex. ('content_unittests', | 32 Ex. ('content_unittests', |
33 '/tmp/chrome/src/out/Debug/content_unittests_apk/' | 33 '/tmp/chrome/src/out/Debug/content_unittests_apk/' |
34 'content_unittests-debug.apk') | 34 'content_unittests-debug.apk') |
35 """ | 35 """ |
| 36 def GetQualifiedSuite(suite): |
| 37 if suite.is_suite_exe: |
| 38 relpath = suite.name |
| 39 else: |
| 40 # out/(Debug|Release)/$SUITE_apk/$SUITE-debug.apk |
| 41 relpath = os.path.join(suite.name + '_apk', suite.name + '-debug.apk') |
| 42 return suite.name, os.path.join(test_suite_dir, relpath) |
| 43 |
36 test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type) | 44 test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), build_type) |
37 if option_test_suite: | 45 if option_test_suite: |
38 all_test_suites = [option_test_suite] | 46 all_test_suites = [gtest_config.Suite(exe, option_test_suite)] |
39 else: | 47 else: |
40 all_test_suites = gtest_config.STABLE_TEST_SUITES | 48 all_test_suites = gtest_config.STABLE_TEST_SUITES |
41 | 49 |
42 if exe: | 50 # List of tuples (suite_name, suite_path) |
43 qualified_test_suites = [os.path.join(test_suite_dir, t) | 51 qualified_test_suites = map(GetQualifiedSuite, all_test_suites) |
44 for t in all_test_suites] | 52 |
45 else: | 53 for t, q in qualified_test_suites: |
46 # out/(Debug|Release)/$SUITE_apk/$SUITE-debug.apk | |
47 qualified_test_suites = [os.path.join(test_suite_dir, | |
48 t + '_apk', | |
49 t + '-debug.apk') | |
50 for t in all_test_suites] | |
51 for t, q in zip(all_test_suites, qualified_test_suites): | |
52 if not os.path.exists(q): | 54 if not os.path.exists(q): |
53 raise Exception('Test suite %s not found in %s.\n' | 55 raise Exception('Test suite %s not found in %s.\n' |
54 'Supported test suites:\n %s\n' | 56 'Supported test suites:\n %s\n' |
55 'Ensure it has been built.\n' % | 57 'Ensure it has been built.\n' % |
56 (t, q, gtest_config.STABLE_TEST_SUITES)) | 58 (t, q, gtest_config.STABLE_TEST_SUITES)) |
57 return zip(all_test_suites, qualified_test_suites) | 59 return qualified_test_suites |
58 | 60 |
59 | 61 |
60 def GetTestsFromDevice(runner): | 62 def GetTestsFromDevice(runner): |
61 """Get a list of tests from a device, excluding disabled tests. | 63 """Get a list of tests from a device, excluding disabled tests. |
62 | 64 |
63 Args: | 65 Args: |
64 runner: a TestRunner. | 66 runner: a TestRunner. |
65 """ | 67 """ |
66 # The executable/apk needs to be copied before we can call GetAllTests. | 68 # The executable/apk needs to be copied before we can call GetAllTests. |
67 runner.test_package.StripAndCopyExecutable() | 69 runner.test_package.StripAndCopyExecutable() |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 failures = 0 | 210 failures = 0 |
209 for suite_name, suite_path in all_test_suites: | 211 for suite_name, suite_path in all_test_suites: |
210 # Give each test suite its own copy of options. | 212 # Give each test suite its own copy of options. |
211 test_options = copy.deepcopy(options) | 213 test_options = copy.deepcopy(options) |
212 test_options.test_suite = suite_path | 214 test_options.test_suite = suite_path |
213 failures += _RunATestSuite(test_options, suite_name) | 215 failures += _RunATestSuite(test_options, suite_name) |
214 | 216 |
215 if options.use_xvfb: | 217 if options.use_xvfb: |
216 framebuffer.Stop() | 218 framebuffer.Stop() |
217 return failures | 219 return failures |
OLD | NEW |