[tests] Update to use lit_config and lit package, as appropriate.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@188116 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/asan/lit_tests/32bitConfig/lit.site.cfg.in b/lib/asan/lit_tests/32bitConfig/lit.site.cfg.in
index 99496c2..faef4e8 100644
--- a/lib/asan/lit_tests/32bitConfig/lit.site.cfg.in
+++ b/lib/asan/lit_tests/32bitConfig/lit.site.cfg.in
@@ -2,12 +2,12 @@
 # Do not edit!
 
 # Load common config for all compiler-rt lit tests.
-lit.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
 
 # Tool-specific config options.
 config.asan_source_dir = "@ASAN_SOURCE_DIR@"
 config.bits = "32"
 
 # Load tool-specific config that would do the real work.
-lit.load_config(config, "@ASAN_SOURCE_DIR@/lit_tests/lit.cfg")
+lit_config.load_config(config, "@ASAN_SOURCE_DIR@/lit_tests/lit.cfg")
 
diff --git a/lib/asan/lit_tests/64bitConfig/lit.site.cfg.in b/lib/asan/lit_tests/64bitConfig/lit.site.cfg.in
index 94b0228..a359944 100644
--- a/lib/asan/lit_tests/64bitConfig/lit.site.cfg.in
+++ b/lib/asan/lit_tests/64bitConfig/lit.site.cfg.in
@@ -2,11 +2,11 @@
 # Do not edit!
 
 # Load common config for all compiler-rt lit tests.
-lit.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
 
 # Tool-specific config options.
 config.asan_source_dir = "@ASAN_SOURCE_DIR@"
 config.bits = "64"
 
 # Load tool-specific config that would do the real work.
-lit.load_config(config, "@ASAN_SOURCE_DIR@/lit_tests/lit.cfg")
+lit_config.load_config(config, "@ASAN_SOURCE_DIR@/lit_tests/lit.cfg")
diff --git a/lib/asan/lit_tests/Unit/lit.site.cfg.in b/lib/asan/lit_tests/Unit/lit.site.cfg.in
index 6864c80..0db0940 100644
--- a/lib/asan/lit_tests/Unit/lit.site.cfg.in
+++ b/lib/asan/lit_tests/Unit/lit.site.cfg.in
@@ -2,7 +2,7 @@
 # Do not edit!
 
 # Load common config for all compiler-rt unit tests.
-lit.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.unit.configured")
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.unit.configured")
 
 # Setup config name.
 config.name = 'AddressSanitizer-Unit'
diff --git a/lib/asan/lit_tests/lit.cfg b/lib/asan/lit_tests/lit.cfg
index 815452d..317ec6f 100644
--- a/lib/asan/lit_tests/lit.cfg
+++ b/lib/asan/lit_tests/lit.cfg
@@ -2,12 +2,15 @@
 
 import os
 
+import lit.util
+
 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)
+    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.
@@ -17,9 +20,9 @@
 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-asan")
+  lit_config.fatal("No site specific configuration available! " +
+                   "Try running your test from the build tree or running " +
+                   "make check-asan")
 
 # Figure out LLVM source root.
 llvm_src_root = getattr(config, 'llvm_src_root', None)
@@ -27,9 +30,9 @@
   # 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.
-  asan_site_cfg = lit.params.get('asan_site_config', None)
+  asan_site_cfg = lit_config.params.get('asan_site_config', None)
   if (asan_site_cfg) and (os.path.exists(asan_site_cfg)):
-    lit.load_config(config, asan_site_cfg)
+    lit_config.load_config(config, asan_site_cfg)
     raise SystemExit
 
   # Try to guess the location of site-specific configuration using llvm-config
@@ -45,7 +48,7 @@
   if (not asan_site_cfg) or (not os.path.exists(asan_site_cfg)):
     DisplayNoConfigMessage()
 
