[Lldb-commits] [lldb] r330518 - [lit] Generate a single lit cfg file for tests that require dotest.py

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Sat Apr 21 11:23:04 PDT 2018


Author: jdevlieghere
Date: Sat Apr 21 11:23:04 2018
New Revision: 330518

URL: http://llvm.org/viewvc/llvm-project?rev=330518&view=rev
Log:
[lit] Generate a single lit cfg file for tests that require dotest.py

The current way that the lit configuration is generated for the LLDB
tests that run using dotest causes cmake to fail when using a generator
which supports multiple configurations (such as Visual Studio). The
failure is because file GENERATE will create a file *per possible
configuration* resulting in the same lit configuration file being
overwritten multiple times.

To fix the issue, we need to create a single lit file that is agnostic
of the configurations and can be used for any configuration.

Patch by: Stella Stamenova

Differential revision: https://reviews.llvm.org/D45918

Modified:
    lldb/trunk/lit/Suite/lit.site.cfg.in
    lldb/trunk/test/CMakeLists.txt

Modified: lldb/trunk/lit/Suite/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Suite/lit.site.cfg.in?rev=330518&r1=330517&r2=330518&view=diff
==============================================================================
--- lldb/trunk/lit/Suite/lit.site.cfg.in (original)
+++ lldb/trunk/lit/Suite/lit.site.cfg.in Sat Apr 21 11:23:04 2018
@@ -12,13 +12,14 @@ config.lldb_src_root = "@LLDB_SOURCE_DIR
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.dotest_path = "@LLDB_SOURCE_DIR@/test/dotest.py"
-config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
+config.dotest_args_str = "@LLDB_DOTEST_ARGS_STR@"
 
 # 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.
 try:
     config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
     config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
+    config.dotest_args_str = config.dotest_args_str % lit_config.params
     config.llvm_build_mode = config.llvm_build_mode % lit_config.params
 except KeyError as e:
     key, = e.args

Modified: lldb/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/CMakeLists.txt?rev=330518&r1=330517&r2=330518&view=diff
==============================================================================
--- lldb/trunk/test/CMakeLists.txt (original)
+++ lldb/trunk/test/CMakeLists.txt Sat Apr 21 11:23:04 2018
@@ -51,8 +51,8 @@ endif ()
 
 # Allow the user to override the default by setting LLDB_TEST_ARCH
 set(LLDB_TEST_ARCH
-	${LLDB_DEFAULT_TEST_ARCH}
-	CACHE STRING "Specify the architecture to run LLDB tests as (x86|x64).  Determines whether tests are compiled with -m32 or -m64")
+  ${LLDB_DEFAULT_TEST_ARCH}
+  CACHE STRING "Specify the architecture to run LLDB tests as (x86|x64).  Determines whether tests are compiled with -m32 or -m64")
 
 # Users can override LLDB_TEST_USER_ARGS to specify arbitrary arguments to pass to the script
 set(LLDB_TEST_USER_ARGS
@@ -66,8 +66,6 @@ set(LLDB_TEST_USER_ARGS
 # the build directory.
 set(LLDB_TEST_COMMON_ARGS
   --arch=${LLDB_TEST_ARCH}
-  --executable $<TARGET_FILE:lldb>
-  --dsymutil $<TARGET_FILE:dsymutil>
   -s
   ${CMAKE_BINARY_DIR}/lldb-test-traces
   --build-dir
@@ -75,9 +73,30 @@ set(LLDB_TEST_COMMON_ARGS
   -S nm
   -u CXXFLAGS
   -u CFLAGS
+  )
+
+# We need two properties here, because they are used for different purposes. When we are generating
+# one file per configuration for lldb-dotest, we want the paths to be configuration specific. However,
+# when we are generating a single lit file, the file itself should not be per configuration and the paths
+# contained inside should be generic also.
+set(LLDB_EXECUTABLE_PATH_ARGS
+  --executable $<TARGET_FILE:lldb>
+  --dsymutil $<TARGET_FILE:dsymutil>
+  )
+set(LLDB_EXECUTABLE_PATH_ARGS_STR
+  --executable ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}
+  --dsymutil ${LLVM_RUNTIME_OUTPUT_INTDIR}/dsymutil${CMAKE_EXECUTABLE_SUFFIX}
   -C ${LLDB_TEST_C_COMPILER}
   )
 
+# There's an additional complication which is that when the compiler is NOT a custom compiler, we need to
+# make sure to get the configuration specific path as well
+if (NOT LLDB_TEST_USE_CUSTOM_C_COMPILER)
+  list(APPEND LLDB_EXECUTABLE_PATH_ARGS -C $<TARGET_FILE:clang>)
+else()
+  list(APPEND LLDB_EXECUTABLE_PATH_ARGS -C ${LLDB_TEST_C_COMPILER})
+endif()
+
 if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
   # All tests are currently flaky on Windows, so rerun them all once when they fail.
   set(LLDB_TEST_COMMON_ARGS ${LLDB_TEST_COMMON_ARGS} --rerun-all-issues)
@@ -103,6 +122,9 @@ if(LLDB_CODESIGN_IDENTITY)
   list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY}")
 endif()
 
+# The framework path is passed to the test arguments as $<TARGET_FILE_DIR:liblldb>. This won't work in the
+# LLDB_DOTEST_ARGS_STR when using a generator that supports multiple configurations such as Visual Studio,
+# but since the framework is currently confined to Darwin/Apple, we can leave it as is.
 if(LLDB_BUILD_FRAMEWORK)
   list(APPEND LLDB_TEST_COMMON_ARGS --framework $<TARGET_FILE_DIR:liblldb>)
 endif()
@@ -112,6 +134,9 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Wi
     --env ARCHIVER=${CMAKE_AR} --env OBJCOPY=${CMAKE_OBJCOPY})
 endif()
 
