Chromium Code Reviews| 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 re | 7 import re |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 import cmd_helper | 10 import cmd_helper |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 device: Device to run the tests. | 22 device: Device to run the tests. |
| 23 test_suite: A specific test suite to run, empty to run all. | 23 test_suite: A specific test suite to run, empty to run all. |
| 24 timeout: Timeout for each test. | 24 timeout: Timeout for each test. |
| 25 rebaseline: Whether or not to run tests in isolation and update the filter. | 25 rebaseline: Whether or not to run tests in isolation and update the filter. |
| 26 performance_test: Whether or not performance test(s). | 26 performance_test: Whether or not performance test(s). |
| 27 cleanup_test_files: Whether or not to cleanup test files on device. | 27 cleanup_test_files: Whether or not to cleanup test files on device. |
| 28 tool: Name of the Valgrind tool. | 28 tool: Name of the Valgrind tool. |
| 29 dump_debug_info: A debug_info object. | 29 dump_debug_info: A debug_info object. |
| 30 """ | 30 """ |
| 31 | 31 |
| 32 APK_DATA_DIR = '/data/user/0/org.chromium.native_test/files/' | |
| 33 | |
| 34 def __init__(self, adb, device, test_suite, timeout, rebaseline, | 32 def __init__(self, adb, device, test_suite, timeout, rebaseline, |
| 35 performance_test, cleanup_test_files, tool, | 33 performance_test, cleanup_test_files, tool, |
| 36 dump_debug_info): | 34 dump_debug_info): |
| 37 TestPackage.__init__(self, adb, device, test_suite, timeout, | 35 TestPackage.__init__(self, adb, device, test_suite, timeout, |
| 38 rebaseline, performance_test, cleanup_test_files, | 36 rebaseline, performance_test, cleanup_test_files, |
| 39 tool, dump_debug_info) | 37 tool, dump_debug_info) |
| 40 | 38 |
| 41 def _CreateTestRunnerScript(self, options): | 39 def _CreateTestRunnerScript(self, options): |
| 42 command_line_file = tempfile.NamedTemporaryFile() | 40 command_line_file = tempfile.NamedTemporaryFile() |
| 43 # GTest expects argv[0] to be the executable path. | 41 # GTest expects argv[0] to be the executable path. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 62 'am start -n ' | 60 'am start -n ' |
| 63 'org.chromium.native_test/' | 61 'org.chromium.native_test/' |
| 64 'org.chromium.native_test.ChromeNativeTestActivity') | 62 'org.chromium.native_test.ChromeNativeTestActivity') |
| 65 # Wait for native test to complete. | 63 # Wait for native test to complete. |
| 66 self.adb.WaitForLogMatch(re.compile('<<nativeRunTests'), None) | 64 self.adb.WaitForLogMatch(re.compile('<<nativeRunTests'), None) |
| 67 finally: | 65 finally: |
| 68 self.tool.CleanUpEnvironment() | 66 self.tool.CleanUpEnvironment() |
| 69 # Copy stdout.txt and read contents. | 67 # Copy stdout.txt and read contents. |
| 70 stdout_file = tempfile.NamedTemporaryFile() | 68 stdout_file = tempfile.NamedTemporaryFile() |
| 71 ret = [] | 69 ret = [] |
| 72 self.adb.Adb().Pull(TestPackageApk.APK_DATA_DIR + 'stdout.txt', | 70 self.adb.Adb().Pull('/sdcard/native_tests/stdout.txt', stdout_file.name) |
|
John Grabowski
2012/07/18 20:40:49
Prefer string const higher in the class (like befo
bulach
2012/07/19 08:14:33
Done.
| |
| 73 stdout_file.name) | |
| 74 # We need to strip the trailing newline. | 71 # We need to strip the trailing newline. |
| 75 content = [line.rstrip() for line in open(stdout_file.name)] | 72 content = [line.rstrip() for line in open(stdout_file.name)] |
| 76 ret = self._ParseGTestListTests(content) | 73 ret = self._ParseGTestListTests(content) |
| 77 return ret | 74 return ret |
| 78 | 75 |
| 79 def CreateTestRunnerScript(self, gtest_filter, test_arguments): | 76 def CreateTestRunnerScript(self, gtest_filter, test_arguments): |
| 80 self._CreateTestRunnerScript('--gtest_filter=%s %s' % (gtest_filter, | 77 self._CreateTestRunnerScript('--gtest_filter=%s %s' % (gtest_filter, |
| 81 test_arguments)) | 78 test_arguments)) |
| 82 | 79 |
| 83 def RunTestsAndListResults(self): | 80 def RunTestsAndListResults(self): |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 100 timeout_time=60*5) | 97 timeout_time=60*5) |
| 101 logging.info('Installing new apk') | 98 logging.info('Installing new apk') |
| 102 self.adb.Adb().SendCommand('install -r ' + self.test_suite_full, | 99 self.adb.Adb().SendCommand('install -r ' + self.test_suite_full, |
| 103 timeout_time=60*5) | 100 timeout_time=60*5) |
| 104 logging.info('Install has completed.') | 101 logging.info('Install has completed.') |
| 105 | 102 |
| 106 def _GetTestSuiteBaseName(self): | 103 def _GetTestSuiteBaseName(self): |
| 107 """Returns the base name of the test suite.""" | 104 """Returns the base name of the test suite.""" |
| 108 # APK test suite names end with '-debug.apk' | 105 # APK test suite names end with '-debug.apk' |
| 109 return os.path.basename(self.test_suite).rsplit('-debug', 1)[0] | 106 return os.path.basename(self.test_suite).rsplit('-debug', 1)[0] |
| OLD | NEW |