summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2015-03-10 18:43:16 +0000
committerDan Albert <danalbert@google.com>2015-03-12 11:00:36 -0700
commit702e978e579b6aa2d190ce99392b68a9cc1a5c02 (patch)
tree117a276481e90fe6f12ddd5f63f001a836feeba6
parent95876420d9100328c7f9ff728a112a043b9f3ce8 (diff)
downloadexternal_libcxx-702e978e579b6aa2d190ce99392b68a9cc1a5c02.tar.gz
external_libcxx-702e978e579b6aa2d190ce99392b68a9cc1a5c02.tar.bz2
external_libcxx-702e978e579b6aa2d190ce99392b68a9cc1a5c02.zip
Factor out RemoteExecutor from SSHExecutor.
Summary: A lot of the pieces of SSHExecutor can be shared with my AdbExecutor (https://android-review.googlesource.com/#/c/138807/). Reviewers: EricWF, jroelofs Reviewed By: jroelofs Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D8117 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@231815 91177308-0d34-0410-b5e6-96231b3b80d8 Change-Id: I38b5d3f16560a07fece15ab0a892c3060404384d
-rw-r--r--test/libcxx/test/executor.py85
1 files changed, 50 insertions, 35 deletions
diff --git a/test/libcxx/test/executor.py b/test/libcxx/test/executor.py
index 30763c9c2..abfedc781 100644
--- a/test/libcxx/test/executor.py
+++ b/test/libcxx/test/executor.py
@@ -78,21 +78,9 @@ class TimeoutExecutor(PrefixExecutor):
['timeout', duration], chain)
-class SSHExecutor(Executor):
- def __init__(self, host, username=None):
- super(SSHExecutor, self).__init__()
-
- self.user_prefix = username + '@' if username else ''
- self.host = host
- self.scp_command = 'scp'
- self.ssh_command = 'ssh'
-
+class RemoteExecutor(Executor):
+ def __init__(self):
self.local_run = executeCommand
- # TODO(jroelofs): switch this on some -super-verbose-debug config flag
- if False:
- self.local_run = tracing.trace_function(
- self.local_run, log_calls=True, log_results=True,
- label='ssh_local')
def remote_temp_dir(self):
return self._remote_temp(True)
@@ -101,33 +89,20 @@ class SSHExecutor(Executor):
return self._remote_temp(False)
def _remote_temp(self, is_dir):
- # TODO: detect what the target system is, and use the correct
- # mktemp command for it. (linux and darwin differ here, and I'm
- # sure windows has another way to do it)
-
- # Not sure how to do suffix on osx yet
- dir_arg = '-d' if is_dir else ''
- cmd = 'mktemp -q {} /tmp/libcxx.XXXXXXXXXX'.format(dir_arg)
- temp_path, err, exitCode = self.__execute_command_remote([cmd])
- temp_path = temp_path.strip()
- if exitCode != 0:
- raise RuntimeError(err)
- return temp_path
+ raise NotImplementedError()
def copy_in(self, local_srcs, remote_dsts):
- scp = self.scp_command
- remote = self.host
- remote = self.user_prefix + remote
-
# This could be wrapped up in a tar->scp->untar for performance
# if there are lots of files to be copied/moved
for src, dst in zip(local_srcs, remote_dsts):
- cmd = [scp, '-p', src, remote + ':' + dst]
- self.local_run(cmd)
+ self._copy_in_file(src, dst)
+
+ def _copy_in_file(self, src, dst):
+ raise NotImplementedError()
def delete_remote(self, remote):
try:
- self.__execute_command_remote(['rm', '-rf', remote])
+ self._execute_command_remote(['rm', '-rf', remote])
except OSError:
# TODO: Log failure to delete?
pass
@@ -144,7 +119,7 @@ class SSHExecutor(Executor):
else:
cmd = [target_exe_path]
self.copy_in([exe_path], [target_exe_path])
- return self.__execute_command_remote(cmd, target_cwd, env)
+ return self._execute_command_remote(cmd, target_cwd, env)
except:
raise
finally:
@@ -153,7 +128,47 @@ class SSHExecutor(Executor):
if target_cwd:
self.delete_remote(target_cwd)
- def __execute_command_remote(self, cmd, remote_work_dir='.', env=None):
+ def _execute_command_remote(self, cmd, remote_work_dir='.', env=None):
+ raise NotImplementedError()
+
+
+class SSHExecutor(RemoteExecutor):
+ def __init__(self, host, username=None):
+ super(SSHExecutor, self).__init__()
+
+ self.user_prefix = username + '@' if username else ''
+ self.host = host
+ self.scp_command = 'scp'
+ self.ssh_command = 'ssh'
+
+ # TODO(jroelofs): switch this on some -super-verbose-debug config flag
+ if False:
+ self.local_run = tracing.trace_function(
+ self.local_run, log_calls=True, log_results=True,
+ label='ssh_local')
+
+ def _remote_temp(self, is_dir):
+ # TODO: detect what the target system is, and use the correct
+ # mktemp command for it. (linux and darwin differ here, and I'm
+ # sure windows has another way to do it)
+
+ # Not sure how to do suffix on osx yet
+ dir_arg = '-d' if is_dir else ''
+ cmd = 'mktemp -q {} /tmp/libcxx.XXXXXXXXXX'.format(dir_arg)
+ temp_path, err, exitCode = self._execute_command_remote([cmd])
+ temp_path = temp_path.strip()
+ if exitCode != 0:
+ raise RuntimeError(err)
+ return temp_path
+
+ def _copy_in_file(self, src, dst):
+ scp = self.scp_command
+ remote = self.host
+ remote = self.user_prefix + remote
+ cmd = [scp, '-p', src, remote + ':' + dst]
+ self.local_run(cmd)
+
+ def _execute_command_remote(self, cmd, remote_work_dir='.', env=None):
remote = self.user_prefix + self.host
ssh_cmd = [self.ssh_command, '-oBatchMode=yes', remote]
if env: