OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Class for running instrumentation tests on a single device.""" | 5 """Class for running instrumentation tests on a single device.""" |
6 | 6 |
7 import collections | 7 import collections |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import re | 10 import re |
11 import sys | |
12 import time | 11 import time |
13 | 12 |
14 from devil.android import device_errors | 13 from devil.android import device_errors |
15 from pylib import constants | 14 from pylib import constants |
16 from pylib import flag_changer | 15 from pylib import flag_changer |
17 from pylib import valgrind_tools | 16 from pylib import valgrind_tools |
18 from pylib.base import base_test_result | 17 from pylib.base import base_test_result |
19 from pylib.base import base_test_runner | 18 from pylib.base import base_test_runner |
| 19 from pylib.constants import host_paths |
20 from pylib.instrumentation import instrumentation_test_instance | 20 from pylib.instrumentation import instrumentation_test_instance |
21 from pylib.instrumentation import json_perf_parser | 21 from pylib.instrumentation import json_perf_parser |
22 from pylib.instrumentation import test_result | 22 from pylib.instrumentation import test_result |
23 from pylib.local.device import local_device_instrumentation_test_run | 23 from pylib.local.device import local_device_instrumentation_test_run |
24 | 24 |
25 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', | 25 with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): |
26 'common')) | 26 import perf_tests_results_helper # pylint: disable=import-error |
27 import perf_tests_results_helper # pylint: disable=F0401 | |
28 | 27 |
29 | 28 |
30 _PERF_TEST_ANNOTATION = 'PerfTest' | 29 _PERF_TEST_ANNOTATION = 'PerfTest' |
31 | 30 |
32 | 31 |
33 class TestRunner(base_test_runner.BaseTestRunner): | 32 class TestRunner(base_test_runner.BaseTestRunner): |
34 """Responsible for running a series of tests connected to a single device.""" | 33 """Responsible for running a series of tests connected to a single device.""" |
35 | 34 |
36 _DEVICE_COVERAGE_DIR = 'chrome/test/coverage' | 35 _DEVICE_COVERAGE_DIR = 'chrome/test/coverage' |
37 _HOSTMACHINE_PERF_OUTPUT_FILE = '/tmp/chrome-profile' | 36 _HOSTMACHINE_PERF_OUTPUT_FILE = '/tmp/chrome-profile' |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 else: | 101 else: |
103 if self.device.SetJavaAsserts(self.options.set_asserts): | 102 if self.device.SetJavaAsserts(self.options.set_asserts): |
104 self.device.RunShellCommand('stop') | 103 self.device.RunShellCommand('stop') |
105 self.device.RunShellCommand('start') | 104 self.device.RunShellCommand('start') |
106 self.device.WaitUntilFullyBooted() | 105 self.device.WaitUntilFullyBooted() |
107 | 106 |
108 # We give different default value to launch HTTP server based on shard index | 107 # We give different default value to launch HTTP server based on shard index |
109 # because it may have race condition when multiple processes are trying to | 108 # because it may have race condition when multiple processes are trying to |
110 # launch lighttpd with same port at same time. | 109 # launch lighttpd with same port at same time. |
111 self.LaunchTestHttpServer( | 110 self.LaunchTestHttpServer( |
112 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) | 111 os.path.join(host_paths.DIR_SOURCE_ROOT), self._lighttp_port) |
113 if self.flags: | 112 if self.flags: |
114 flags_to_add = ['--disable-fre', '--enable-test-intents'] | 113 flags_to_add = ['--disable-fre', '--enable-test-intents'] |
115 if self.options.device_flags: | 114 if self.options.device_flags: |
116 with open(self.options.device_flags) as device_flags_file: | 115 with open(self.options.device_flags) as device_flags_file: |
117 stripped_flags = (l.strip() for l in device_flags_file) | 116 stripped_flags = (l.strip() for l in device_flags_file) |
118 flags_to_add.extend([flag for flag in stripped_flags if flag]) | 117 flags_to_add.extend([flag for flag in stripped_flags if flag]) |
119 self.flags.AddFlags(flags_to_add) | 118 self.flags.AddFlags(flags_to_add) |
120 | 119 |
121 def TearDown(self): | 120 def TearDown(self): |
122 """Cleans up the test harness and saves outstanding data from test run.""" | 121 """Cleans up the test harness and saves outstanding data from test run.""" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 result_name, ' '.join(flag_modifiers.add)) | 410 result_name, ' '.join(flag_modifiers.add)) |
412 if flag_modifiers.remove: | 411 if flag_modifiers.remove: |
413 result_name = '%s without {%s}' % ( | 412 result_name = '%s without {%s}' % ( |
414 result_name, ' '.join(flag_modifiers.remove)) | 413 result_name, ' '.join(flag_modifiers.remove)) |
415 result.SetName(result_name) | 414 result.SetName(result_name) |
416 results.AddResult(result) | 415 results.AddResult(result) |
417 | 416 |
418 self.TestTeardown(test, results) | 417 self.TestTeardown(test, results) |
419 | 418 |
420 return (results, None if results.DidRunPass() else test) | 419 return (results, None if results.DidRunPass() else test) |
OLD | NEW |