| 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 | 5 |
| 6 import os | 6 import os |
| 7 import shlex | 7 import shlex |
| 8 import sys | 8 import sys |
| 9 import tempfile | 9 import tempfile |
| 10 import time | 10 import time |
| 11 | 11 |
| 12 import android_commands | 12 import android_commands |
| 13 import constants | 13 import constants |
| 14 from android_commands import errors |
| 14 from test_package import TestPackage | 15 from test_package import TestPackage |
| 15 from pylib import pexpect | 16 from pylib import pexpect |
| 16 | 17 |
| 17 class TestPackageApk(TestPackage): | 18 class TestPackageApk(TestPackage): |
| 18 """A helper class for running APK-based native tests. | 19 """A helper class for running APK-based native tests. |
| 19 | 20 |
| 20 Args: | 21 Args: |
| 21 adb: ADB interface the tests are using. | 22 adb: ADB interface the tests are using. |
| 22 device: Device to run the tests. | 23 device: Device to run the tests. |
| 23 test_suite: A specific test suite to run, empty to run all. | 24 test_suite: A specific test suite to run, empty to run all. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 def _ClearFifo(self): | 59 def _ClearFifo(self): |
| 59 self.adb.RunShellCommand('rm -f ' + self._GetFifo()) | 60 self.adb.RunShellCommand('rm -f ' + self._GetFifo()) |
| 60 | 61 |
| 61 def _WatchFifo(self, timeout, logfile=None): | 62 def _WatchFifo(self, timeout, logfile=None): |
| 62 for i in range(10): | 63 for i in range(10): |
| 63 if self.adb.FileExistsOnDevice(self._GetFifo()): | 64 if self.adb.FileExistsOnDevice(self._GetFifo()): |
| 64 print 'Fifo created...' | 65 print 'Fifo created...' |
| 65 break | 66 break |
| 66 time.sleep(i) | 67 time.sleep(i) |
| 67 else: | 68 else: |
| 68 raise Exception('Unable to find fifo on device %s ' % self._GetFifo()) | 69 raise errors.DeviceUnresponsiveError( |
| 70 'Unable to find fifo on device %s ' % self._GetFifo()) |
| 69 args = shlex.split(self.adb.Adb()._target_arg) | 71 args = shlex.split(self.adb.Adb()._target_arg) |
| 70 args += ['shell', 'cat', self._GetFifo()] | 72 args += ['shell', 'cat', self._GetFifo()] |
| 71 return pexpect.spawn('adb', args, timeout=timeout, logfile=logfile) | 73 return pexpect.spawn('adb', args, timeout=timeout, logfile=logfile) |
| 72 | 74 |
| 73 def GetAllTests(self): | 75 def GetAllTests(self): |
| 74 """Returns a list of all tests available in the test suite.""" | 76 """Returns a list of all tests available in the test suite.""" |
| 75 self._CreateTestRunnerScript('--gtest_list_tests') | 77 self._CreateTestRunnerScript('--gtest_list_tests') |
| 76 try: | 78 try: |
| 77 self.tool.SetupEnvironment() | 79 self.tool.SetupEnvironment() |
| 78 # Clear and start monitoring logcat. | 80 # Clear and start monitoring logcat. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 def StripAndCopyExecutable(self): | 114 def StripAndCopyExecutable(self): |
| 113 # Always uninstall the previous one (by activity name); we don't | 115 # Always uninstall the previous one (by activity name); we don't |
| 114 # know what was embedded in it. | 116 # know what was embedded in it. |
| 115 self.adb.ManagedInstall(self.test_suite_full, False, | 117 self.adb.ManagedInstall(self.test_suite_full, False, |
| 116 package_name='org.chromium.native_test') | 118 package_name='org.chromium.native_test') |
| 117 | 119 |
| 118 def _GetTestSuiteBaseName(self): | 120 def _GetTestSuiteBaseName(self): |
| 119 """Returns the base name of the test suite.""" | 121 """Returns the base name of the test suite.""" |
| 120 # APK test suite names end with '-debug.apk' | 122 # APK test suite names end with '-debug.apk' |
| 121 return os.path.basename(self.test_suite).rsplit('-debug', 1)[0] | 123 return os.path.basename(self.test_suite).rsplit('-debug', 1)[0] |
| OLD | NEW |