Skip to content

Commit fd667b8

Browse files
committed
[libcxx] [test] Run chmod +x on executables when testing via SSH
When running libc++ tests on a remote machine via SSH, we can encounter a 'Permission denied' error. Fix this with plain old 'chmod +x <executable>'. Thanks to Sergej Jaskiewicz for the patch. Differential Revision: https://reviews.llvm.org/D69170
1 parent b74d7e5 commit fd667b8

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

libcxx/utils/libcxx/test/executor.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,18 @@ def run(self, exe_path, cmd=None, work_dir='.', file_deps=None, env=None):
135135
srcs.extend(file_deps)
136136
dsts.extend(dev_paths)
137137
self.copy_in(srcs, dsts)
138+
139+
# When testing executables that were cross-compiled on Windows for
140+
# Linux, we may need to explicitly set the execution permission to
141+
# avoid the 'Permission denied' error:
142+
chmod_cmd = ['chmod', '+x', target_exe_path]
143+
138144
# TODO(jroelofs): capture the copy_in and delete_remote commands,
139145
# and conjugate them with '&&'s around the first tuple element
140146
# returned here:
141-
return self._execute_command_remote(cmd, target_cwd, env)
147+
return self._execute_command_remote(chmod_cmd + ['&&'] + cmd,
148+
target_cwd,
149+
env)
142150
finally:
143151
if target_cwd:
144152
self.delete_remote(target_cwd)
@@ -187,10 +195,14 @@ def _execute_command_remote(self, cmd, remote_work_dir='.', env=None):
187195
remote = self.user_prefix + self.host
188196
ssh_cmd = [self.ssh_command, '-oBatchMode=yes', remote]
189197
if env:
190-
env_cmd = ['env'] + ['%s="%s"' % (k, v) for k, v in env.items()]
198+
export_cmd = \
199+
['export'] + ['"%s"="%s"' % (k, v) for k, v in env.items()]
191200
else:
192-
env_cmd = []
193-
remote_cmd = ' '.join(env_cmd + cmd)
201+
export_cmd = []
202+
203+
remote_cmd = ' '.join(cmd)
204+
if export_cmd:
205+
remote_cmd = ' '.join(export_cmd) + ' && ' + remote_cmd
194206
if remote_work_dir != '.':
195207
remote_cmd = 'cd ' + remote_work_dir + ' && ' + remote_cmd
196208
out, err, rc = self.local_run(ssh_cmd + [remote_cmd])

0 commit comments

Comments
 (0)