aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Kirilov <anton.kirilov@linaro.org>2016-08-09 12:55:13 +0100
committerAnton Kirilov <anton.kirilov@linaro.org>2016-08-22 18:11:03 +0100
commitbbbf89701595145655824ba56e070005652a6b05 (patch)
tree368d17ddddb18683d6432b2944dcfd7d8589642f
parentbf24c506d240d22c804fad5822886b730a59a398 (diff)
downloadart-testing-bbbf89701595145655824ba56e070005652a6b05.tar.gz
Fix the execution of long command lines by adb.
Change-Id: Ibf5b1e2de30b84c7ff92b79a1bb414c42ce76065
-rw-r--r--tools/utils_adb.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/utils_adb.py b/tools/utils_adb.py
index 62cf50d..7344d63 100644
--- a/tools/utils_adb.py
+++ b/tools/utils_adb.py
@@ -14,6 +14,7 @@
import os
import subprocess
+import tempfile
import utils
@@ -46,6 +47,7 @@ def root(target=utils.adb_default_target_string, exit_on_error=True):
def shell(command,
target=utils.adb_default_target_string,
+ target_copy_path=utils.adb_default_target_copy_path,
exit_on_error=True):
if not isinstance(command, list):
command = [command]
@@ -53,8 +55,23 @@ def shell(command,
# copy-pasted and executed.
command_string = ' '.join(['adb'] + GetTargetArgs(target) + \
['shell', '"%s"' % ' '.join(command)])
- command = ['adb'] + GetTargetArgs(target) + ['shell'] + command
- return utils.Command(command, command_string=command_string , exit_on_error=exit_on_error)
+ if len(' '.join(command)) < 512:
+ command = ['adb'] + GetTargetArgs(target) + ['shell'] + command
+ return utils.Command(command, command_string=command_string , exit_on_error=exit_on_error)
+ else:
+ fd, path = tempfile.mkstemp()
+ remote_path = utils.TargetPathJoin(target_copy_path, os.path.basename(path))
+ os.write(fd, bytes(' '.join(command), 'UTF-8'))
+ os.close(fd)
+ push(path, remote_path, target)
+ os.remove(path)
+ command = ['adb'] + GetTargetArgs(target) + ['shell', 'source', remote_path]
+ rc, outerr = utils.Command(command,
+ command_string=command_string ,
+ exit_on_error=exit_on_error)
+ shell(['rm', '-f', remote_path], target, exit_on_error=exit_on_error)
+ return rc, outerr
+
def GetISAList(target):
# The 32-bit ISA name should be a substring of the 64-bit one.