summaryrefslogtreecommitdiff
path: root/test/lsan/lit.common.cfg
diff options
context:
space:
mode:
Diffstat (limited to 'test/lsan/lit.common.cfg')
-rw-r--r--test/lsan/lit.common.cfg51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/lsan/lit.common.cfg b/test/lsan/lit.common.cfg
new file mode 100644
index 000000000000..bd1aa2769c42
--- /dev/null
+++ b/test/lsan/lit.common.cfg
@@ -0,0 +1,51 @@
+# -*- Python -*-
+
+# Common configuration for running leak detection tests under LSan/ASan.
+
+import os
+
+def get_required_attr(config, attr_name):
+ attr_value = getattr(config, attr_name, None)
+ if attr_value == None:
+ 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 source root.
+config.test_source_root = os.path.dirname(__file__)
+
+# Choose between standalone and LSan+ASan modes.
+lsan_lit_test_mode = get_required_attr(config, 'lsan_lit_test_mode')
+if lsan_lit_test_mode == "Standalone":
+ config.name = "LeakSanitizer-Standalone"
+ lsan_cflags = ["-fsanitize=leak"]
+elif lsan_lit_test_mode == "AddressSanitizer":
+ config.name = "LeakSanitizer-AddressSanitizer"
+ lsan_cflags = ["-fsanitize=address"]
+ config.available_features.add('asan')
+else:
+ lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode)
+
+clang_cflags = ["-O0", "-m64"] + config.debug_info_flags
+clang_cxxflags = config.cxx_mode_flags + clang_cflags
+clang_lsan_cflags = clang_cflags + lsan_cflags
+clang_lsan_cxxflags = clang_cxxflags + lsan_cflags
+
+config.clang_cflags = clang_cflags
+config.clang_cxxflags = clang_cxxflags
+
+def build_invocation(compile_flags):
+ return " " + " ".join([config.clang] + compile_flags) + " "
+
+config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
+config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
+config.substitutions.append( ("%clang_lsan ", build_invocation(clang_lsan_cflags)) )
+config.substitutions.append( ("%clangxx_lsan ", build_invocation(clang_lsan_cxxflags)) )
+
+# LeakSanitizer tests are currently supported on x86-64 Linux only.
+if config.host_os not in ['Linux'] or config.host_arch not in ['x86_64']:
+ config.unsupported = True
+
+config.suffixes = ['.c', '.cc', '.cpp']