blob: 621844fd30a22f5f0be43d3b8bc1bf2090febfc8 [file] [log] [blame]
Stephen Hines2d1fdb22014-05-28 23:58:16 -07001#!/usr/bin/python
2
3import os, sys, subprocess, tempfile
4from android_common import *
5
6ANDROID_TMPDIR = '/data/local/tmp/Output'
7
8here = os.path.abspath(os.path.dirname(sys.argv[0]))
9device_binary = os.path.join(ANDROID_TMPDIR, os.path.basename(sys.argv[0]))
10
11def 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():
Stephen Hines86277eb2015-03-23 12:06:32 -070017 if key in ['ASAN_OPTIONS', 'ASAN_ACTIVATION_OPTIONS']:
Stephen Hines2d1fdb22014-05-28 23:58:16 -070018 args.append('%s="%s"' % (key, value))
19 return ' '.join(args)
20
21device_env = build_env()
22device_args = ' '.join(sys.argv[1:]) # FIXME: escape?
23device_stdout = device_binary + '.stdout'
24device_stderr = device_binary + '.stderr'
25device_exitcode = device_binary + '.exitcode'
Stephen Hines6a211c52014-07-21 00:49:56 -070026ret = adb(['shell', 'cd %s && %s asanwrapper %s %s >%s 2>%s ; echo $? >%s' %
Stephen Hines2d1fdb22014-05-28 23:58:16 -070027 (ANDROID_TMPDIR, device_env, device_binary, device_args,
28 device_stdout, device_stderr, device_exitcode)])
29if ret != 0:
30 sys.exit(ret)
31
32sys.stdout.write(pull_from_device(device_stdout))
33sys.stderr.write(pull_from_device(device_stderr))
34sys.exit(int(pull_from_device(device_exitcode)))