-  lit.load_config(config, asan_site_cfg)
+  lit_config.load_config(config, asan_site_cfg)
   raise SystemExit
 
 # Setup default compiler flags used with -fsanitize=address option.
@@ -74,7 +77,7 @@
 asan_source_dir = get_required_attr(config, "asan_source_dir")
 asan_symbolize = os.path.join(asan_source_dir, "scripts", "asan_symbolize.py")
 if not os.path.exists(asan_symbolize):
-  lit.fatal("Can't find script on path %r" % asan_symbolize)
+  lit_config.fatal("Can't find script on path %r" % asan_symbolize)
 config.substitutions.append( ("%asan_symbolize", " " + asan_symbolize + " ") )
 
 # Define CHECK-%os to check for OS-dependent output.
diff --git a/lib/dfsan/lit_tests/lit.cfg b/lib/dfsan/lit_tests/lit.cfg
index 0daface..19bc976 100644
--- a/lib/dfsan/lit_tests/lit.cfg
+++ b/lib/dfsan/lit_tests/lit.cfg
@@ -2,12 +2,15 @@
 
 import os
 
+import lit.util
+
 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)
+    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.
@@ -17,9 +20,9 @@
 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")
+  lit_config.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)
@@ -27,9 +30,9 @@
   # 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)
+  dfsan_site_cfg = lit_config.params.get('dfsan_site_config', None)
   if (dfsan_site_cfg) and (os.path.exists(dfsan_site_cfg)):
-    lit.load_config(config, dfsan_site_cfg)
+    lit_config.load_config(config, dfsan_site_cfg)
     raise SystemExit
 
   # Try to guess the location of site-specific configuration using llvm-config
@@ -45,7 +48,7 @@
   if (not dfsan_site_cfg) or (not os.path.exists(dfsan_site_cfg)):
     DisplayNoConfigMessage()
 
-  lit.load_config(config, dfsan_site_cfg)
+  lit_config.load_config(config, dfsan_site_cfg)
   raise SystemExit
 
 # Setup default compiler flags used with -fsanitize=dataflow option.
diff --git a/lib/dfsan/lit_tests/lit.site.cfg.in b/lib/dfsan/lit_tests/lit.site.cfg.in
index d9eb836..0cf6d6b 100644
--- a/lib/dfsan/lit_tests/lit.site.cfg.in
+++ b/lib/dfsan/lit_tests/lit.site.cfg.in
@@ -1,5 +1,5 @@
 # Load common config for all compiler-rt lit tests.
-lit.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
 
 # Load tool-specific config that would do the real work.
-lit.load_config(config, "@DFSAN_SOURCE_DIR@/lit_tests/lit.cfg")
+lit_config.load_config(config, "@DFSAN_SOURCE_DIR@/lit_tests/lit.cfg")
diff --git a/lib/lit.common.cfg b/lib/lit.common.cfg
index b19d687..4be6921 100644
--- a/lib/lit.common.cfg
+++ b/lib/lit.common.cfg
@@ -6,15 +6,17 @@
 import os
 import platform
 
+import lit.formats
+
 # Setup test format
 execute_external = (platform.system() != 'Windows'
-                    or lit.getBashPath() not in [None, ""])
+                    or lit_config.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)
+  lit_config.fatal("Can't find Clang on path %r" % clang_path)
 
 # Clear some environment variables that might affect Clang.
 possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
@@ -36,7 +38,7 @@
 # Tweak PATH to include llvm tools dir.
 llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
 if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)):
-  lit.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir)
+  lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir)
 path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
 config.environment['PATH'] = path
 
diff --git a/lib/lit.common.configured.in b/lib/lit.common.configured.in
index f7c29f6..9827a68 100644
--- a/lib/lit.common.configured.in
+++ b/lib/lit.common.configured.in
@@ -16,10 +16,10 @@
 # LLVM tools dir can be passed in lit parameters, so try to
 # apply substitution.
 try:
