Chromium Code Reviews

Side by Side Diff: build/android/pylib/gtest/test_runner.py

Issue 1222313015: Manual partial update from from https://crrev.com/337502 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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 import logging 5 import logging
6 import os 6 import os
7 import re 7 import re
8 import tempfile
8 9
9 from pylib import pexpect 10 from pylib import pexpect
10 from pylib import ports 11 from pylib import ports
11 from pylib.base import base_test_result 12 from pylib.base import base_test_result
12 from pylib.base import base_test_runner 13 from pylib.base import base_test_runner
13 from pylib.device import device_errors 14 from pylib.device import device_errors
14 from pylib.gtest import gtest_test_instance 15 from pylib.gtest import gtest_test_instance
15 from pylib.local import local_test_server_spawner 16 from pylib.local import local_test_server_spawner
16 from pylib.perf import perf_control 17 from pylib.perf import perf_control
17 18
(...skipping 55 matching lines...)
73 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name): 74 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name):
74 self._perf_controller = perf_control.PerfControl(self.device) 75 self._perf_controller = perf_control.PerfControl(self.device)
75 76
76 if _TestSuiteRequiresMockTestServer(self.test_package.suite_name): 77 if _TestSuiteRequiresMockTestServer(self.test_package.suite_name):
77 self._servers = [ 78 self._servers = [
78 local_test_server_spawner.LocalTestServerSpawner( 79 local_test_server_spawner.LocalTestServerSpawner(
79 ports.AllocateTestServerPort(), self.device, self.tool)] 80 ports.AllocateTestServerPort(), self.device, self.tool)]
80 else: 81 else:
81 self._servers = [] 82 self._servers = []
82 83
84 if test_options.app_data_files:
85 self._app_data_files = test_options.app_data_files
86 if test_options.app_data_file_dir:
87 self._app_data_file_dir = test_options.app_data_file_dir
88 else:
89 self._app_data_file_dir = tempfile.mkdtemp()
90 logging.critical('Saving app files to %s', self._app_data_file_dir)
91 else:
92 self._app_data_files = None
93 self._app_data_file_dir = None
94
83 #override 95 #override
84 def InstallTestPackage(self): 96 def InstallTestPackage(self):
85 self.test_package.Install(self.device) 97 self.test_package.Install(self.device)
86 98
87 def _ParseTestOutput(self, p): 99 def _ParseTestOutput(self, p):
88 """Process the test output. 100 """Process the test output.
89 101
90 Args: 102 Args:
91 p: An instance of pexpect spawn class. 103 p: An instance of pexpect spawn class.
92 104
(...skipping 67 matching lines...)
160 test_results = base_test_result.TestRunResults() 172 test_results = base_test_result.TestRunResults()
161 if not test: 173 if not test:
162 return test_results, None 174 return test_results, None
163 175
164 try: 176 try:
165 self.test_package.ClearApplicationState(self.device) 177 self.test_package.ClearApplicationState(self.device)
166 self.test_package.CreateCommandLineFileOnDevice( 178 self.test_package.CreateCommandLineFileOnDevice(
167 self.device, test, self._test_arguments) 179 self.device, test, self._test_arguments)
168 test_results = self._ParseTestOutput( 180 test_results = self._ParseTestOutput(
169 self.test_package.SpawnTestProcess(self.device)) 181 self.test_package.SpawnTestProcess(self.device))
182 if self._app_data_files:
183 self.test_package.PullAppFiles(self.device, self._app_data_files,
184 self._app_data_file_dir)
170 finally: 185 finally:
171 for s in self._servers: 186 for s in self._servers:
172 s.Reset() 187 s.Reset()
173 # Calculate unknown test results. 188 # Calculate unknown test results.
174 all_tests = set(test.split(':')) 189 all_tests = set(test.split(':'))
175 all_tests_ran = set([t.GetName() for t in test_results.GetAll()]) 190 all_tests_ran = set([t.GetName() for t in test_results.GetAll()])
176 unknown_tests = all_tests - all_tests_ran 191 unknown_tests = all_tests - all_tests_ran
177 test_results.AddResults( 192 test_results.AddResults(
178 [base_test_result.BaseTestResult(t, base_test_result.ResultType.UNKNOWN) 193 [base_test_result.BaseTestResult(t, base_test_result.ResultType.UNKNOWN)
179 for t in unknown_tests]) 194 for t in unknown_tests])
(...skipping 13 matching lines...)
193 #override 208 #override
194 def TearDown(self): 209 def TearDown(self):
195 """Cleans up the test enviroment for the test suite.""" 210 """Cleans up the test enviroment for the test suite."""
196 for s in self._servers: 211 for s in self._servers:
197 s.TearDown() 212 s.TearDown()
198 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name): 213 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name):
199 self._perf_controller.SetDefaultPerfMode() 214 self._perf_controller.SetDefaultPerfMode()
200 self.test_package.ClearApplicationState(self.device) 215 self.test_package.ClearApplicationState(self.device)
201 self.tool.CleanUpEnvironment() 216 self.tool.CleanUpEnvironment()
202 super(TestRunner, self).TearDown() 217 super(TestRunner, self).TearDown()
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/test_package_exe.py ('k') | build/android/pylib/instrumentation/test_jar.py » ('j') | no next file with comments »

Powered by Google App Engine