Skip to content

Commit 3ab5e5c

Browse files
authored
Merge pull request #19940 from drodriguez/android-adb_test_runner-envvars
2 parents 6cd7803 + 44108a8 commit 3ab5e5c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

test/lit.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,8 @@ SIMULATOR_ENV_PREFIX = 'SIMCTL_CHILD_'
932932
ENV_VAR_PREFIXES = {
933933
'iphonesimulator': SIMULATOR_ENV_PREFIX,
934934
'watchsimulator': SIMULATOR_ENV_PREFIX,
935-
'appletvsimulator': SIMULATOR_ENV_PREFIX
935+
'appletvsimulator': SIMULATOR_ENV_PREFIX,
936+
'android': 'ANDROID_CHILD_'
936937
}
937938
TARGET_ENV_PREFIX = ENV_VAR_PREFIXES.get(config.target_sdk_name, "")
938939

utils/android/adb/commands.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717

1818
from __future__ import print_function
1919

20+
import os
2021
import subprocess
2122
import tempfile
2223
import uuid
2324

2425

2526
# A temporary directory on the Android device.
2627
DEVICE_TEMP_DIR = '/data/local/tmp'
28+
ENV_PREFIX = 'ANDROID_CHILD_'
2729

2830

2931
def shell(args):
@@ -93,16 +95,21 @@ def execute_on_device(executable_path, executable_arguments):
9395
executable = '{}/__executable'.format(uuid_dir)
9496
push(executable_path, executable)
9597

98+
child_environment = ['{}="{}"'.format(k.replace(ENV_PREFIX, '', 1), v)
99+
for (k, v) in os.environ.items()
100+
if k.startswith(ENV_PREFIX)]
101+
96102
# When running the executable on the device, we need to pass it the same
97103
# arguments, as well as specify the correct LD_LIBRARY_PATH. Save these
98104
# to a file we can easily call multiple times.
99105
executable_with_args = '{}/__executable_with_args'.format(uuid_dir)
100106
_create_executable_on_device(
101107
executable_with_args,
102108
'LD_LIBRARY_PATH={uuid_dir}:{tmp_dir} '
103-
'{executable} {executable_arguments}'.format(
109+
'{child_environment} {executable} {executable_arguments}'.format(
104110
uuid_dir=uuid_dir,
105111
tmp_dir=DEVICE_TEMP_DIR,
112+
child_environment=' '.join(child_environment),
106113
executable=executable,
107114
executable_arguments=' '.join(executable_arguments)))
108115

@@ -146,7 +153,7 @@ def execute_on_device(executable_path, executable_arguments):
146153
# the executable on the device.
147154
return 1
148155

149-
print(stdout)
156+
print(stdout, end='')
150157

151158
shell(['rm', '-rf', uuid_dir])
152159
return 0

0 commit comments

Comments
 (0)