Skip to content

Commit bf10e0b

Browse files
committed
[android] adb_test_runner.py pushes file arguments.
Some tests need more than just the executable to be pushed. For example the resilience tests need the executable and the linked library to be pushed. adb_test_runner.py only pushed the executable. The changes look into the arguments passed to the executable and figure out which ones refer to files. Those files are pushed to the device and transformed to refer to the path on the device instead (the resilience test do not actually use the argument values themselves, but maybe others do).
1 parent 1d551cb commit bf10e0b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

utils/android/adb/commands.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ def execute_on_device(executable_path, executable_arguments):
9999
for (k, v) in os.environ.items()
100100
if k.startswith(ENV_PREFIX)]
101101

102+
# The executables are sometimes passed arguments, and sometimes those
103+
# arguments are files that have to be pushed, but also the argument values
104+
# have to be changed to the new path in the Android device.
105+
translated_executable_arguments = []
106+
for executable_argument in executable_arguments:
107+
# Currently we only support arguments that are file paths themselves.
108+
# Things like `--foo=/path/to/file` or directories are not supported.
109+
# Relative paths from the executable to the arguments are not kept.
110+
if os.path.isfile(executable_argument):
111+
final_path = '{}/{}'.format(uuid_dir,
112+
os.path.basename(executable_argument))
113+
push(executable_argument, final_path)
114+
translated_executable_arguments.append(final_path)
115+
else:
116+
translated_executable_arguments.append(executable_argument)
117+
102118
# When running the executable on the device, we need to pass it the same
103119
# arguments, as well as specify the correct LD_LIBRARY_PATH. Save these
104120
# to a file we can easily call multiple times.
@@ -111,7 +127,7 @@ def execute_on_device(executable_path, executable_arguments):
111127
tmp_dir=DEVICE_TEMP_DIR,
112128
child_environment=' '.join(child_environment),
113129
executable=executable,
114-
executable_arguments=' '.join(executable_arguments)))
130+
executable_arguments=' '.join(translated_executable_arguments)))
115131

116132
# Write the output from the test executable to a file named '__stdout', and
117133
# if the test executable succeeds, write 'SUCCEEDED' to a file

0 commit comments

Comments
 (0)