aboutsummaryrefslogtreecommitdiff
path: root/automated/android/multinode/tradefed
diff options
context:
space:
mode:
Diffstat (limited to 'automated/android/multinode/tradefed')
-rwxr-xr-xautomated/android/multinode/tradefed/tradefed-runner-multinode.py5
-rw-r--r--automated/android/multinode/tradefed/utils.py27
2 files changed, 20 insertions, 12 deletions
diff --git a/automated/android/multinode/tradefed/tradefed-runner-multinode.py b/automated/android/multinode/tradefed/tradefed-runner-multinode.py
index e2da6ec..f862057 100755
--- a/automated/android/multinode/tradefed/tradefed-runner-multinode.py
+++ b/automated/android/multinode/tradefed/tradefed-runner-multinode.py
@@ -14,6 +14,7 @@ import time
sys.path.insert(0, '../../../lib/')
sys.path.insert(1, '../../')
import py_test_lib # nopep8
+from py_util_lib import call_shell_lib # nopep8
import tradefed.result_parser as result_parser # nopep8
from multinode.tradefed.utils import * # nopep8
from multinode.tradefed.sts_util import StsUtil # nopep8
@@ -226,8 +227,8 @@ while child.isalive():
if num_available_devices < len(devices):
logger.debug('Some devices are lost. Dumping state of adb/USB devices.')
child.sendline('dump logs')
- subprocess.run(['sh', '-c', '. ../../../lib/sh-test-lib && . ../../../lib/android-test-lib '
- '&& adb_debug_info'])
+
+ call_shell_lib("adb_debug_info")
logger.debug('"adb devices" output')
subprocess.run(['adb', 'devices'])
diff --git a/automated/android/multinode/tradefed/utils.py b/automated/android/multinode/tradefed/utils.py
index c3b748f..14ecac6 100644
--- a/automated/android/multinode/tradefed/utils.py
+++ b/automated/android/multinode/tradefed/utils.py
@@ -4,6 +4,9 @@ import shutil
import subprocess
import time
+sys.path.insert(0, "../../../lib/")
+from py_util_lib import call_shell_lib # nopep8
+
class Device:
tcpip_device_re = re.compile(
@@ -119,16 +122,8 @@ class Device:
bootTimeoutSecs = max(
10, int(reconnectTimeoutSecs) - fastbootRebootTimeoutSecs
)
- return (
- subprocess.run(
- [
- "sh",
- "-c",
- ". ../../../lib/sh-test-lib && . ../../../lib/android-test-lib && "
- 'export ANDROID_SERIAL="%s" && wait_boot_completed %s'
- % (self.serial_or_address, bootTimeoutSecs),
- ]
- ).returncode == 0
+ return self._call_shell_lib(
+ "wait_boot_completed {}".format(bootTimeoutSecs)
)
# adb may not yet have realized that the connection is broken
@@ -202,6 +197,18 @@ class Device:
self.worker_handshake_iteration += 1
return True
+ def _call_shell_lib(self, command: str) -> bool:
+ """Call a function implemented in the (Android) shell library.
+ Ensure that device-specific commands are executed on `self`.
+
+ Arguments:
+ command: Function defined in sh-test-lib or android-test-lib to
+ call, including its parameters.
+ Return:
+ True if the executed shell exists with 0, False otherwise.
+ """
+ return call_shell_lib(command, device=self.serial_or_address) == 0
+
class RetryCheck:
def __init__(self, total_max_retries, retries_if_unchanged):