First tiny move towards integrating AddressSanitizer regressions test into LLVM lit-based testing infrastructure.
The goal is to be able to run ASan tests by simply running "make check-asan" command from CMake build tree:
* tests should use fresh clang binary from current build tree.
* tests should use the same RUN-lines syntax as llvm/clang reg tests.
Next steps:
- restricting tests to machines where target is equal to host, i.e. where we can produce working binaries.
- moving AddressSanitizer unit tests to lit as well.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@161050 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/lit.common.cfg b/lib/lit.common.cfg
new file mode 100644
index 0000000..725156b
--- /dev/null
+++ b/lib/lit.common.cfg
@@ -0,0 +1,45 @@
+# -*- Python -*-
+
+# Configuration file for 'lit' test runner.
+# This file contains common rules for various compiler-rt testsuites.
+# It is mostly copied from lit.cfg used by Clang.
+import os
+import platform
+
+# Setup test format
+execute_external = (platform.system() != 'Windows'
+ or lit.getBashPath() not in [None, ""])
+config.test_format = lit.formats.ShTest(execute_external)
+
+# Setup clang binary.
+clang_path = getattr(config, 'clang', None)
+if (not clang_path) or (not os.path.exists(clang_path)):
+ lit.fatal("Can't find Clang on path %r" % clang_path)
+if not lit.quiet:
+ lit.note("using clang: %r" % clang_path)
+
+# Clear some environment variables that might affect Clang.
+possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
+ 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
+ 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
+ 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
+ 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
+ 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
+ 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
+ 'LIBCLANG_RESOURCE_USAGE',
+ 'LIBCLANG_CODE_COMPLETION_LOGGING']
+# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
+if platform.system() != 'Windows':
+ possibly_dangerous_env_vars.append('INCLUDE')
+for name in possibly_dangerous_env_vars:
+ if name in config.environment:
+ del config.environment[name]
+
+# Define %clang substitution to use in test RUN lines.
+config.substitutions.append( ("%clang ", (" " + config.clang + " ")) )
+
+# Use ugly construction to explicitly prohibit "clang", "clang++" etc.
+# in RUN lines.
+config.substitutions.append(
+ (' clang', """\n\n*** Do not use 'clangXXX' in tests,
+ instead define '%clangXXX' substitution in lit config. ***\n\n""") )