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 | 5 |
6 import os | 6 import os |
7 import shlex | 7 import shlex |
8 import sys | 8 import sys |
9 import tempfile | 9 import tempfile |
10 import time | 10 import time |
11 | 11 |
12 import android_commands | 12 import android_commands |
13 import constants | 13 import constants |
14 from android_commands import errors | 14 from android_commands import errors |
15 from test_package import TestPackage | 15 from test_package import TestPackage |
16 from pylib import pexpect | 16 from pylib import pexpect |
17 | 17 |
18 class TestPackageApk(TestPackage): | 18 class TestPackageApk(TestPackage): |
19 """A helper class for running APK-based native tests. | 19 """A helper class for running APK-based native tests. |
20 | 20 |
21 Args: | 21 Args: |
22 adb: ADB interface the tests are using. | 22 adb: ADB interface the tests are using. |
23 device: Device to run the tests. | 23 device: Device to run the tests. |
24 test_suite: A specific test suite to run, empty to run all. | 24 test_suite: A specific test suite to run, empty to run all. |
25 timeout: Timeout for each test. | 25 timeout: Timeout for each test. |
26 performance_test: Whether or not performance test(s). | |
27 cleanup_test_files: Whether or not to cleanup test files on device. | 26 cleanup_test_files: Whether or not to cleanup test files on device. |
28 tool: Name of the Valgrind tool. | 27 tool: Name of the Valgrind tool. |
29 dump_debug_info: A debug_info object. | 28 dump_debug_info: A debug_info object. |
30 """ | 29 """ |
31 | 30 |
32 def __init__(self, adb, device, test_suite, timeout, | 31 def __init__(self, adb, device, test_suite, timeout, |
33 performance_test, cleanup_test_files, tool, | 32 cleanup_test_files, tool, dump_debug_info): |
34 dump_debug_info): | |
35 TestPackage.__init__(self, adb, device, test_suite, timeout, | 33 TestPackage.__init__(self, adb, device, test_suite, timeout, |
36 performance_test, cleanup_test_files, | 34 cleanup_test_files, tool, dump_debug_info) |
37 tool, dump_debug_info) | |
38 | 35 |
39 def _CreateTestRunnerScript(self, options): | 36 def _CreateTestRunnerScript(self, options): |
40 command_line_file = tempfile.NamedTemporaryFile() | 37 command_line_file = tempfile.NamedTemporaryFile() |
41 # GTest expects argv[0] to be the executable path. | 38 # GTest expects argv[0] to be the executable path. |
42 command_line_file.write(self.test_suite_basename + ' ' + options) | 39 command_line_file.write(self.test_suite_basename + ' ' + options) |
43 command_line_file.flush() | 40 command_line_file.flush() |
44 self.adb.PushIfNeeded(command_line_file.name, | 41 self.adb.PushIfNeeded(command_line_file.name, |
45 constants.TEST_EXECUTABLE_DIR + | 42 constants.TEST_EXECUTABLE_DIR + |
46 '/chrome-native-tests-command-line') | 43 '/chrome-native-tests-command-line') |
47 | 44 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 self.tool.CopyFiles() | 111 self.tool.CopyFiles() |
115 # Always uninstall the previous one (by activity name); we don't | 112 # Always uninstall the previous one (by activity name); we don't |
116 # know what was embedded in it. | 113 # know what was embedded in it. |
117 self.adb.ManagedInstall(self.test_suite_full, False, | 114 self.adb.ManagedInstall(self.test_suite_full, False, |
118 package_name='org.chromium.native_test') | 115 package_name='org.chromium.native_test') |
119 | 116 |
120 def _GetTestSuiteBaseName(self): | 117 def _GetTestSuiteBaseName(self): |
121 """Returns the base name of the test suite.""" | 118 """Returns the base name of the test suite.""" |
122 # APK test suite names end with '-debug.apk' | 119 # APK test suite names end with '-debug.apk' |
123 return os.path.basename(self.test_suite).rsplit('-debug', 1)[0] | 120 return os.path.basename(self.test_suite).rsplit('-debug', 1)[0] |
OLD | NEW |