JDevlieghere updated this revision to Diff 144853.
JDevlieghere retitled this revision from "[lit] Make debugserver available to 
lit test" to "[CMake] Unify and relayer testing".
JDevlieghere edited the summary of this revision.
JDevlieghere added reviewers: labath, aprantl.
JDevlieghere added a comment.

- Relayer and unify test dependencies between lit and dotest
- Extract lldb dotest to utils.
- Replace generator expressions with configuration variables


https://reviews.llvm.org/D46334

Files:
  CMakeLists.txt
  lit/CMakeLists.txt
  lit/Suite/lit.site.cfg.in
  test/CMakeLists.txt
  test/lldb-dotest.in
  utils/lldb-dotest/CMakeLists.txt
  utils/lldb-dotest/lldb-dotest.in

Index: utils/lldb-dotest/CMakeLists.txt
===================================================================
--- /dev/null
+++ utils/lldb-dotest/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Make lldb-dotest a custom target.
+add_custom_target(lldb-dotest)
+add_dependencies(lldb-dotest ${LLDB_TEST_DEPS})
+
+# Generate wrapper for each build mode.
+if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
+  foreach(LLVM_BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
+    string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
+    string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_DOTEST_ARGS "${LLDB_DOTEST_ARGS}")
+    configure_file(
+      lldb-dotest.in
+      ${LLDB_DOTEST_DIR}/lldb-dotest
+      )
+  endforeach()
+else()
+  configure_file(
+    lldb-dotest.in
+    ${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb-dotest
+    )
+endif()
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -13,35 +13,6 @@
     )
 endfunction()
 
-set(LLDB_TEST_DEPS lldb)
-
-# darwin-debug is an hard dependency for the testsuite.
-if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  list(APPEND LLDB_TEST_DEPS darwin-debug)
-endif()
-
-if(TARGET lldb-server)
-  list(APPEND LLDB_TEST_DEPS lldb-server)
-endif()
-
-if(TARGET debugserver)
-  if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY)
-    list(APPEND LLDB_TEST_DEPS debugserver)
-  endif()
-endif()
-
-if(TARGET lldb-mi)
-  list(APPEND LLDB_TEST_DEPS lldb-mi)
-endif()
-
-if(NOT LLDB_BUILT_STANDALONE)
-  list(APPEND LLDB_TEST_DEPS yaml2obj dsymutil)
-endif()
-
-if(TARGET liblldb)
-  list(APPEND LLDB_TEST_DEPS liblldb)
-endif()
-
 # The default architecture with which to compile test executables is the default LLVM target
 # architecture, which itself defaults to the host architecture.
 string(TOLOWER "${LLVM_TARGET_ARCH}" LLDB_DEFAULT_TEST_ARCH)
@@ -75,24 +46,14 @@
   -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>)
+  list(APPEND LLDB_EXECUTABLE_PATH_ARGS -C ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX})
 else()
   list(APPEND LLDB_EXECUTABLE_PATH_ARGS -C ${LLDB_TEST_C_COMPILER})
 endif()
@@ -122,31 +83,28 @@
   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>)
+  list(APPEND LLDB_TEST_COMMON_ARGS --framework ${LLVM_LIBRARY_OUTPUT_INTDIR})
 endif()
 
 if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows|Darwin")
   list(APPEND LLDB_TEST_COMMON_ARGS
     --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})
+  if (DEBUGSERVER_PATH STREQUAL "$<TARGET_FILE:debugserver>")
+    list(APPEND LLDB_EXECUTABLE_PATH_ARGS --server ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX})
+  else()
+    list(APPEND LLDB_EXECUTABLE_PATH_ARGS --server ${DEBUGSERVER_PATH})
+  endif()
 endif()
 
 if(SKIP_DEBUGSERVER)
   list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
 endif()
 
