[compiler-rt] r194698 - [UBSan] Make sure ASan and UBSan interact properly by running each test from UBSan test suite with and without ASan
Alexey Samsonov
samsonov at google.com
Thu Nov 14 04:30:09 PST 2013
Author: samsonov
Date: Thu Nov 14 06:30:09 2013
New Revision: 194698
URL: http://llvm.org/viewvc/llvm-project?rev=194698&view=rev
Log:
[UBSan] Make sure ASan and UBSan interact properly by running each test from UBSan test suite with and without ASan
Added:
compiler-rt/trunk/lib/ubsan/lit_tests/AsanConfig/
compiler-rt/trunk/lib/ubsan/lit_tests/AsanConfig/lit.cfg
compiler-rt/trunk/lib/ubsan/lit_tests/AsanConfig/lit.site.cfg.in
compiler-rt/trunk/lib/ubsan/lit_tests/TestCases/
compiler-rt/trunk/lib/ubsan/lit_tests/TestCases/Float/
- copied from r194684, compiler-rt/trunk/lib/ubsan/lit_tests/Float/
compiler-rt/trunk/lib/ubsan/lit_tests/TestCases/Integer/
- copied from r194684, compiler-rt/trunk/lib/ubsan/lit_tests/Integer/
compiler-rt/trunk/lib/ubsan/lit_tests/TestCases/Misc/
- copied from r194684, compiler-rt/trunk/lib/ubsan/lit_tests/Misc/
compiler-rt/trunk/lib/ubsan/lit_tests/TestCases/TypeCheck/
- copied from r194684, compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/
compiler-rt/trunk/lib/ubsan/lit_tests/UbsanConfig/
compiler-rt/trunk/lib/ubsan/lit_tests/UbsanConfig/lit.cfg
compiler-rt/trunk/lib/ubsan/lit_tests/UbsanConfig/lit.site.cfg.in
compiler-rt/trunk/lib/ubsan/lit_tests/lit.common.cfg
- copied, changed from r194684, compiler-rt/trunk/lib/ubsan/lit_tests/lit.cfg
Removed:
compiler-rt/trunk/lib/ubsan/lit_tests/Float/
compiler-rt/trunk/lib/ubsan/lit_tests/Integer/
compiler-rt/trunk/lib/ubsan/lit_tests/Misc/
compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/
compiler-rt/trunk/lib/ubsan/lit_tests/lit.cfg
compiler-rt/trunk/lib/ubsan/lit_tests/lit.site.cfg.in
Modified:
compiler-rt/trunk/lib/ubsan/lit_tests/CMakeLists.txt
Added: compiler-rt/trunk/lib/ubsan/lit_tests/AsanConfig/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/AsanConfig/lit.cfg?rev=194698&view=auto
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/AsanConfig/lit.cfg (added)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/AsanConfig/lit.cfg Thu Nov 14 06:30:09 2013
@@ -0,0 +1,25 @@
+# -*- Python -*-
+
+import os
+
+def get_required_attr(config, attr_name):
+ attr_value = getattr(config, attr_name, None)
+ if not attr_value:
+ lit_config.fatal(
+ "No attribute %r in test configuration! You may need to run "
+ "tests from your build directory or add this attribute "
+ "to lit.site.cfg " % attr_name)
+ return attr_value
+
+ubsan_lit_tests_dir = get_required_attr(config, "ubsan_lit_tests_dir")
+ubsan_lit_cfg = os.path.join(ubsan_lit_tests_dir, "lit.common.cfg")
+lit_config.load_config(config, ubsan_lit_cfg)
+
+config.name = 'UndefinedBehaviorSanitizer-AddressSanitizer'
+
+# Define %clang and %clangxx substitutions to use in test RUN lines.
+config.substitutions.append( ("%clang ", (" " + config.clang +
+ " -fsanitize=address ")) )
+config.substitutions.append( ("%clangxx ", (" " + config.clang +
+ " -fsanitize=address" +
+ " --driver-mode=g++ ")) )
Added: compiler-rt/trunk/lib/ubsan/lit_tests/AsanConfig/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/AsanConfig/lit.site.cfg.in?rev=194698&view=auto
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/AsanConfig/lit.site.cfg.in (added)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/AsanConfig/lit.site.cfg.in Thu Nov 14 06:30:09 2013
@@ -0,0 +1,9 @@
+# Load common config for all compiler-rt lit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
+
+# Tool-specific config options.
+config.ubsan_lit_tests_dir = "@UBSAN_LIT_TESTS_DIR@"
+
+# Load tool-specific config that would do the real work.
+print config.ubsan_lit_tests_dir
+lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/AsanConfig/lit.cfg")
Modified: compiler-rt/trunk/lib/ubsan/lit_tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/CMakeLists.txt?rev=194698&r1=194697&r2=194698&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/CMakeLists.txt Thu Nov 14 06:30:09 2013
@@ -1,21 +1,23 @@
+set(UBSAN_LIT_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+
+configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/UbsanConfig/lit.site.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/UbsanConfig/lit.site.cfg)
+
configure_lit_site_cfg(
- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
- ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/AsanConfig/lit.site.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/AsanConfig/lit.site.cfg)
if(COMPILER_RT_CAN_EXECUTE_TESTS)
# Run UBSan output tests only if we're sure that clang would produce
# working binaries.
set(UBSAN_TEST_DEPS
${SANITIZER_COMMON_LIT_TEST_DEPS}
- ${UBSAN_RUNTIME_LIBRARIES})
- set(UBSAN_TEST_PARAMS
- ubsan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
- )
+ ${UBSAN_RUNTIME_LIBRARIES}
+ asan_runtime_libraries)
add_lit_testsuite(check-ubsan "Running UndefinedBehaviorSanitizer tests"
- ${CMAKE_CURRENT_BINARY_DIR}
- PARAMS ${UBSAN_TEST_PARAMS}
- DEPENDS ${UBSAN_TEST_DEPS}
- )
+ ${CMAKE_CURRENT_BINARY_DIR}/UbsanConfig
+ ${CMAKE_CURRENT_BINARY_DIR}/AsanConfig
+ DEPENDS ${UBSAN_TEST_DEPS})
set_target_properties(check-ubsan PROPERTIES FOLDER "UBSan unittests")
endif()
Added: compiler-rt/trunk/lib/ubsan/lit_tests/UbsanConfig/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/UbsanConfig/lit.cfg?rev=194698&view=auto
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/UbsanConfig/lit.cfg (added)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/UbsanConfig/lit.cfg Thu Nov 14 06:30:09 2013
@@ -0,0 +1,23 @@
+# -*- Python -*-
+
+import os
+
+def get_required_attr(config, attr_name):
+ attr_value = getattr(config, attr_name, None)
+ if not attr_value:
+ lit_config.fatal(
+ "No attribute %r in test configuration! You may need to run "
+ "tests from your build directory or add this attribute "
+ "to lit.site.cfg " % attr_name)
+ return attr_value
+
+ubsan_lit_tests_dir = get_required_attr(config, "ubsan_lit_tests_dir")
+ubsan_lit_cfg = os.path.join(ubsan_lit_tests_dir, "lit.common.cfg")
+lit_config.load_config(config, ubsan_lit_cfg)
+
+config.name = 'UndefinedBehaviorSanitizer-Standalone'
+
+# Define %clang and %clangxx substitutions to use in test RUN lines.
+config.substitutions.append( ("%clang ", (" " + config.clang + " ")) )
+config.substitutions.append( ("%clangxx ", (" " + config.clang +
+ " --driver-mode=g++ ")) )
Added: compiler-rt/trunk/lib/ubsan/lit_tests/UbsanConfig/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/UbsanConfig/lit.site.cfg.in?rev=194698&view=auto
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/UbsanConfig/lit.site.cfg.in (added)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/UbsanConfig/lit.site.cfg.in Thu Nov 14 06:30:09 2013
@@ -0,0 +1,8 @@
+# Load common config for all compiler-rt lit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
+
+# Tool-specific config options.
+config.ubsan_lit_tests_dir = "@UBSAN_LIT_TESTS_DIR@"
+
+# Load tool-specific config that would do the real work.
+lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/UbsanConfig/lit.cfg")
Removed: compiler-rt/trunk/lib/ubsan/lit_tests/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/lit.cfg?rev=194697&view=auto
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/lit.cfg (original)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/lit.cfg (removed)
@@ -1,65 +0,0 @@
-# -*- Python -*-
-
-import os
-
-def get_required_attr(config, attr_name):
- attr_value = getattr(config, attr_name, None)
- if not attr_value:
- lit_config.fatal(
- "No attribute %r in test configuration! You may need to run "
- "tests from your build directory or add this attribute "
- "to lit.site.cfg " % attr_name)
- return attr_value
-
-# Setup config name.
-config.name = 'UndefinedBehaviorSanitizer'
-
-# Setup source root.
-config.test_source_root = os.path.dirname(__file__)
-
-def DisplayNoConfigMessage():
- lit_config.fatal("No site specific configuration available! " +
- "Try running your test from the build tree or running " +
- "make check-ubsan")
-
-# Figure out LLVM source root.
-llvm_src_root = getattr(config, 'llvm_src_root', None)
-if llvm_src_root is None:
- # We probably haven't loaded the site-specific configuration: the user
- # is likely trying to run a test file directly, and the site configuration
- # wasn't created by the build system or we're performing an out-of-tree build.
- ubsan_site_cfg = lit_config.params.get('ubsan_site_config', None)
- if ubsan_site_cfg and os.path.exists(ubsan_site_cfg):
- lit_config.load_config(config, ubsan_site_cfg)
- raise SystemExit
-
- # Try to guess the location of site-specific configuration using llvm-config
- # util that can point where the build tree is.
- llvm_config = lit.util.which("llvm-config", config.environment["PATH"])
- if not llvm_config:
- DisplayNoConfigMessage()
-
- # Find out the presumed location of generated site config.
- llvm_obj_root = lit.util.capture(["llvm-config", "--obj-root"]).strip()
- ubsan_site_cfg = os.path.join(llvm_obj_root, "projects", "compiler-rt",
- "lib", "ubsan", "lit_tests", "lit.site.cfg")
- if not ubsan_site_cfg or not os.path.exists(ubsan_site_cfg):
- DisplayNoConfigMessage()
-
- lit_config.load_config(config, ubsan_site_cfg)
- raise SystemExit
-
-# Define %clang and %clangxx substitutions to use in test RUN lines.
-config.substitutions.append( ("%clang ", (" " + config.clang + " ")) )
-config.substitutions.append( ("%clangxx ", (" " + config.clang +
- " --driver-mode=g++ ")) )
-
-# Default test suffixes.
-config.suffixes = ['.c', '.cc', '.cpp']
-
-# UndefinedBehaviorSanitizer tests are currently supported on
-# Linux and Darwin only.
-if config.host_os not in ['Linux', 'Darwin']:
- config.unsupported = True
-
-config.pipefail = False
Copied: compiler-rt/trunk/lib/ubsan/lit_tests/lit.common.cfg (from r194684, compiler-rt/trunk/lib/ubsan/lit_tests/lit.cfg)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/lit.common.cfg?p2=compiler-rt/trunk/lib/ubsan/lit_tests/lit.common.cfg&p1=compiler-rt/trunk/lib/ubsan/lit_tests/lit.cfg&r1=194684&r2=194698&rev=194698&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/lit.cfg (original)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/lit.common.cfg Thu Nov 14 06:30:09 2013
@@ -11,49 +11,15 @@ def get_required_attr(config, attr_name)
"to lit.site.cfg " % attr_name)
return attr_value
-# Setup config name.
-config.name = 'UndefinedBehaviorSanitizer'
-
# Setup source root.
-config.test_source_root = os.path.dirname(__file__)
+ubsan_lit_tests_dir = get_required_attr(config, 'ubsan_lit_tests_dir')
+config.test_source_root = os.path.join(ubsan_lit_tests_dir, 'TestCases')
def DisplayNoConfigMessage():
lit_config.fatal("No site specific configuration available! " +
"Try running your test from the build tree or running " +
"make check-ubsan")
-# Figure out LLVM source root.
-llvm_src_root = getattr(config, 'llvm_src_root', None)
-if llvm_src_root is None:
- # We probably haven't loaded the site-specific configuration: the user
- # is likely trying to run a test file directly, and the site configuration
- # wasn't created by the build system or we're performing an out-of-tree build.
- ubsan_site_cfg = lit_config.params.get('ubsan_site_config', None)
- if ubsan_site_cfg and os.path.exists(ubsan_site_cfg):
- lit_config.load_config(config, ubsan_site_cfg)
- raise SystemExit
-
- # Try to guess the location of site-specific configuration using llvm-config
- # util that can point where the build tree is.
- llvm_config = lit.util.which("llvm-config", config.environment["PATH"])
- if not llvm_config:
- DisplayNoConfigMessage()
-
- # Find out the presumed location of generated site config.
- llvm_obj_root = lit.util.capture(["llvm-config", "--obj-root"]).strip()
- ubsan_site_cfg = os.path.join(llvm_obj_root, "projects", "compiler-rt",
- "lib", "ubsan", "lit_tests", "lit.site.cfg")
- if not ubsan_site_cfg or not os.path.exists(ubsan_site_cfg):
- DisplayNoConfigMessage()
-
- lit_config.load_config(config, ubsan_site_cfg)
- raise SystemExit
-
-# Define %clang and %clangxx substitutions to use in test RUN lines.
-config.substitutions.append( ("%clang ", (" " + config.clang + " ")) )
-config.substitutions.append( ("%clangxx ", (" " + config.clang +
- " --driver-mode=g++ ")) )
-
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
Removed: compiler-rt/trunk/lib/ubsan/lit_tests/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/lit.site.cfg.in?rev=194697&view=auto
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/lit.site.cfg.in (original)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/lit.site.cfg.in (removed)
@@ -1,8 +0,0 @@
-## 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@/lib/lit.common.configured")
-
-# Load tool-specific config that would do the real work.
-lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")
More information about the llvm-commits
mailing list