+# In some cases, DEBUGSERVER_PATH is expressed as $<TARGET_FILE:debugserver>. This won't work in the
+# LLDB_DOTEST_ARGS_STR when using a generator that supports multiple configurations such as Visual Studio,
+# but since debugserver is currently confined to Darwin/Apple, we can leave it as is.
 if(CMAKE_HOST_APPLE)
   list(APPEND LLDB_TEST_COMMON_ARGS --server ${DEBUGSERVER_PATH})
 endif()
@@ -120,7 +145,8 @@ if(SKIP_DEBUGSERVER)
   list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
 endif()
 
-set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS})
+set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_EXECUTABLE_PATH_ARGS};${LLDB_TEST_USER_ARGS})
+set(LLDB_DOTEST_ARGS_STR ${LLDB_TEST_COMMON_ARGS};${LLDB_EXECUTABLE_PATH_ARGS_STR};${LLDB_TEST_USER_ARGS})
 
 add_python_test_target(check-lldb-single
   ${LLDB_SOURCE_DIR}/test/dotest.py
@@ -138,7 +164,8 @@ configure_file(
   lldb-dotest.in
   ${CMAKE_CURRENT_BINARY_DIR}/lldb-dotest.configured
   )
-# We need this to expand the generator expressions.
+# We need this to expand the generator expressions. TARGET_FILE_DIR is OK here because we want to
+# generate a copy of lldb-dotest per configuration.
 file(GENERATE
   OUTPUT
   $<TARGET_FILE_DIR:lldb>/lldb-dotest
@@ -149,16 +176,19 @@ file(GENERATE
 add_custom_target(lldb-dotest)
 add_dependencies(lldb-dotest ${LLDB_TEST_DEPS})
 
-configure_file(
+if (CMAKE_CFG_INTDIR STREQUAL ".")
+  set(LLVM_BUILD_MODE ".")
+else ()
+  set(LLVM_BUILD_MODE "%(build_mode)s")
+endif ()
+
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
+string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS_STR "${LLDB_DOTEST_ARGS_STR}")
+
+configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/../lit/Suite/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg
-  )
-file(GENERATE
-  OUTPUT
-  ${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg
-  INPUT
-  ${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg
-  )
+  ${CMAKE_CURRENT_BINARY_DIR}/../lit/Suite/lit.site.cfg)
 
 # If we're building with an in-tree clang, then list clang as a dependency
 # to run tests.




More information about the lldb-commits mailing list