-  config.llvm_tools_dir = config.llvm_tools_dir % lit.params
+  config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
 except KeyError,e:
   key, = e.args
-  lit.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))
+  lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))
 
 # Setup attributes common for all compiler-rt projects.
-lit.load_config(config, "@COMPILER_RT_SOURCE_DIR@/lib/lit.common.cfg")
+lit_config.load_config(config, "@COMPILER_RT_SOURCE_DIR@/lib/lit.common.cfg")
diff --git a/lib/lit.common.unit.configured.in b/lib/lit.common.unit.configured.in
index 1eac25b..88eeed1 100644
--- a/lib/lit.common.unit.configured.in
+++ b/lib/lit.common.unit.configured.in
@@ -12,11 +12,11 @@
 # LLVM tools dir and build mode can be passed in lit parameters,
 # so try to apply substitution.
 try:
-  config.llvm_tools_dir = config.llvm_tools_dir % lit.params
-  config.llvm_build_mode = config.llvm_build_mode % lit.params
+  config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
+  config.llvm_build_mode = config.llvm_build_mode % lit_config.params
 except KeyError,e:
   key, = e.args
-  lit.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))
+  lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))
 
 # Setup attributes common for all compiler-rt unit tests.
-lit.load_config(config, "@COMPILER_RT_SOURCE_DIR@/lib/lit.common.unit.cfg")
+lit_config.load_config(config, "@COMPILER_RT_SOURCE_DIR@/lib/lit.common.unit.cfg")
diff --git a/lib/lsan/lit_tests/AsanConfig/lit.cfg b/lib/lsan/lit_tests/AsanConfig/lit.cfg
index eb24244..a7df896 100644
--- a/lib/lsan/lit_tests/AsanConfig/lit.cfg
+++ b/lib/lsan/lit_tests/AsanConfig/lit.cfg
@@ -5,16 +5,17 @@
 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)
+    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
 
 lsan_lit_src_root = get_required_attr(config, "lsan_lit_src_root")
 lsan_lit_cfg = os.path.join(lsan_lit_src_root, "lit.common.cfg")
 if not os.path.exists(lsan_lit_cfg):
-  lit.fatal("Can't find common LSan lit config at: %r" % lsan_lit_cfg)
-lit.load_config(config, lsan_lit_cfg)
+  lit_config.fatal("Can't find common LSan lit config at: %r" % lsan_lit_cfg)
+lit_config.load_config(config, lsan_lit_cfg)
 
 config.name = 'LeakSanitizer-AddressSanitizer'
 
diff --git a/lib/lsan/lit_tests/AsanConfig/lit.site.cfg.in b/lib/lsan/lit_tests/AsanConfig/lit.site.cfg.in
index 4557d79..9cf6572 100644
--- a/lib/lsan/lit_tests/AsanConfig/lit.site.cfg.in
+++ b/lib/lsan/lit_tests/AsanConfig/lit.site.cfg.in
@@ -1,8 +1,8 @@
 # Load common config for all compiler-rt lit tests.
-lit.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
 
 # Tool-specific config options.
 config.lsan_lit_src_root = "@LSAN_LIT_SOURCE_DIR@"
 
 # Load tool-specific config that would do the real work.
-lit.load_config(config, "@LSAN_LIT_SOURCE_DIR@/AsanConfig/lit.cfg")
+lit_config.load_config(config, "@LSAN_LIT_SOURCE_DIR@/AsanConfig/lit.cfg")
diff --git a/lib/lsan/lit_tests/LsanConfig/lit.cfg b/lib/lsan/lit_tests/LsanConfig/lit.cfg
index bc1d548..764bf92 100644
--- a/lib/lsan/lit_tests/LsanConfig/lit.cfg
+++ b/lib/lsan/lit_tests/LsanConfig/lit.cfg
@@ -5,16 +5,17 @@
 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)