-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})
+set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_EXECUTABLE_PATH_ARGS};${LLDB_TEST_USER_ARGS} PARENT_SCOPE)
 
 add_python_test_target(check-lldb-single
   ${LLDB_SOURCE_DIR}/test/dotest.py
@@ -158,38 +116,6 @@
 # output is desired (i.e. in continuous integration contexts) check-lldb-single is a better target.
 add_custom_target(check-lldb)
 
-# Generate a wrapper for dotest.py in the bin directory.
-# We need configure_file to substitute variables.
-configure_file(
-  lldb-dotest.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lldb-dotest.configured
-  )
-# 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
-  INPUT
-  ${CMAKE_CURRENT_BINARY_DIR}/lldb-dotest.configured
-  )
-# Make this a custom target.
-add_custom_target(lldb-dotest)
-add_dependencies(lldb-dotest ${LLDB_TEST_DEPS})
-
-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)
-
 # If we're building with an in-tree clang, then list clang as a dependency
 # to run tests.
 if (TARGET clang)
Index: lit/Suite/lit.site.cfg.in
===================================================================
--- lit/Suite/lit.site.cfg.in
+++ lit/Suite/lit.site.cfg.in
@@ -12,7 +12,7 @@
 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_STR@"
+config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
 
 # 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.
Index: lit/CMakeLists.txt
===================================================================
--- lit/CMakeLists.txt
+++ lit/CMakeLists.txt
@@ -17,6 +17,7 @@
 
 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 "${LLDB_DOTEST_ARGS}")
 
 if(BUILD_SHARED_LIBS)
   set(ENABLE_SHARED 1)
@@ -33,34 +34,24 @@
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
-  )
+  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/Suite/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/Suite/lit.site.cfg)
 
-set(LLDB_TEST_DEPS
+list(APPEND LLDB_TEST_DEPS
   LLDBUnitTests
-  dsymutil
-  lldb
   lldb-test
   llvm-config
   llvm-mc
   llvm-objcopy
   )
 
 if(NOT LLDB_BUILT_STANDALONE)
-  list(APPEND LLDB_TEST_DEPS FileCheck not yaml2obj)
-endif()
-  
-# lldb-server is not built on every platform.
-if (TARGET lldb-server)
-  list(APPEND LLDB_TEST_DEPS lldb-server)
-endif()
-  
-if(APPLE)
-  list(APPEND LLDB_TEST_DEPS debugserver)
-endif()
-
-if(TARGET clang)
-  list(APPEND LLDB_TEST_DEPS clang)
+  list(APPEND LLDB_TEST_DEPS
+    FileCheck
+    not
+    )
 endif()
 
 set(LLDB_TEST_PARAMS
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -85,9 +85,43 @@
     message(FATAL_ERROR "LLDB test compilers not specified.  Tests will not run")
   endif()
 
+  set(LLDB_TEST_DEPS lldb)
+
+  # darwin-debug is an hard dependency for the testsuite.
+  if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+    list(APPEND LLDB_TEST_DEPS darwin-debug)
+  endif()
+
+  if(TARGET lldb-server)
+    list(APPEND LLDB_TEST_DEPS lldb-server)
+  endif()
+
+  if(TARGET debugserver)
+    if(NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY)
+      list(APPEND LLDB_TEST_DEPS debugserver)
+    endif()
+  endif()
+
+  if(TARGET lldb-mi)
+    list(APPEND LLDB_TEST_DEPS lldb-mi)
+  endif()
+
+  if(NOT LLDB_BUILT_STANDALONE)
+    list(APPEND LLDB_TEST_DEPS yaml2obj dsymutil)
+  endif()
+
+  if(TARGET liblldb)
+    list(APPEND LLDB_TEST_DEPS liblldb)
+  endif()
+
+  if(TARGET clang)
+    list(APPEND LLDB_TEST_DEPS clang)
+  endif()
+
   add_subdirectory(test)
   add_subdirectory(unittests)
   add_subdirectory(lit)
+  add_subdirectory(utils/lldb-dotest)
 endif()
 
 if (NOT LLDB_DISABLE_PYTHON)
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to