OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Runs all the native unit tests. | 7 """Runs all the native unit tests. |
8 | 8 |
9 1. Copy over test binary to /data/local on device. | 9 1. Copy over test binary to /data/local on device. |
frankf
2013/06/11 02:50:15
This doc is pretty out-dated. Let's get rid of it.
gkanwar
2013/06/12 01:27:32
Done.
| |
10 2. Resources: chrome/unit_tests requires resources (chrome.pak and en-US.pak) | 10 2. Resources: chrome/unit_tests requires resources (chrome.pak and en-US.pak) |
11 to be deployed to the device. We use the device's $EXTERNAL_STORAGE as the | 11 to be deployed to the device. We use the device's $EXTERNAL_STORAGE as the |
12 base dir (which maps to Context.getExternalFilesDir()). | 12 base dir (which maps to Context.getExternalFilesDir()). |
13 3. Environment: | 13 3. Environment: |
14 3.1. chrome/unit_tests requires (via chrome_paths.cc) a directory named: | 14 3.1. chrome/unit_tests requires (via chrome_paths.cc) a directory named: |
15 $EXTERNAL_STORAGE + /chrome/test/data | 15 $EXTERNAL_STORAGE + /chrome/test/data |
16 4. Run the binary in the device and stream the log to the host. | 16 4. Run the binary in the device and stream the log to the host. |
17 4.1. Optionally, filter specific tests. | 17 4.1. Optionally, filter specific tests. |
18 4.2. If we're running a single test suite and we have multiple devices | 18 4.2. If we're running a single test suite and we have multiple devices |
19 connected, we'll shard the tests. | 19 connected, we'll shard the tests. |
20 5. Clean up the device. | 20 5. Clean up the device. |
21 | 21 |
22 Suppressions: | 22 Suppressions: |
23 | 23 |
24 Individual tests in a test binary can be suppressed by listing it in | 24 Individual tests in a test binary can be suppressed by listing it in |
25 the gtest_filter directory in a file of the same name as the test binary, | 25 the gtest_filter directory in a file of the same name as the test binary, |
26 one test per line. Here is an example: | 26 one test per line. Here is an example: |
27 | 27 |
28 $ cat gtest_filter/base_unittests_disabled | 28 $ cat gtest_filter/base_unittests_disabled |
29 DataPackTest.Load | 29 DataPackTest.Load |
30 ReadOnlyFileUtilTest.ContentsEqual | 30 ReadOnlyFileUtilTest.ContentsEqual |
31 | 31 |
32 This file is generated by the tests running on devices. If running on emulator, | 32 This file is generated by the tests running on devices. If running on emulator, |
33 additonal filter file which lists the tests only failed in emulator will be | 33 additonal filter file which lists the tests only failed in emulator will be |
34 loaded. We don't care about the rare testcases which succeeded on emuatlor, but | 34 loaded. We don't care about the rare testcases which succeeded on emulator, but |
35 failed on device. | 35 failed on device. |
36 """ | 36 """ |
37 | 37 |
38 import optparse | 38 import subprocess |
39 import sys | 39 import sys |
40 | 40 |
41 from pylib import cmd_helper | |
42 from pylib.gtest import dispatch | |
43 from pylib.utils import emulator | |
44 from pylib.utils import run_tests_helper | |
45 from pylib.utils import test_options_parser | |
46 | |
47 | |
48 def main(argv): | |
49 option_parser = optparse.OptionParser() | |
50 test_options_parser.AddGTestOptions(option_parser) | |
51 options, args = option_parser.parse_args(argv) | |
52 | |
53 if len(args) > 1: | |
54 option_parser.error('Unknown argument: %s' % args[1:]) | |
55 | |
56 run_tests_helper.SetLogLevel(options.verbose_count) | |
57 | |
58 if options.out_directory: | |
59 cmd_helper.OutDirectory.set(options.out_directory) | |
60 | |
61 if options.use_emulator: | |
62 emulator.DeleteAllTempAVDs() | |
63 | |
64 failed_tests_count = dispatch.Dispatch(options) | |
65 | |
66 # Failures of individual test suites are communicated by printing a | |
67 # STEP_FAILURE message. | |
68 # Returning a success exit status also prevents the buildbot from incorrectly | |
69 # marking the last suite as failed if there were failures in other suites in | |
70 # the batch (this happens because the exit status is a sum of all failures | |
71 # from all suites, but the buildbot associates the exit status only with the | |
72 # most recent step). | |
73 if options.exit_code: | |
74 return failed_tests_count | |
75 return 0 | |
76 | |
77 | |
78 if __name__ == '__main__': | 41 if __name__ == '__main__': |
79 sys.exit(main(sys.argv)) | 42 args = ["./run_all_tests.py", "--gtest"] + sys.argv[1:] |
43 sys.exit(subprocess.call(args)) | |
OLD | NEW |