+    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
 
 lsan_lit_src_root = get_required_attr(config, "lsan_lit_src_root")
 lsan_lit_cfg = os.path.join(lsan_lit_src_root, "lit.common.cfg")
 if not os.path.exists(lsan_lit_cfg):
-  lit.fatal("Can't find common LSan lit config at: %r" % lsan_lit_cfg)
-lit.load_config(config, lsan_lit_cfg)
+  lit_config.fatal("Can't find common LSan lit config at: %r" % lsan_lit_cfg)
+lit_config.load_config(config, lsan_lit_cfg)
 
 config.name = 'LeakSanitizer-Standalone'
 
diff --git a/lib/lsan/lit_tests/LsanConfig/lit.site.cfg.in b/lib/lsan/lit_tests/LsanConfig/lit.site.cfg.in
index 8bc5c41..2a6d724 100644
--- a/lib/lsan/lit_tests/LsanConfig/lit.site.cfg.in
+++ b/lib/lsan/lit_tests/LsanConfig/lit.site.cfg.in
@@ -1,8 +1,8 @@
 # Load common config for all compiler-rt lit tests.
-lit.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
 
 # Tool-specific config options.
 config.lsan_lit_src_root = "@LSAN_LIT_SOURCE_DIR@"
 
 # Load tool-specific config that would do the real work.
-lit.load_config(config, "@LSAN_LIT_SOURCE_DIR@/LsanConfig/lit.cfg")
+lit_config.load_config(config, "@LSAN_LIT_SOURCE_DIR@/LsanConfig/lit.cfg")
diff --git a/lib/lsan/lit_tests/Unit/lit.site.cfg.in b/lib/lsan/lit_tests/Unit/lit.site.cfg.in
index efe8049..a3a4e9a 100644
--- a/lib/lsan/lit_tests/Unit/lit.site.cfg.in
+++ b/lib/lsan/lit_tests/Unit/lit.site.cfg.in
@@ -2,7 +2,7 @@
 # Do not edit!
 
 # Load common config for all compiler-rt unit tests.
-lit.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.unit.configured")
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.unit.configured")
 
 # Setup config name.
 config.name = 'LeakSanitizer-Unit'
diff --git a/lib/lsan/lit_tests/lit.common.cfg b/lib/lsan/lit_tests/lit.common.cfg
index d52f64c..11a40b5 100644
--- a/lib/lsan/lit_tests/lit.common.cfg
+++ b/lib/lsan/lit_tests/lit.common.cfg
@@ -7,9 +7,10 @@
 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)
+    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.
diff --git a/lib/msan/lit_tests/Unit/lit.site.cfg.in b/lib/msan/lit_tests/Unit/lit.site.cfg.in
index 52e1713..8e67f55 100644
--- a/lib/msan/lit_tests/Unit/lit.site.cfg.in
+++ b/lib/msan/lit_tests/Unit/lit.site.cfg.in
@@ -2,7 +2,7 @@
 # Do not edit!
 
 # Load common config for all compiler-rt unit tests.
-lit.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.unit.configured")
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.unit.configured")
 
 # Setup config name.
 config.name = 'MemorySanitizer-Unit'
diff --git a/lib/msan/lit_tests/lit.cfg b/lib/msan/lit_tests/lit.cfg
index bc19b74..093ad94 100644
--- a/lib/msan/lit_tests/lit.cfg
+++ b/lib/msan/lit_tests/lit.cfg
@@ -2,12 +2,15 @@
 
 import os
 
+import lit.util
+
 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)
+    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.
@@ -17,9 +20,9 @@
 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-msan")
+  lit_config.fatal("No site specific configuration available! " +
+                   "Try running your test from the build tree or running " +
+                   "make check-msan")
 
 # Figure out LLVM source root.
 llvm_src_root = getattr(config, 'llvm_src_root', None)
@@ -27,9 +30,9 @@
   # 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.
-  msan_site_cfg = lit.params.get('msan_site_config', None)
+  msan_site_cfg = lit_config.params.get('msan_site_config', None)
   if (msan_site_cfg) and (os.path.exists(msan_site_cfg)):
-    lit.load_config(config, msan_site_cfg)
+    lit_config.load_config(config, msan_site_cfg)
     raise SystemExit
 
   # Try to guess the location of site-specific configuration using llvm-config
@@ -45,7 +48,7 @@
   if (not msan_site_cfg) or (not os.path.exists(msan_site_cfg)):
     DisplayNoConfigMessage()
 
-  lit.load_config(config, msan_site_cfg)
+  lit_config.load_config(config, msan_site_cfg)
   raise SystemExit
 
 # Setup default compiler flags used with -fsanitize=memory option.
diff --git a/lib/msan/lit_tests/lit.site.cfg.in b/lib/msan/lit_tests/lit.site.cfg.in
index 25d378f..946df77 100644
--- a/lib/msan/lit_tests/lit.site.cfg.in
+++ b/lib/msan/lit_tests/lit.site.cfg.in
@@ -1,5 +1,5 @@
 # Load common config for all compiler-rt lit tests.
-lit.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
 
 # Load tool-specific config that would do the real work.
-lit.load_config(config, "@MSAN_SOURCE_DIR@/lit_tests/lit.cfg")
+lit_config.load_config(config, "@MSAN_SOURCE_DIR@/lit_tests/lit.cfg")
diff --git a/lib/sanitizer_common/tests/lit.cfg b/lib/sanitizer_common/tests/lit.cfg
index 303d56c..0712746 100644
--- a/lib/sanitizer_common/tests/lit.cfg
+++ b/lib/sanitizer_common/tests/lit.cfg
@@ -5,16 +5,17 @@
 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)
+    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 attributes common for all compiler-rt projects.
 compiler_rt_src_root = get_required_attr(config, 'compiler_rt_src_root')
 compiler_rt_lit_unit_cfg = os.path.join(compiler_rt_src_root, "lib",
                                         "lit.common.unit.cfg")
-lit.load_config(config, compiler_rt_lit_unit_cfg)
+lit_config.load_config(config, compiler_rt_lit_unit_cfg)
 
 # Setup config name.
 config.name = 'SanitizerCommon-Unit'
diff --git a/lib/sanitizer_common/tests/lit.site.cfg.in b/lib/sanitizer_common/tests/lit.site.cfg.in
index 50485aa..bcd69cf 100644
--- a/lib/sanitizer_common/tests/lit.site.cfg.in
+++ b/lib/sanitizer_common/tests/lit.site.cfg.in
@@ -7,10 +7,10 @@
 config.llvm_build_mode = "@LLVM_BUILD_MODE@"
 
 try:
-  config.llvm_build_mode = config.llvm_build_mode % lit.params
+  config.llvm_build_mode = config.llvm_build_mode % lit_config.params
 except KeyError,e:
   key, = e.args
-  lit.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))
+  lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))
 
 # Let the main config do the real work.
-lit.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")
+lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")
diff --git a/lib/tsan/lit_tests/Unit/lit.cfg b/lib/tsan/lit_tests/Unit/lit.cfg
index 1b8d175..c7aa0c1 100644
--- a/lib/tsan/lit_tests/Unit/lit.cfg
+++ b/lib/tsan/lit_tests/Unit/lit.cfg
@@ -5,9 +5,10 @@
 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)
+    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.
diff --git a/lib/tsan/lit_tests/Unit/lit.site.cfg.in b/lib/tsan/lit_tests/Unit/lit.site.cfg.in
index 964da91..3701a2c 100644
--- a/lib/tsan/lit_tests/Unit/lit.site.cfg.in
+++ b/lib/tsan/lit_tests/Unit/lit.site.cfg.in
@@ -2,7 +2,7 @@
 # Do not edit!
 
 # Load common config for all compiler-rt unit tests.
-lit.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.unit.configured")
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.unit.configured")
 
 # Load tool-specific config that would do the real work.
-lit.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/Unit/lit.cfg")
+lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/Unit/lit.cfg")
diff --git a/lib/tsan/lit_tests/lit.cfg b/lib/tsan/lit_tests/lit.cfg
index ce6c23a..600290d 100644
--- a/lib/tsan/lit_tests/lit.cfg
+++ b/lib/tsan/lit_tests/lit.cfg
@@ -2,12 +2,15 @@
 
 import os
 
+import lit.util
+
 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)
+    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.
@@ -17,9 +20,9 @@
 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-tsan")
+  lit_config.fatal("No site specific configuration available! " +
+                   "Try running your test from the build tree or running " +
+                   "make check-tsan")
 
 # Figure out LLVM source root.
 llvm_src_root = getattr(config, 'llvm_src_root', None)
@@ -27,9 +30,9 @@
   # 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.
-  tsan_site_cfg = lit.params.get('tsan_site_config', None)
+  tsan_site_cfg = lit_config.params.get('tsan_site_config', None)
   if (tsan_site_cfg) and (os.path.exists(tsan_site_cfg)):
-    lit.load_config(config, tsan_site_cfg)
+    lit_config.load_config(config, tsan_site_cfg)
     raise SystemExit
 
   # Try to guess the location of site-specific configuration using llvm-config
@@ -45,7 +48,7 @@
   if (not tsan_site_cfg) or (not os.path.exists(tsan_site_cfg)):
     DisplayNoConfigMessage()
 
-  lit.load_config(config, tsan_site_cfg)
+  lit_config.load_config(config, tsan_site_cfg)
   raise SystemExit
 
 # Setup environment variables for running ThreadSanitizer.
diff --git a/lib/tsan/lit_tests/lit.site.cfg.in b/lib/tsan/lit_tests/lit.site.cfg.in
index a212393..b0e4274 100644
--- a/lib/tsan/lit_tests/lit.site.cfg.in
+++ b/lib/tsan/lit_tests/lit.site.cfg.in
@@ -2,7 +2,7 @@
 # Do not edit!
 
 # Load common config for all compiler-rt lit tests.
-lit.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
 
 # Load tool-specific config that would do the real work.
-lit.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")
+lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")
diff --git a/lib/ubsan/lit_tests/lit.cfg b/lib/ubsan/lit_tests/lit.cfg
index f3fc646..6714a56 100644
--- a/lib/ubsan/lit_tests/lit.cfg
+++ b/lib/ubsan/lit_tests/lit.cfg
@@ -5,9 +5,10 @@
 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)
+    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.
@@ -17,9 +18,9 @@
 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-ubsan")
+  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)
@@ -27,9 +28,9 @@
   # 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.params.get('ubsan_site_config', None)
+  ubsan_site_cfg = lit_config.params.get('ubsan_site_config', None)
   if ubsan_site_cfg and os.path.exists(ubsan_site_cfg):
-    lit.load_config(config, 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
@@ -45,7 +46,7 @@
   if not ubsan_site_cfg or not os.path.exists(ubsan_site_cfg):
     DisplayNoConfigMessage()
 
-  lit.load_config(config, ubsan_site_cfg)
+  lit_config.load_config(config, ubsan_site_cfg)
   raise SystemExit
 
 # Define %clang substitution to use in test RUN lines.
diff --git a/lib/ubsan/lit_tests/lit.site.cfg.in b/lib/ubsan/lit_tests/lit.site.cfg.in
index a212393..b0e4274 100644
--- a/lib/ubsan/lit_tests/lit.site.cfg.in
+++ b/lib/ubsan/lit_tests/lit.site.cfg.in
@@ -2,7 +2,7 @@
 # Do not edit!
 
 # Load common config for all compiler-rt lit tests.
-lit.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/lib/lit.common.configured")
 
 # Load tool-specific config that would do the real work.
-lit.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")
+lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")