From 96e6cbbf941d0f937b7e823433d4c222967a1817 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 11 Jun 2020 15:41:38 -0400 Subject: [PATCH] [libc++] Allow specifying arbitrary custom executors with the new format The integration between CMake and executor selection in the new format wasn't very flexible -- only the default executor and SSH executors were supported. This patch makes it possible to specify arbitrary executors with the new format. With the new testing format, a custom executor is just a script that gets called with a command-line to execute, and some arguments like --env, --codesign_identity and --execdir. As such, the default executor is just run.py. Remote execution with the SSH executor can be achived by specifying LIBCXX_EXECUTOR=" --host ". Similarly, arbitrary scripts can be provided. --- libcxx/test/CMakeLists.txt | 2 +- libcxx/utils/libcxx/test/config.py | 36 +++++++++++++++++------------------- libcxxabi/test/CMakeLists.txt | 4 ++-- libunwind/test/CMakeLists.txt | 3 ++- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt index 5068cbd..b68f59f 100644 --- a/libcxx/test/CMakeLists.txt +++ b/libcxx/test/CMakeLists.txt @@ -81,7 +81,7 @@ endif() set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING "TargetInfo to use when setting up test environment.") -set(LIBCXX_EXECUTOR "None" CACHE STRING +set(LIBCXX_EXECUTOR "${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/../utils/run.py" CACHE STRING "Executor to use when running tests.") set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!") diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py index 5eccc27..44cb959 100644 --- a/libcxx/utils/libcxx/test/config.py +++ b/libcxx/utils/libcxx/test/config.py @@ -189,18 +189,22 @@ class Configuration(object): exec_env=self.exec_env) def configure_executor(self): - exec_str = self.get_lit_conf('executor', "None") - te = eval(exec_str) - if te: - self.lit_config.note("Using executor: %r" % exec_str) - if self.lit_config.useValgrind: - self.lit_config.fatal("The libc++ test suite can't run under Valgrind with a custom executor") - else: - te = LocalExecutor() + if self.get_lit_conf('use_old_format'): + exec_str = self.get_lit_conf('executor', "None") + te = eval(exec_str) + if te: + self.lit_config.note("Using executor: %r" % exec_str) + if self.lit_config.useValgrind: + self.lit_config.fatal("The libc++ test suite can't run under Valgrind with a custom executor") + else: + te = LocalExecutor() - te.target_info = self.target_info - self.target_info.executor = te - self.executor = te + te.target_info = self.target_info + self.target_info.executor = te + self.executor = te + else: + self.executor = self.get_lit_conf('executor') + self.lit_config.note("Using executor: {}".format(self.executor)) def configure_target_info(self): self.target_info = make_target_info(self) @@ -751,14 +755,8 @@ class Configuration(object): '--codesign_identity "{}"'.format(codesign_ident), '--env {}'.format(env_vars) ] - if isinstance(self.executor, SSHExecutor): - exec_args.append('--host {}'.format(self.executor.user_prefix + self.executor.host)) - executor = os.path.join(self.libcxx_src_root, 'utils', 'ssh.py') - else: - executor = os.path.join(self.libcxx_src_root, 'utils', 'run.py') - sub.append(('%{exec}', '{} {} {} -- '.format(pipes.quote(sys.executable), - pipes.quote(executor), - ' '.join(exec_args)))) + if not self.get_lit_conf('use_old_format'): + sub.append(('%{exec}', '{} {} -- '.format(self.executor, ' '.join(exec_args)))) if self.get_lit_conf('libcxx_gdb'): sub.append(('%{libcxx_gdb}', self.get_lit_conf('libcxx_gdb'))) diff --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt index bedfce8..2160f52 100644 --- a/libcxxabi/test/CMakeLists.txt +++ b/libcxxabi/test/CMakeLists.txt @@ -32,7 +32,7 @@ if(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT LIBCXX_ENABLE_SHARED) endif() if(DEFINED LIBCXX_ENABLE_STATIC - AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX + AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT LIBCXX_ENABLE_STATIC) message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX being OFF requires LIBCXX_ENABLE_STATIC to be ON") endif() @@ -50,7 +50,7 @@ pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX) pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI) set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING "TargetInfo to use when setting up test environment.") -set(LIBCXXABI_EXECUTOR "None" CACHE STRING +set(LIBCXXABI_EXECUTOR "${Python3_EXECUTABLE} ${LIBCXXABI_LIBCXX_PATH}/utils/run.py" CACHE STRING "Executor to use when running tests.") set(AUTO_GEN_COMMENT "## Autogenerated by libcxxabi configuration.\n# Do not edit!") diff --git a/libunwind/test/CMakeLists.txt b/libunwind/test/CMakeLists.txt index e608c17..26e7842 100644 --- a/libunwind/test/CMakeLists.txt +++ b/libunwind/test/CMakeLists.txt @@ -20,7 +20,8 @@ pythonize_bool(LIBUNWIND_USE_COMPILER_RT) pythonize_bool(LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY) set(LIBUNWIND_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING "TargetInfo to use when setting up test environment.") -set(LIBUNWIND_EXECUTOR "None" CACHE STRING +set(LIBUNWIND_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../../libcxx") +set(LIBUNWIND_EXECUTOR "${Python3_EXECUTABLE} ${LIBUNWIND_LIBCXX_PATH}/utils/run.py" CACHE STRING "Executor to use when running tests.") set(AUTO_GEN_COMMENT "## Autogenerated by libunwind configuration.\n# Do not edit!") -- 2.7.4