Move MSan lit-tests under test/msan
[blocksruntime.git] / lib / asan / lit_tests / android_commands / android_run.py
bloba6ceeb4270705a5e3f37704f4678db87b0e5b88b
1 #!/usr/bin/python
3 import os, sys, subprocess, tempfile
4 from android_common import *
6 ANDROID_TMPDIR = '/data/local/tmp/Output'
8 here = os.path.abspath(os.path.dirname(sys.argv[0]))
9 device_binary = os.path.join(ANDROID_TMPDIR, os.path.basename(sys.argv[0]))
11 def build_env():
12 args = []
13 # Android linker ignores RPATH. Set LD_LIBRARY_PATH to Output dir.
14 args.append('LD_LIBRARY_PATH=%s:%s' %
15 (ANDROID_TMPDIR, os.environ.get('LD_LIBRARY_PATH', '')))
16 for (key, value) in os.environ.items():
17 if key in ['ASAN_OPTIONS']:
18 args.append('%s="%s"' % (key, value))
19 return ' '.join(args)
21 device_env = build_env()
22 device_args = ' '.join(sys.argv[1:]) # FIXME: escape?
23 device_stdout = device_binary + '.stdout'
24 device_stderr = device_binary + '.stderr'
25 device_exitcode = device_binary + '.exitcode'
26 ret = adb(['shell', 'cd %s && %s %s %s >%s 2>%s ; echo $? >%s' %
27 (ANDROID_TMPDIR, device_env, device_binary, device_args,
28 device_stdout, device_stderr, device_exitcode)])
29 if ret != 0:
30 sys.exit(ret)
32 sys.stdout.write(pull_from_device(device_stdout))
33 sys.stderr.write(pull_from_device(device_stderr))
34 sys.exit(int(pull_from_device(device_exitcode)))