[PATCH] D16855: [msan] Run the tests for each supported arch and suffix each one to distinguish them.

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 08:15:35 PST 2016


dsanders created this revision.
dsanders added a reviewer: samsonov.
dsanders added a subscriber: llvm-commits.
Herald added subscribers: srhines, danalbert, tberghammer.

Previously, the tests only ran for the 64-bit equivalent of the default target
(see -m64).
Given the supported architecture list only contains 64-bit targets, this happens
to work out the same as the supported targets in most cases but may matter for
X86_64/X86_64h on Darwin.

For other targets, the practical effect is that the test names contain the
architecture. This resolves some confusion when msan tests fail since their
name no longer implies that they are trying to test the default target.

http://reviews.llvm.org/D16855

Files:
  test/msan/CMakeLists.txt
  test/msan/lit.cfg
  test/msan/lit.site.cfg.in

Index: test/msan/lit.site.cfg.in
===================================================================
--- test/msan/lit.site.cfg.in
+++ test/msan/lit.site.cfg.in
@@ -1,5 +1,11 @@
+## Autogenerated by LLVM/Clang configuration.
+# Do not edit!
+
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
 
+# Tool-specific config options.
+config.name_suffix = "@MSAN_TEST_CONFIG_SUFFIX@"
+config.target_cflags = "@MSAN_TEST_TARGET_CFLAGS@"
 # Load tool-specific config that would do the real work.
 lit_config.load_config(config, "@MSAN_LIT_SOURCE_DIR@/lit.cfg")
Index: test/msan/lit.cfg
===================================================================
--- test/msan/lit.cfg
+++ test/msan/lit.cfg
@@ -3,17 +3,18 @@
 import os
 
 # Setup config name.
-config.name = 'MemorySanitizer'
+config.name = 'MemorySanitizer' + config.name_suffix
 
 # Setup source root.
 config.test_source_root = os.path.dirname(__file__)
 
 # Setup default compiler flags used with -fsanitize=memory option.
-clang_msan_cflags = ["-fsanitize=memory",
-                     "-mno-omit-leaf-frame-pointer",
-                     "-fno-omit-frame-pointer",
-                     "-fno-optimize-sibling-calls",
-                     "-m64"] + config.debug_info_flags
+clang_msan_cflags = (["-fsanitize=memory",
+                      "-mno-omit-leaf-frame-pointer",
+                      "-fno-omit-frame-pointer",
+                      "-fno-optimize-sibling-calls"] +
+                      [config.target_cflags] +
+                      config.debug_info_flags)
 # Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD.
 if config.host_os == 'FreeBSD':
   clang_msan_cflags += ["-lexecinfo"]
Index: test/msan/CMakeLists.txt
===================================================================
--- test/msan/CMakeLists.txt
+++ test/msan/CMakeLists.txt
@@ -1,8 +1,32 @@
 set(MSAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+set(MSAN_TESTSUITES)
+
+set(MSAN_TEST_ARCH ${MSAN_SUPPORTED_ARCH})
+if(APPLE)
+  darwin_filter_host_archs(MSAN_SUPPORTED_ARCH MSAN_TEST_ARCH)
+endif()
+
+foreach(arch ${MSAN_TEST_ARCH})
+  string(TOLOWER "-${arch}" MSAN_TEST_CONFIG_SUFFIX)
+  if(ANDROID OR ${arch} MATCHES "arm|aarch64")
+    # This is only true if we are cross-compiling.
+    # Build all tests with host compiler and use host tools.
+    set(MSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
+    set(MSAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS})
+  else()
+    get_target_flags_for_arch(${arch} MSAN_TEST_TARGET_CFLAGS)
+    string(REPLACE ";" " " MSAN_TEST_TARGET_CFLAGS "${MSAN_TEST_TARGET_CFLAGS}")
+  endif()
+
+  string(TOUPPER ${arch} ARCH_UPPER_CASE)
+  set(CONFIG_NAME ${ARCH_UPPER_CASE}Config)
+
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+    ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
+  list(APPEND MSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
+endforeach()
 
 set(MSAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
 if(NOT COMPILER_RT_STANDALONE_BUILD)
@@ -17,7 +41,7 @@
 endif()
 
 add_lit_testsuite(check-msan "Running the MemorySanitizer tests"
-  ${CMAKE_CURRENT_BINARY_DIR}
+  ${MSAN_TESTSUITES}
   DEPENDS ${MSAN_TEST_DEPS}
   )
 set_target_properties(check-msan PROPERTIES FOLDER "MSan tests")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16855.46792.patch
Type: text/x-patch
Size: 3483 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160203/82e7fd9d/attachment.bin>


More information about the llvm-commits mailing list