aboutsummaryrefslogtreecommitdiff
path: root/automated/android/multinode/tradefed/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'automated/android/multinode/tradefed/utils.py')
-rw-r--r--automated/android/multinode/tradefed/utils.py27
1 files changed, 17 insertions, 10 deletions
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):