summaryrefslogtreecommitdiff
path: root/lib/dfsan/lit_tests/lit.cfg
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dfsan/lit_tests/lit.cfg')
-rw-r--r--lib/dfsan/lit_tests/lit.cfg66
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/dfsan/lit_tests/lit.cfg b/lib/dfsan/lit_tests/lit.cfg
new file mode 100644
index 000000000..ce39f4a50
--- /dev/null
+++ b/lib/dfsan/lit_tests/lit.cfg
@@ -0,0 +1,66 @@
+# -*- Python -*-
+
+import os
+
+def get_required_attr(config, attr_name):
+ attr_value = getattr(config, attr_name, None)
+ if not attr_value:
+ lit.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 = 'DataFlowSanitizer'
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)
+
+def DisplayNoConfigMessage():
+ lit.fatal("No site specific configuration available! " +
+ "Try running your test from the build tree or running " +
+ "make check-dfsan")
+
+# 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.
+ dfsan_site_cfg = lit.params.get('dfsan_site_config', None)
+ if (dfsan_site_cfg) and (os.path.exists(dfsan_site_cfg)):
+ lit.load_config(config, dfsan_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()
+ dfsan_site_cfg = os.path.join(llvm_obj_root, "projects", "compiler-rt",
+ "lib", "dfsan", "lit_tests", "lit.site.cfg")
+ if (not dfsan_site_cfg) or (not os.path.exists(dfsan_site_cfg)):
+ DisplayNoConfigMessage()
+
+ lit.load_config(config, dfsan_site_cfg)
+ raise SystemExit
+
+# Setup default compiler flags used with -fsanitize=dataflow option.
+clang_dfsan_cflags = ["-fsanitize=dataflow"]
+clang_dfsan_cxxflags = ["-ccc-cxx "] + clang_dfsan_cflags
+config.substitutions.append( ("%clang_dfsan ",
+ " ".join([config.clang] + clang_dfsan_cflags) +
+ " ") )
+config.substitutions.append( ("%clangxx_dfsan ",
+ " ".join([config.clang] + clang_dfsan_cxxflags) +
+ " ") )
+
+# Default test suffixes.
+config.suffixes = ['.c', '.cc', '.cpp']
+
+# DataFlowSanitizer tests are currently supported on Linux only.
+if config.host_os not in ['Linux']:
+ config.unsupported = True