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

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

Issue 221823011: [Android] Change object types from AndroidCommands to DeviceUtils in build/android/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Frank's comments. Created 6 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """Runs a monkey test on a single device.""" 5 """Runs a monkey test on a single device."""
6 6
7 import logging 7 import logging
8 import random 8 import random
9 9
10 from pylib import constants 10 from pylib import constants
(...skipping 22 matching lines...) Expand all
33 cmd = ['monkey', 33 cmd = ['monkey',
34 '-p %s' % self._package, 34 '-p %s' % self._package,
35 ' '.join(['-c %s' % c for c in self._options.category]), 35 ' '.join(['-c %s' % c for c in self._options.category]),
36 '--throttle %d' % self._options.throttle, 36 '--throttle %d' % self._options.throttle,
37 '-s %d' % (self._options.seed or random.randint(1, 100)), 37 '-s %d' % (self._options.seed or random.randint(1, 100)),
38 '-v ' * self._options.verbose_count, 38 '-v ' * self._options.verbose_count,
39 '--monitor-native-crashes', 39 '--monitor-native-crashes',
40 '--kill-process-after-error', 40 '--kill-process-after-error',
41 self._options.extra_args, 41 self._options.extra_args,
42 '%d' % self._options.event_count] 42 '%d' % self._options.event_count]
43 return self.adb.RunShellCommand(' '.join(cmd), timeout_time=timeout_ms) 43 return self.device.old_interface.RunShellCommand(
44 ' '.join(cmd), timeout_time=timeout_ms)
44 45
45 def RunTest(self, test_name): 46 def RunTest(self, test_name):
46 """Run a Monkey test on the device. 47 """Run a Monkey test on the device.
47 48
48 Args: 49 Args:
49 test_name: String to use for logging the test result. 50 test_name: String to use for logging the test result.
50 51
51 Returns: 52 Returns:
52 A tuple of (TestRunResults, retry). 53 A tuple of (TestRunResults, retry).
53 """ 54 """
54 self.adb.StartActivity(self._package, 55 self.device.old_interface.StartActivity(
55 self._activity, 56 self._package, self._activity, wait_for_completion=True,
56 wait_for_completion=True, 57 action='android.intent.action.MAIN', force_stop=True)
57 action='android.intent.action.MAIN',
58 force_stop=True)
59 58
60 # Chrome crashes are not always caught by Monkey test runner. 59 # Chrome crashes are not always caught by Monkey test runner.
61 # Verify Chrome has the same PID before and after the test. 60 # Verify Chrome has the same PID before and after the test.
62 before_pids = self.adb.ExtractPid(self._package) 61 before_pids = self.device.old_interface.ExtractPid(self._package)
63 62
64 # Run the test. 63 # Run the test.
65 output = '' 64 output = ''
66 if before_pids: 65 if before_pids:
67 output = '\n'.join(self._LaunchMonkeyTest()) 66 output = '\n'.join(self._LaunchMonkeyTest())
68 after_pids = self.adb.ExtractPid(self._package) 67 after_pids = self.device.old_interface.ExtractPid(self._package)
69 68
70 crashed = True 69 crashed = True
71 if not before_pids: 70 if not before_pids:
72 logging.error('Failed to start the process.') 71 logging.error('Failed to start the process.')
73 elif not after_pids: 72 elif not after_pids:
74 logging.error('Process %s has died.', before_pids[0]) 73 logging.error('Process %s has died.', before_pids[0])
75 elif before_pids[0] != after_pids[0]: 74 elif before_pids[0] != after_pids[0]:
76 logging.error('Detected process restart %s -> %s', 75 logging.error('Detected process restart %s -> %s',
77 before_pids[0], after_pids[0]) 76 before_pids[0], after_pids[0])
78 else: 77 else:
79 crashed = False 78 crashed = False
80 79
81 results = base_test_result.TestRunResults() 80 results = base_test_result.TestRunResults()
82 success_pattern = 'Events injected: %d' % self._options.event_count 81 success_pattern = 'Events injected: %d' % self._options.event_count
83 if success_pattern in output and not crashed: 82 if success_pattern in output and not crashed:
84 result = base_test_result.BaseTestResult( 83 result = base_test_result.BaseTestResult(
85 test_name, base_test_result.ResultType.PASS, log=output) 84 test_name, base_test_result.ResultType.PASS, log=output)
86 else: 85 else:
87 result = base_test_result.BaseTestResult( 86 result = base_test_result.BaseTestResult(
88 test_name, base_test_result.ResultType.FAIL, log=output) 87 test_name, base_test_result.ResultType.FAIL, log=output)
89 if 'chrome' in self._options.package: 88 if 'chrome' in self._options.package:
90 logging.warning('Starting MinidumpUploadService...') 89 logging.warning('Starting MinidumpUploadService...')
91 try: 90 try:
92 self.adb.StartCrashUploadService(self._package) 91 self.device.old_interface.StartCrashUploadService(self._package)
93 except AssertionError as e: 92 except AssertionError as e:
94 logging.error('Failed to start MinidumpUploadService: %s', e) 93 logging.error('Failed to start MinidumpUploadService: %s', e)
95 results.AddResult(result) 94 results.AddResult(result)
96 return results, False 95 return results, False
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698