OLD | NEW |
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 """Provides an interface to communicate with the device via the adb command. | 5 """Provides an interface to communicate with the device via the adb command. |
6 | 6 |
7 Assumes adb binary is currently on system path. | 7 Assumes adb binary is currently on system path. |
8 """ | 8 """ |
9 | 9 |
10 import collections | 10 import collections |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 Returns: | 1008 Returns: |
1009 True if the file exists, False otherwise. | 1009 True if the file exists, False otherwise. |
1010 """ | 1010 """ |
1011 assert '"' not in file_name, 'file_name cannot contain double quotes' | 1011 assert '"' not in file_name, 'file_name cannot contain double quotes' |
1012 status = self._adb.SendShellCommand( | 1012 status = self._adb.SendShellCommand( |
1013 '\'test -f "%s"; echo $?\'' % (file_name)) | 1013 '\'test -f "%s"; echo $?\'' % (file_name)) |
1014 if not status[0].find('test: not found'): | 1014 if not status[0].find('test: not found'): |
1015 return int(status) == 0 | 1015 return int(status) == 0 |
1016 | 1016 |
1017 status = self._adb.SendShellCommand('ls "%s"' % (file_name)) | 1017 status = self._adb.SendShellCommand('ls "%s"' % (file_name)) |
1018 if not status[0].find('No such file or directory'): | 1018 if status[0].find('No such file or directory') == -1: |
1019 return True | 1019 return True |
1020 | 1020 |
1021 return False | 1021 return False |
1022 | 1022 |
1023 def RunMonkey(self, package_name, category=None, throttle=100, seed=None, | 1023 def RunMonkey(self, package_name, category=None, throttle=100, seed=None, |
1024 event_count=10000, verbosity=1, extra_args=''): | 1024 event_count=10000, verbosity=1, extra_args=''): |
1025 """Runs monkey test for a given package. | 1025 """Runs monkey test for a given package. |
1026 | 1026 |
1027 Args: | 1027 Args: |
1028 package_name: Allowed package. | 1028 package_name: Allowed package. |
(...skipping 17 matching lines...) Expand all Loading... |
1046 ' '.join(['-c %s' % c for c in category]), | 1046 ' '.join(['-c %s' % c for c in category]), |
1047 '--throttle %d' % throttle, | 1047 '--throttle %d' % throttle, |
1048 '-s %d' % seed, | 1048 '-s %d' % seed, |
1049 '-v ' * verbosity, | 1049 '-v ' * verbosity, |
1050 '--monitor-native-crashes', | 1050 '--monitor-native-crashes', |
1051 '--kill-process-after-error', | 1051 '--kill-process-after-error', |
1052 extra_args, | 1052 extra_args, |
1053 '%d' % event_count] | 1053 '%d' % event_count] |
1054 return self.RunShellCommand(' '.join(cmd), | 1054 return self.RunShellCommand(' '.join(cmd), |
1055 timeout_time=event_count*throttle*1.5) | 1055 timeout_time=event_count*throttle*1.5) |
OLD | NEW |