[llvm] 20e1efc - Update the remote test launch utility (utils/remote-exec.py).
Vladimir Vereschaka via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 6 19:41:01 PDT 2022
Author: Vladimir Vereschaka
Date: 2022-10-06T19:40:32-07:00
New Revision: 20e1efcfe153fc5fac4c9715d1ac207d65891c8f
URL: https://github.com/llvm/llvm-project/commit/20e1efcfe153fc5fac4c9715d1ac207d65891c8f
DIFF: https://github.com/llvm/llvm-project/commit/20e1efcfe153fc5fac4c9715d1ac207d65891c8f.diff
LOG: Update the remote test launch utility (utils/remote-exec.py).
Allowed a single file execution without the execution directory.
Added:
Modified:
llvm/utils/remote-exec.py
Removed:
################################################################################
diff --git a/llvm/utils/remote-exec.py b/llvm/utils/remote-exec.py
index 481885b0c6c0..37b261cca7ee 100644
--- a/llvm/utils/remote-exec.py
+++ b/llvm/utils/remote-exec.py
@@ -41,7 +41,7 @@ def scp(args, src, dst):
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--host', type=str, required=True)
- parser.add_argument('--execdir', type=str, required=True)
+ parser.add_argument('--execdir', type=str, required=False)
parser.add_argument('--extra-ssh-args', type=str, required=False)
parser.add_argument('--extra-scp-args', type=str, required=False)
parser.add_argument('--codesign_identity', type=str, required=False, default=None)
@@ -55,7 +55,7 @@ def main():
# and changing their path when running on the remote host. It's also possible
# for there to be no such executable, for example in the case of a .sh.cpp
# test.
- parser.add_argument('--exec-pattern', type=str, required=False, default='.*\.tmp\.exe',
+ parser.add_argument('--exec-pattern', type=str, required=False, default='.*',
help='The name regex pattern of the executables generated by \
a test file. Specifying it allows us to do custom \
processing like codesigning test-executables \
@@ -68,6 +68,15 @@ def main():
args = parser.parse_args()
commandLine = args.command
+ execdir = args.execdir
+ if execdir == '.':
+ # Retrieve the exec directory from the command line.
+ execdir, _ = os.path.split(commandLine[0])
+ if execdir == '':
+ # Get the current directory in that case.
+ execdir = os.getcwd()
+ arcname = os.path.basename(execdir) if execdir else None
+
# Create a temporary directory where the test will be run.
# That is effectively the value of %T on the remote host.
tmp = subprocess.check_output(
@@ -78,6 +87,8 @@ def main():
isExecutable = lambda exe: re.match(args.exec_pattern, exe) and os.path.exists(exe)
pathOnRemote = lambda file: posixpath.join(tmp, os.path.basename(file))
+ remoteCommands = []
+
try:
# Do any necessary codesigning of test-executables found in the command line.
if args.codesign_identity:
@@ -88,27 +99,34 @@ def main():
# tar up the execution directory (which contains everything that's needed
# to run the test), and copy the tarball over to the remote host.
- try:
- tmpTar = tempfile.NamedTemporaryFile(suffix='.tar', delete=False)
- with tarfile.open(fileobj=tmpTar, mode='w') as tarball:
- tarball.add(args.execdir, arcname=os.path.basename(args.execdir))
-
- # Make sure we close the file before we scp it, because accessing
- # the temporary file while still open doesn't work on Windows.
- tmpTar.close()
- remoteTarball = pathOnRemote(tmpTar.name)
- subprocess.check_call(scp(args, tmpTar.name, remoteTarball))
- finally:
- # Make sure we close the file in case an exception happens before
- # we've closed it above -- otherwise close() is idempotent.
- tmpTar.close()
- os.remove(tmpTar.name)
-
- # Untar the dependencies in the temporary directory and remove the tarball.
- remoteCommands = [
- 'tar -xf {} -C {} --strip-components 1'.format(remoteTarball, tmp),
- 'rm {}'.format(remoteTarball)
- ]
+ if execdir:
+ try:
+ tmpTar = tempfile.NamedTemporaryFile(suffix='.tar', delete=False)
+ with tarfile.open(fileobj=tmpTar, mode='w') as tarball:
+ tarball.add(execdir, arcname=arcname)
+
+ # Make sure we close the file before we scp it, because accessing
+ # the temporary file while still open doesn't work on Windows.
+ tmpTar.close()
+ remoteTarball = pathOnRemote(tmpTar.name)
+ subprocess.check_call(scp(args, tmpTar.name, remoteTarball))
+ finally:
+ # Make sure we close the file in case an exception happens before
+ # we've closed it above -- otherwise close() is idempotent.
+ tmpTar.close()
+ os.remove(tmpTar.name)
+
+ # Untar the dependencies in the temporary directory and remove the tarball.
+ remoteCommands.extend([
+ 'tar -xf {} -C {} --strip-components 1'.format(remoteTarball, tmp),
+ 'rm {}'.format(remoteTarball)
+ ])
+ else:
+ # Copy only the files, which are specified in the command line.
+ # Copy them to remote host one by one.
+ for x in commandLine:
+ _, f = os.path.split(x)
+ subprocess.check_call(scp(args, x, pathOnRemote(f)))
# Make sure all executables in the remote command line have 'execute'
# permissions on the remote host. The host that compiled the test-executable
More information about the llvm-commits
mailing list