summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2015-03-12 21:38:54 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-03-12 21:38:54 +0000
commitb96f408151531708bd9d59fe6afb7216df17644e (patch)
tree117a276481e90fe6f12ddd5f63f001a836feeba6
parent4867432b357a7b927e59345a5f50f373da0f6729 (diff)
parent702e978e579b6aa2d190ce99392b68a9cc1a5c02 (diff)
downloadexternal_libcxx-b96f408151531708bd9d59fe6afb7216df17644e.tar.gz
external_libcxx-b96f408151531708bd9d59fe6afb7216df17644e.tar.bz2
external_libcxx-b96f408151531708bd9d59fe6afb7216df17644e.zip
am 702e978e: Factor out RemoteExecutor from SSHExecutor.
* commit '702e978e579b6aa2d190ce99392b68a9cc1a5c02': Factor out RemoteExecutor from SSHExecutor.
-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: