]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/android_commands/android_common.py
1 import os
, subprocess
, tempfile
4 ANDROID_TMPDIR
= '/data/local/tmp/Output'
5 ADB
= os
.environ
.get('ADB', 'adb')
8 if os
.environ
.get('ANDROID_RUN_VERBOSE') == '1':
11 def adb(args
, attempts
= 1):
14 tmpname
= tempfile
.mktemp()
15 out
= open(tmpname
, 'w')
17 while attempts
> 0 and ret
!= 0:
19 ret
= subprocess
.call([ADB
] + args
, stdout
=out
, stderr
=subprocess
.STDOUT
)
23 print "adb command failed", args
26 out
= open(tmpname
, 'r')
32 def pull_from_device(path
):
33 tmp
= tempfile
.mktemp()
34 adb(['pull', path
, tmp
], 5)
35 text
= open(tmp
, 'r').read()
39 def push_to_device(path
):
40 # Workaround for https://code.google.com/p/android/issues/detail?id=65857
41 dst_path
= os
.path
.join(ANDROID_TMPDIR
, os
.path
.basename(path
))
42 tmp_path
= dst_path
+ '.push'
43 adb(['push', path
, tmp_path
], 5)
44 adb(['shell', 'cp "%s" "%s" 2>&1' % (tmp_path
, dst_path
)], 5)