Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: build/android/pylib/local/device/local_device_test_run.py

Issue 788753002: [Android] Implement gtest and local in platform mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix findbugs + move log parsing up to GtestTestInstance Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5
6 from pylib import valgrind_tools
7 from pylib.base import base_test_result
8 from pylib.base import test_run
9 from pylib.base import test_collection
10
11
12 class LocalDeviceTestRun(test_run.TestRun):
13
14 def __init__(self, env, test_instance):
15 super(LocalDeviceTestRun, self).__init__(env, test_instance)
16 self._tools = {}
17
18 #override
19 def RunTests(self):
20 tests = self._GetTests()
21
22 def run_tests_on_device(dev, tests):
23 r = base_test_result.TestRunResults()
24 for test in tests:
25 result = self._RunTest(dev, test)
26 if isinstance(result, base_test_result.BaseTestResult):
27 r.AddResult(result)
28 elif isinstance(result, list):
29 r.AddResults(result)
30 else:
31 raise Exception('Unexpected result type: %s' % type(result).__name__)
32 if isinstance(tests, test_collection.TestCollection):
33 tests.test_completed()
34 return r
35
36 tries = 0
37 results = base_test_result.TestRunResults()
38 fail_results = []
39 while tries < self._env.max_tries and tests:
40 if self._ShouldShard():
41 tc = test_collection.TestCollection(self._CreateShards(tests))
42 try_results = self._env.parallel_devices.pMap(
43 run_tests_on_device, tc).pGet(None)
44 else:
45 try_results = self._env.parallel_devices.pMap(
46 run_tests_on_device, tests).pGet(None)
47 fail_results = []
48 for try_result in try_results:
49 for result in try_result.GetAll():
50 if result.GetType() in (base_test_result.ResultType.PASS,
51 base_test_result.ResultType.SKIP):
52 results.AddResult(result)
53 else:
54 fail_results.append(result)
55
56 results_names = set(r.GetName() for r in results.GetAll())
57 tests = [t for t in tests if t not in results_names]
58 tries += 1
59
60 if tests:
61 results.AddResults(
62 base_test_result.BaseTestResult(
63 t, base_test_result.ResultType.UNKNOWN)
64 for t in tests)
65 if fail_results:
66 results.AddResults(fail_results)
67 return results
68
69 def GetTool(self, device):
70 if not str(device) in self._tools:
71 self._tools[str(device)] = valgrind_tools.CreateTool(
72 self._env.tool, device)
73 return self._tools[str(device)]
74
75 def _CreateShards(self, tests):
76 raise NotImplementedError
77
78 def _GetTests(self):
79 raise NotImplementedError
80
81 def _RunTest(self, device, test):
82 raise NotImplementedError
83
84 def _ShouldShard(self):
85 raise NotImplementedError
OLDNEW
« no previous file with comments | « build/android/pylib/local/device/local_device_environment.py ('k') | chrome/test/android/unit_tests_apk/AndroidManifest.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698