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

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
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 if hasattr(args, 'device_flags') and args.device_flags: 264 if hasattr(args, 'device_flags') and args.device_flags:
264 with open(args.device_flags) as device_flags_file: 265 with open(args.device_flags) as device_flags_file:
265 stripped_lines = (l.strip() for l in device_flags_file) 266 stripped_lines = (l.strip() for l in device_flags_file)
266 self._flags.extend([flag for flag in stripped_lines if flag]) 267 self._flags.extend([flag for flag in stripped_lines if flag])
267 if hasattr(args, 'device_flags_file') and args.device_flags_file: 268 if hasattr(args, 'device_flags_file') and args.device_flags_file:
268 with open(args.device_flags_file) as device_flags_file: 269 with open(args.device_flags_file) as device_flags_file:
269 stripped_lines = (l.strip() for l in device_flags_file) 270 stripped_lines = (l.strip() for l in device_flags_file)
270 self._flags.extend([flag for flag in stripped_lines if flag]) 271 self._flags.extend([flag for flag in stripped_lines if flag])
271 272
272 @property 273 @property
274 def suite(self):
275 return 'instrumentation'
276
277 @property
273 def apk_under_test(self): 278 def apk_under_test(self):
274 return self._apk_under_test 279 return self._apk_under_test
275 280
276 @property 281 @property
277 def flags(self): 282 def flags(self):
278 return self._flags 283 return self._flags
279 284
280 @property 285 @property
281 def package_info(self): 286 def package_info(self):
282 return self._package_info 287 return self._package_info
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 for m in c['methods']: 456 for m in c['methods']:
452 a = dict(c['annotations']) 457 a = dict(c['annotations'])
453 a.update(m['annotations']) 458 a.update(m['annotations'])
454 inflated_tests.append({ 459 inflated_tests.append({
455 'class': c['class'], 460 'class': c['class'],
456 'method': m['method'], 461 'method': m['method'],
457 'annotations': a, 462 'annotations': a,
458 }) 463 })
459 return inflated_tests 464 return inflated_tests
460 465
466 def GenerateMultiTestResult(self, errors, statuses):
jbudorick 2015/01/20 15:39:03 Does this need |self|? It looks like it can be a @
rnephew (Wrong account) 2015/01/20 16:45:46 Done.
467 INSTR_STATUS_CODE_START = 1
468 results = []
469 skip_counter = 1
470 for status_code, bundle in statuses:
471 if status_code != INSTR_STATUS_CODE_START:
472 # TODO(rnephew): Make skipped tests still output test name. This is only
473 # there to give skipped tests a unique name so they are counted
474 if 'test_skipped' in bundle:
475 test_name = str(skip_counter)
476 skip_counter += 1
477 else:
478 test_name = '%s#%s' % (
479 ''.join(bundle.get('class', [''])),
480 ''.join(bundle.get('test', [''])))
481
482 results.append(
483 GenerateTestResult(test_name, [(status_code, bundle)], 0, 0))
484 print 'batman'
jbudorick 2015/01/20 15:39:03 the debugging statement we deserve, but not the on
rnephew (Wrong account) 2015/01/20 16:45:46 Done.
485 for error in errors:
486 if re.search('Native Crash', error, re.IGNORECASE):
487 results.append(
488 base_test_result.BaseTestResult(
489 'Crash detected', base_test_result.ResultType.CRASH))
490
491 return results
492
461 @staticmethod 493 @staticmethod
462 def ParseAmInstrumentRawOutput(raw_output): 494 def ParseAmInstrumentRawOutput(raw_output):
463 return ParseAmInstrumentRawOutput(raw_output) 495 return ParseAmInstrumentRawOutput(raw_output)
464 496
465 @staticmethod 497 @staticmethod
466 def GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms): 498 def GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms):
467 return GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms) 499 return GenerateTestResult(test_name, instr_statuses, start_ms, duration_ms)
468 500
469 #override 501 #override
470 def TearDown(self): 502 def TearDown(self):
471 if self._isolate_delegate: 503 if self._isolate_delegate:
472 self._isolate_delegate.Clear() 504 self._isolate_delegate.Clear()
473 505
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698