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

Side by Side Diff: build/android/pylib/instrumentation/instrumentation_test_instance.py

Issue 832493005: Add Instrumentation test support to remote device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 pickle 7 import pickle
8 import re
8 import sys 9 import sys
9 10
10 from pylib import cmd_helper 11 from pylib import cmd_helper
11 from pylib import constants 12 from pylib import constants
12 from pylib import flag_changer 13 from pylib import flag_changer
13 from pylib.base import base_test_result 14 from pylib.base import base_test_result
14 from pylib.base import test_instance 15 from pylib.base import test_instance
15 from pylib.instrumentation import test_result 16 from pylib.instrumentation import test_result
16 from pylib.utils import apk_helper 17 from pylib.utils import apk_helper
17 from pylib.utils import md5sum 18 from pylib.utils import md5sum
18 from pylib.utils import proguard 19 from pylib.utils import proguard
19 20
20 sys.path.append( 21 sys.path.append(
21 os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', 'common')) 22 os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'util', 'lib', 'common'))
22 import unittest_util 23 import unittest_util
23 24
24 _DEFAULT_ANNOTATIONS = [ 25 _DEFAULT_ANNOTATIONS = [
25 'Smoke', 'SmallTest', 'MediumTest', 'LargeTest', 26 'Smoke', 'SmallTest', 'MediumTest', 'LargeTest',
26 'EnormousTest', 'IntegrationTest'] 27 'EnormousTest', 'IntegrationTest']
28 _NATIVE_CRASH_RE = re.compile('native crash', re.IGNORECASE)
27 _PICKLE_FORMAT_VERSION = 10 29 _PICKLE_FORMAT_VERSION = 10
28 30
29 31
30 # TODO(jbudorick): Make these private class methods of 32 # TODO(jbudorick): Make these private class methods of
31 # InstrumentationTestInstance once the instrumentation test_runner is 33 # InstrumentationTestInstance once the instrumentation test_runner is
32 # deprecated. 34 # deprecated.
33 def ParseAmInstrumentRawOutput(raw_output): 35 def ParseAmInstrumentRawOutput(raw_output):
34 """Parses the output of an |am instrument -r| call. 36 """Parses the output of an |am instrument -r| call.
35 37
36 Args: 38 Args:
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 if hasattr(args, 'device_flags') and args.device_flags: 265 if hasattr(args, 'device_flags') and args.device_flags:
264 with open(args.device_flags) as device_flags_file: 266 with open(args.device_flags) as device_flags_file:
265 stripped_lines = (l.strip() for l in device_flags_file) 267 stripped_lines = (l.strip() for l in device_flags_file)
266 self._flags.extend([flag for flag in stripped_lines if flag]) 268 self._flags.extend([flag for flag in stripped_lines if flag])
267 if hasattr(args, 'device_flags_file') and args.device_flags_file: 269 if hasattr(args, 'device_flags_file') and args.device_flags_file:
268 with open(args.device_flags_file) as device_flags_file: 270 with open(args.device_flags_file) as device_flags_file:
269 stripped_lines = (l.strip() for l in device_flags_file) 271 stripped_lines = (l.strip() for l in device_flags_file)
270 self._flags.extend([flag for flag in stripped_lines if flag]) 272 self._flags.extend([flag for flag in stripped_lines if flag])
271 273
272 @property 274 @property
275 def suite(self):
276 return 'instrumentation'
277
278 @property
273 def apk_under_test(self): 279 def apk_under_test(self):
274 return self._apk_under_test 280 return self._apk_under_test
275 281
276 @property 282 @property
277 def flags(self): 283 def flags(self):
278 return self._flags 284 return self._flags
279 285
280 @property 286 @property
281 def package_info(self): 287 def package_info(self):
282 return self._package_info 288 return self._package_info
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 a = dict(c['annotations']) 458 a = dict(c['annotations'])
453 a.update(m['annotations']) 459 a.update(m['annotations'])
454 inflated_tests.append({ 460 inflated_tests.append({
455 'class': c['class'], 461 'class': c['class'],
456 'method': m['method'], 462 'method': m['method'],
457 'annotations': a, 463 'annotations': a,
458 }) 464 })
459 return inflated_tests 465 return inflated_tests
460 466
461 @staticmethod 467 @staticmethod
468 def GenerateMultiTestResult(errors, statuses):
469 INSTR_STATUS_CODE_START = 1
470 results = []
471 skip_counter = 1
472 for status_code, bundle in statuses:
473 if status_code != INSTR_STATUS_CODE_START:
474 # TODO(rnephew): Make skipped tests still output test name. This is only
475 # there to give skipped tests a unique name so they are counted
476 if 'test_skipped' in bundle:
477 test_name = str(skip_counter)
478 skip_counter += 1
479 else:
480 test_name = '%s#%s' % (
481 ''.join(bundle.get('class', [''])),
482 ''.join(bundle.get('test', [''])))
483
484 results.append(
485 GenerateTestResult(test_name, [(status_code, bundle)], 0, 0))
486 for error in errors:
487 if _NATIVE_CRASH_RE.search(error):
488 results.append(
489 base_test_result.BaseTestResult(
490 'Crash detected', base_test_result.ResultType.CRASH))
491
492 return results
493
494 @staticmethod
462 def ParseAmInstrumentRawOutput(raw_output): 495 def ParseAmInstrumentRawOutput(raw_output):
463 return ParseAmInstrumentRawOutput(raw_output) 496 return ParseAmInstrumentRawOutput(raw_output)
464 497
465 @staticmethod 498 @staticmethod
466 def GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms): 499 def GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms):
467 return GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms) 500 return GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms)
468 501
469 #override 502 #override
470 def TearDown(self): 503 def TearDown(self):
471 if self._isolate_delegate: 504 if self._isolate_delegate:
472 self._isolate_delegate.Clear() 505 self._isolate_delegate.Clear()
473 506
OLDNEW
« no previous file with comments | « build/android/pylib/base/test_run_factory.py ('k') | build/android/pylib/remote/device/remote_device_gtest_run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698