[Lldb-commits] [lldb] r374386 - [test] Use a different module cache for Shell and API tests.
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 10 10:27:09 PDT 2019
Author: jdevlieghere
Date: Thu Oct 10 10:27:09 2019
New Revision: 374386
URL: http://llvm.org/viewvc/llvm-project?rev=374386&view=rev
Log:
[test] Use a different module cache for Shell and API tests.
Before the test reorganization, everything was part of a single test
suite with a single module cache. Now that things are properly separated
this is no longer the case. Only the shell tests inherited the logic to
properly configure and wipe the module caches. This patch adds that
logic back for the API tests. While doing so, I noticed that we were
configuring a Clang module cache in CMake, but weren't actually using it
from dotest.py. I included a fix for that in this patch as well.
Differential revision: https://reviews.llvm.org/D68755
Modified:
lldb/trunk/packages/Python/lldbsuite/test/configuration.py
lldb/trunk/packages/Python/lldbsuite/test/dotest.py
lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py
lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
lldb/trunk/test/API/lit.cfg
lldb/trunk/test/API/lit.site.cfg.in
lldb/trunk/test/CMakeLists.txt
lldb/trunk/test/Shell/lit.cfg.py
lldb/trunk/test/Shell/lit.site.cfg.py.in
Modified: lldb/trunk/packages/Python/lldbsuite/test/configuration.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/configuration.py?rev=374386&r1=374385&r2=374386&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/configuration.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/configuration.py Thu Oct 10 10:27:09 2019
@@ -107,7 +107,9 @@ lldb_platform_working_dir = None
test_build_dir = None
# The clang module cache directory used by lldb.
-module_cache_dir = None
+lldb_module_cache_dir = None
+# The clang module cache directory used by clang.
+clang_module_cache_dir = None
# The only directory to scan for tests. If multiple test directories are
# specified, and an exclusive test subdirectory is specified, the latter option
Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=374386&r1=374385&r2=374386&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Thu Oct 10 10:27:09 2019
@@ -426,11 +426,18 @@ def parseOptionsAndInitTestdirs():
configuration.lldb_platform_working_dir = args.lldb_platform_working_dir
if args.test_build_dir:
configuration.test_build_dir = args.test_build_dir
- if args.module_cache_dir:
- configuration.module_cache_dir = args.module_cache_dir
+ if args.lldb_module_cache_dir:
+ configuration.lldb_module_cache_dir = args.lldb_module_cache_dir
else:
- configuration.module_cache_dir = os.path.join(configuration.test_build_dir,
- 'module-cache-lldb')
+ configuration.lldb_module_cache_dir = os.path.join(
+ configuration.test_build_dir, 'module-cache-lldb')
+ if args.clang_module_cache_dir:
+ configuration.clang_module_cache_dir = args.clang_module_cache_dir
+ else:
+ configuration.clang_module_cache_dir = os.path.join(
+ configuration.test_build_dir, 'module-cache-clang')
+
+ os.environ['CLANG_MODULE_CACHE_DIR'] = configuration.clang_module_cache_dir
# Gather all the dirs passed on the command line.
if len(args.args) > 0:
Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py?rev=374386&r1=374385&r2=374386&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/dotest_args.py Thu Oct 10 10:27:09 2019
@@ -150,10 +150,15 @@ def create_parser():
default='lldb-test-build.noindex',
help='The root build directory for the tests. It will be removed before running.')
group.add_argument(
- '--module-cache-dir',
- dest='module_cache_dir',
+ '--lldb-module-cache-dir',
+ dest='lldb_module_cache_dir',
metavar='The clang module cache directory used by LLDB',
- help='The clang module cache directory used by LLDB. This is not the one used by the makefiles. Defaults to <test build directory>/module-cache-lldb.')
+ help='The clang module cache directory used by LLDB. Defaults to <test build directory>/module-cache-lldb.')
+ group.add_argument(
+ '--clang-module-cache-dir',
+ dest='clang_module_cache_dir',
+ metavar='The clang module cache directory used by Clang',
+ help='The clang module cache directory used in the Make files by Clang while building tests. Defaults to <test build directory>/module-cache-clang.')
# Configuration options
group = parser.add_argument_group('Remote platform options')
Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=374386&r1=374385&r2=374386&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Thu Oct 10 10:27:09 2019
@@ -696,7 +696,7 @@ class Base(unittest2.TestCase):
"settings set plugin.process.gdb-remote.packet-timeout 60",
'settings set symbols.clang-modules-cache-path "{}"'.format(
- configuration.module_cache_dir),
+ configuration.lldb_module_cache_dir),
"settings set use-color false",
]
# Make sure that a sanitizer LLDB's environment doesn't get passed on.
Modified: lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules?rev=374386&r1=374385&r2=374386&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules Thu Oct 10 10:27:09 2019
@@ -313,14 +313,6 @@ ifeq "$(MAKE_DWO)" "YES"
CFLAGS += -gsplit-dwarf
endif
-# Use a shared module cache when building in the default test build directory.
-CLANG_MODULE_CACHE_DIR := $(shell echo "$(BUILDDIR)" | sed $(QUOTE)s/lldb-test-build.noindex.*/lldb-test-build.noindex\/module-cache-clang/$(QUOTE))
-
-ifeq "$(findstring lldb-test-build.noindex, $(BUILDDIR))" ""
-CLANG_MODULE_CACHE_DIR := $(BUILDDIR)/module-cache
-$(warning failed to set the shared clang module cache dir)
-endif
-
MODULE_BASE_FLAGS := -fmodules -gmodules -fmodules-cache-path=$(CLANG_MODULE_CACHE_DIR)
MANDATORY_MODULE_BUILD_CFLAGS := $(MODULE_BASE_FLAGS) -gmodules
# Build flags for building with C++ modules.
Modified: lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py?rev=374386&r1=374385&r2=374386&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/plugins/builder_base.py Thu Oct 10 10:27:09 2019
@@ -122,6 +122,16 @@ def getSDKRootSpec():
return "SDKROOT={}".format(os.environ["SDKROOT"])
return "";
+def getModuleCacheSpec():
+ """
+ Helper function to return the key-value string to specify the clang
+ module cache used for the make system.
+ """
+ if "CLANG_MODULE_CACHE_DIR" in os.environ:
+ return "CLANG_MODULE_CACHE_DIR={}".format(
+ os.environ["CLANG_MODULE_CACHE_DIR"])
+ return "";
+
def getCmdLine(d):
"""
Helper function to return a properly formatted command line argument(s)
@@ -168,6 +178,7 @@ def buildDefault(
getCCSpec(compiler),
getDsymutilSpec(),
getSDKRootSpec(),
+ getModuleCacheSpec(),
getCmdLine(dictionary)])
runBuildCommands(commands, sender=sender)
@@ -191,6 +202,7 @@ def buildDwarf(
getCCSpec(compiler),
getDsymutilSpec(),
getSDKRootSpec(),
+ getModuleCacheSpec(),
getCmdLine(dictionary)])
runBuildCommands(commands, sender=sender)
@@ -214,6 +226,7 @@ def buildDwo(
getCCSpec(compiler),
getDsymutilSpec(),
getSDKRootSpec(),
+ getModuleCacheSpec(),
getCmdLine(dictionary)])
runBuildCommands(commands, sender=sender)
@@ -237,6 +250,7 @@ def buildGModules(
getCCSpec(compiler),
getDsymutilSpec(),
getSDKRootSpec(),
+ getModuleCacheSpec(),
getCmdLine(dictionary)])
lldbtest.system(commands, sender=sender)
Modified: lldb/trunk/test/API/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/API/lit.cfg?rev=374386&r1=374385&r2=374386&view=diff
==============================================================================
--- lldb/trunk/test/API/lit.cfg (original)
+++ lldb/trunk/test/API/lit.cfg Thu Oct 10 10:27:09 2019
@@ -5,6 +5,7 @@
import os
import platform
import shlex
+import shutil
import lit.formats
@@ -52,6 +53,14 @@ if config.shared_libs:
lit_config.warning("unable to inject shared library path on '{}'".format(
platform.system()))
+# Clean the module caches in the test build directory. This is necessary in an
+# incremental build whenever clang changes underneath, so doing it once per
+# lit.py invocation is close enough.
+for cachedir in [config.clang_module_cache, config.lldb_module_cache]:
+ if os.path.isdir(cachedir):
+ print("Deleting module cache at %s."%cachedir)
+ shutil.rmtree(cachedir)
+
# Build dotest command.
dotest_cmd = [config.dotest_path]
dotest_cmd.extend(config.dotest_args_str.split(';'))
@@ -70,7 +79,10 @@ if config.lldb_build_directory:
dotest_cmd += ['--build-dir', config.lldb_build_directory]
if config.lldb_module_cache:
- dotest_cmd += ['--module-cache-dir', config.lldb_module_cache]
+ dotest_cmd += ['--lldb-module-cache-dir', config.lldb_module_cache]
+
+if config.clang_module_cache:
+ dotest_cmd += ['--clang-module-cache-dir', config.clang_module_cache]
# Load LLDB test format.
sys.path.append(os.path.join(config.lldb_src_root, "test", "API"))
Modified: lldb/trunk/test/API/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/API/lit.site.cfg.in?rev=374386&r1=374385&r2=374386&view=diff
==============================================================================
--- lldb/trunk/test/API/lit.site.cfg.in (original)
+++ lldb/trunk/test/API/lit.site.cfg.in Thu Oct 10 10:27:09 2019
@@ -17,13 +17,14 @@ config.shared_libs = @LLVM_ENABLE_SHARED
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.target_triple = "@TARGET_TRIPLE@"
config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
-config.lldb_module_cache = "@LLDB_TEST_MODULE_CACHE_LLDB@"
-config.clang_module_cache = "@LLDB_TEST_MODULE_CACHE_CLANG@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.dotest_path = "@LLDB_SOURCE_DIR@/test/API/dotest.py"
config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
config.lldb_disable_python = @LLDB_DISABLE_PYTHON@
config.dotest_lit_args_str = None
+# The API tests use their own module caches.
+config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api")
+config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api")
# Additional dotest arguments can be passed to lit by providing a
# semicolon-separates list: --param dotest-args="arg;arg".
Modified: lldb/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/CMakeLists.txt?rev=374386&r1=374385&r2=374386&view=diff
==============================================================================
--- lldb/trunk/test/CMakeLists.txt (original)
+++ lldb/trunk/test/CMakeLists.txt Thu Oct 10 10:27:09 2019
@@ -3,6 +3,12 @@
add_subdirectory(API)
+# Configure and create module cache directories.
+set(LLDB_TEST_MODULE_CACHE_LLDB "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-lldb" CACHE PATH "The Clang module cache used by the Clang embedded in LLDB while running tests.")
+set(LLDB_TEST_MODULE_CACHE_CLANG "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-clang" CACHE PATH "The Clang module cache used by the Clang while building tests.")
+file(MAKE_DIRECTORY ${LLDB_TEST_MODULE_CACHE_LLDB})
+file(MAKE_DIRECTORY ${LLDB_TEST_MODULE_CACHE_CLANG})
+
# LLVM_BUILD_MODE is used in lit.site.cfg
if (CMAKE_CFG_INTDIR STREQUAL ".")
set(LLVM_BUILD_MODE ".")
@@ -17,8 +23,6 @@ endif()
get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
set(dotest_args_replacement ${LLVM_BUILD_MODE})
-set(LLDB_TEST_MODULE_CACHE_LLDB "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-lldb" CACHE PATH "The Clang module cache used by the Clang embedded in LLDB while running tests.")
-set(LLDB_TEST_MODULE_CACHE_CLANG "${LLDB_TEST_BUILD_DIRECTORY}/module-cache-clang" CACHE PATH "The Clang module cache used by the Clang while building tests.")
if(LLDB_BUILT_STANDALONE)
# In paths to our build-tree, replace CMAKE_CFG_INTDIR with our configuration name placeholder.
Modified: lldb/trunk/test/Shell/lit.cfg.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/lit.cfg.py?rev=374386&r1=374385&r2=374386&view=diff
==============================================================================
--- lldb/trunk/test/Shell/lit.cfg.py (original)
+++ lldb/trunk/test/Shell/lit.cfg.py Thu Oct 10 10:27:09 2019
@@ -69,9 +69,9 @@ llvm_config.feature_config(
# incremental build whenever clang changes underneath, so doing it once per
# lit.py invocation is close enough.
for cachedir in [config.clang_module_cache, config.lldb_module_cache]:
- if os.path.isdir(cachedir):
- print("Deleting module cache at %s."%cachedir)
- shutil.rmtree(cachedir)
+ if os.path.isdir(cachedir):
+ print("Deleting module cache at %s."%cachedir)
+ shutil.rmtree(cachedir)
# Set a default per-test timeout of 10 minutes. Setting a timeout per test
# requires that killProcessAndChildren() is supported on the platform and
Modified: lldb/trunk/test/Shell/lit.site.cfg.py.in
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/Shell/lit.site.cfg.py.in?rev=374386&r1=374385&r2=374386&view=diff
==============================================================================
--- lldb/trunk/test/Shell/lit.site.cfg.py.in (original)
+++ lldb/trunk/test/Shell/lit.site.cfg.py.in Thu Oct 10 10:27:09 2019
@@ -20,8 +20,9 @@ config.host_triple = "@LLVM_HOST_TRIPLE@
config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
config.lldb_disable_python = @LLDB_DISABLE_PYTHON@
config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
-config.lldb_module_cache = "@LLDB_TEST_MODULE_CACHE_LLDB@"
-config.clang_module_cache = "@LLDB_TEST_MODULE_CACHE_CLANG@"
+# The shell tests use their own module caches.
+config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-shell")
+config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-shell")
# Support substitution of the tools and libs dirs with user parameters. This is
# used when we can't determine the tool dir at configuration time.
@@ -32,7 +33,6 @@ try:
config.lldb_libs_dir = config.lldb_libs_dir % lit_config.params
config.lldb_tools_dir = config.lldb_tools_dir % lit_config.params
config.lldb_lit_tools_dir = config.lldb_lit_tools_dir % lit_config.params
-
except KeyError as e:
key, = e.args
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
More information about the lldb-commits
mailing list